Tuesday, January 31, 2017

docker : folder sharing on windows


To share a folder / volume using Docker, you need to understand the layers involved. There are 3 main layers - which are

Host (Your machine) -> Docker (a virtual machine using Oracle VM called default / or your Windows Hypervisor )  -> Image (the image you download from Docker hub for example hello-world or ubuntu.


Virtual machine configuration 

Using Oracle virtual machine, shutdown default virtual machine if it is already running. The click on Properties->Shared Folder->Add your share location as shown below :-

In this example, you're sharing /c/blog -> c:\tmp\laravel\blog


Running the container

Next, we will mount the volume to a container path /var/www/laravel. What's going on is we're trying to mount virtual machine shared folder (indirectly host machine share folder) to a container folder.

docker run -p 8000:80 -p 443:443 -v /c/blog/:/var/www/laravel/ -d eboraas/laravel

I think many people got confused with providing a windows directory here. (-v /c/blog with /c:/tmp/laravel/blog). You need to share your host folder with virtual machine first.

After this command executes, we're have a container with directory.

Monday, January 30, 2017

Google cloud bitnami LAMP mysql data password



After you spin up a Bitnami LAMP server and you might wonder what is the mysql database password .....well, just go into Google Console and open up details of your LAMP server.

Then look under bitnami-based password as shown below :-



After that try ssh into your LAMP server and then login to mysql with the password above :-

mysql -u root -p

powershell : get date from epoch / linux date


This is going to be a relatively short post and here's the code get a datetime from epoch time. The $time parameter looks something like 1485810174


Wednesday, January 25, 2017

Deploying Laravel on Google Cloud



Since Google Cloud Platform Bitnami LAMP comes ready with composer and Laravel, we can drive straight in, after you spin up a new LAMP virtual machine.

The public directory accessible to the world is htdocs.

Lets change directory to htdocs by issuing this command "cd htdocs"

Run the following command
composer global require "laravel/installer"
Next, we will create a application using the command below: -

$HOME/.composer/vendor/bin/laravel new blog

Please note that this will create a directory called blog under htdocs.

Important! Ensure a folder called storage is writable by

cd blog

Then issue the following command

chmod -R o+w storage

Fire up your brower and browse to the following link
http://your-lamp-server-ip/blog/public/index.php
Your laravel page will fire up. :)







Tuesday, January 24, 2017

Project WAH - (What Happened Here)



WAH - (What Happened Here) - Is a project that allows developer to figure what's going on with an application during runtime. For example, if an application crash, we wanted to find out why.
Unfortunately most of the it time, we ask did you enable logging, read through the logs and find out its root cost and finally cross check that with source code. This takes up alot of time
Instead of using the traditional logging, it allows developer for ask the app what actually happened and why it crash. Yeap, something like interrogation - but with more intelligent way.




Monday, January 23, 2017

Powershell script to read all the queue available on a host


The following codes gets a list of queue listed on activeMq Host server using NMS Provider.

Docs on deploying LAMP apps to Google Cloud



Apparently the following links provide good information on deploying PHP based application.

https://docs.bitnami.com/google/infrastructure/lamp/

So what is supported in this LAMP package?

Php scripting language, Apache Web Server, MySQl, MariaDB, phpMyAdmin.

It also support Zend Framework, Symfony, CodeIgniter, CakePhp, Smarty and Laravel. So essentially you can dive straight into development.

Sunday, January 22, 2017

google cloud platform : using the lamp stack


when i first install my LAMP stack on Google cloud, I am at a loss trying to find my way  through. The only thing available was ssh. What if  i wanted to install Laravel?

Thankfully it came with "Composer" - PHP dependency manager. I was able to fire up my ssh and just install Laravel using the following command :-

composer global require "laravel/installer=~1.1"

Phew that's was easy

Once you have installed that, $HOME/.composer/vendor/bin/laravel new blog

And you have just created your first project :)


Thursday, January 19, 2017

powershell gotchas :- Use global variable / function when you have event in your code


Did you know that its a good idea to use global function and variables when you use event in your code.

Have a look at example below :-



You will not be able to call GetActiveQueueMessage function and your script just dies.

Key take from this is, if you have event, any variable or function you're referring to, please make sure its defined on global or script scope.

Otherwise, you pretty much get uninitialized or empty variable everywhere.







Tuesday, January 17, 2017

passing parameters in powershell script



Lets say you would like to pass some parameters to your powershell script, you can easily do it using the param keyword. You just have to have it right on top of your scripts. I know this kinda lame post but sometimes when you just can't seems to be able to write that code out.... :)


powershell encrypting credentials using key


Think many of us, already know how to encrypt password in our powershell automation and normally we would just use "Get-Credential". This approach uses Windows Data Protection and only the same user will able to encrypt / decrypt a secure string.

Alternatively you can use a key for the same purpose. Here's my quick and simple  script to encrypt a password.



So we're using our key which starts from 1 until 16 and then it encrypts our password which is "admin" into a file called "password.txt".

Lets instantiate our credential object. Its just a call to say instantiate PSCredential('username', 'password' - tho its a big longer)




We now have a object called MyCredential which stores username and password (extracted from encrypted password.txt file.

We can just pass $MyCredential username and password into our application for further execution.






Monday, January 16, 2017

Powershell to read JBoss Fuse activeMQ using Powershell with NMS Provider .Net



There wasn't much documentation available. Essentially you need 2 files to get your apps running, namely :-

1. Apache.NMS.dll

2. Apache.NMS.ActiveMQ.dll

Next, you can carry on with your powershell coding using code example below :-

In summary, it create a timer and easy elapsed interval, it goes and peek at the message queue. If it is older than a pre-configure days, messages gets archived into a file. (this module is not implemented yet).

Assumption : You have installed and configure activeMq provider like Jboss Fuse.






Powershell - Creating a timer



Creating a timer in powershell is almost the same as in .net, well it is the same :).
The tricky part is event registration. As you can see below, we using Register-ObjectEvent to link an event handler to our Elapsed event.

ionic2 - unable to issue http.get / post


Probably faced by many ionic 2 developer. You can probably fire up your android studio, fire up your android emulator, deploy app and then look at android monitor window for error messages or .....

The fix




Please ensure you allow http and  https connection out to different host in your config.xml file. (i assume that you have installed cordova whitelisting plug-in component.


Thursday, January 12, 2017

ionic2 cordova build android - Unable resolve gradle 2.2.3


Faced  this problem when trying to build android using ionic2/cordova. Seems like com.android.tools.build:gradle:2.2.3 is not listed in maven.org (but is available in jcenter).

I was able to compile and run it using Android studio 2.  Would still trying to find a better solution here.

* What went wrong:
  A problem occurred configuring root project ''.
  > Could not resolve all dependencies for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:2.2.3.
 Searched in the following locations:
     file:/home/ubuntu/.m2/repository/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom
     file:/home/ubuntu/.m2/repository/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.jar
     https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom
     https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.jar
     https://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom
     https://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.jar
 Required by:
     :<myproject>:unspecified


After some time, this error comes from CordovaLib (reference projects for Cordova). To resolve this, I edit "build.gradle", remove mavenCentral to make it look like code below :-



Next, i was able issue 'cordova compile" or "ionic build android" to build my project successfully. (You can't use ionic command as it would replace the entire project file).

Problem solved! :) Unless, you completed remove Android source in platform folder.


Update : This is fixed in Ionic Framework release 2.0.0













Wednesday, January 11, 2017

cordova-plugin-file-transfer can only be used for emulator or hardware devices



Was playing around with ionic and crashing beyond recognition. AppInBrowser, File-Transfer, Push notification plugin don't work with browser. It only works on emulator and mobile devices.

Going back to work ! 

Monday, January 09, 2017

Zurb foundation responsive email site is awesome

If you ever wanted to write any responsive email html and see how it looks like on different platform like on IOS, Android, Outlook 2015, Outlook 2013, Gmail, Yahoo and many more... try going to this link http://foundation.zurb.com/emails/getting-started.html

Truly awesome! :)

Have alook at some examples given :-

http://foundation.zurb.com/emails/email-templates.html

There is a couple of catch tho, You should download templates from here (click on Download Foundation for Emails).

http://foundation.zurb.com/emails/docs/css-guide.html

Once you follow the example and crank up some email template of your own, please test it here.

http://foundation.zurb.com/emails/inliner.html

If you still have problem downloading, you can still get it from github.

https://github.com/zurb/foundation-emails-template/tree/master/src/pages


Thursday, January 05, 2017

Javascript ES5, ES6 and next is pretty confusing


Think ES5 and ES6 language features are pretty confusing. I got mixed up with ES2015 with ES5, thinking "let or destructuring" feature were actually supported. What a huge mixed up.




What was actually supported by ES5 is pretty minimal. ES6 is a huge change.

You can easily find out the list of features ES5, ES6 supports by clicking on this link here.

To learn about ES6 or ES2015, please click here. Think i just got confused again.