Thursday, November 12, 2015

Vagrant - Useful Commands

This is a list of useful commands to use with Vagrant. These commands are useful to know and saves time on searching. To see the argument options along with the command, click on the command.


Vagrant Reference URL

Manage (add, remove, etc) virtual boxes

$vagrant box
// See the list of boxes installed into Vagrant.
$vagrant box list
// See any outdated boxes currently installed.
$vagrant box outdated
// Remove a box (and replace NAME_OF_BOX with the actual name of your box)
$vagrant box remove NAME_OF_BOX
// Update current box in Vagrant
$vagrant box update

Create, configure box

Create, configure guest machines according to local Vagrantfile.
$vagrant up

Suspend virtual box

Suspend guest machine in use (that Vagrant is managing) rather than shutting down or destroying it. This effectively saves the exact point-in-time state of the machine for resuming later (instead of full boot).
$vagrant suspend

Halt virtual box

Shuts down the running machine (box) Vagrant is managing. If graceful shutdown fails, then use argument 'force' to shut off completely.
$vagrant halt
$vagrant halt --force
$vagrant halt -f

Destroy virtual box

Stops the running machine (box) Vagrant is managing and destroys all resources created during the machine process. This leaves your machine in a clean state as if never used (like a reset button).
Use the 'force' argument to bypass the confirmation dialog.
$vagrant destroy
$vagrant destroy --force
$vagrant destroy -f

Reload virtual box

Halt followed by an Up.
$vagrant reload


Git - Useful Commands

This is a list of useful commands to use with Git. Once in a while, my Windows GitHub GUI app is not working as I would like and I need to do some back-end coding to speed things up. Other times, I just want to bypass using the GUI to speed up my coding or to automate processes. These commands are useful to know and saves time on searching.


Git Reference URL

Refresh my branch list (all branches including master)

- list both remote-tracking branches and local branches.
$git branch -a

Refresh my branch list

- list the remote-tracking branches.
$git branch --remotes
$git branch -r


Tuesday, November 10, 2015

Friday, November 6, 2015

Learning PHP - How to Begin and Win!

Dev Fam,

This is a good way to get started with learning PHP.

http://code.tutsplus.com/tutorials/the-best-way-to-learn-php--net-22287

The author, I think, has done a pretty good job with summing and articulating the steps to hit the track running as a PHP Developer.

Here are some book references as well.



Cheers,
G2

Tuesday, November 3, 2015

GitHub Auth Basics | Using Sinatra (RubyGem) | "Persistent" Authentication

Hi Dev Fam,

This is actually part 3 of executing the GitHub Basic Authentication tutorial. Find part 1 and part 2 that I did here:
http://g2coding.blogspot.com/2015/10/github-auth-basics-using-sinatra.html
http://g2coding.blogspot.com/2015/10/github-auth-basics-using-sinatra_20.html

Implementing "Persistent" Authentication

We add the files "advanced_server.rb" and "advanced.erb" (inside "views" folder). Let's make sure no other code is running this Sinatra server by simply opening browser and accessing port: 4567.


Now, let's run the code. Again, I'm using Windows OS. So, I'll open my command prompt, go to my Ruby project folder and run:
C:\Users\[username]\RubyProjects\github-auth> ruby advanced_server.rb

This is how the home page should display in browser.


Oops, we got an error. The problem relates to the advanced.erb file when accessing a "null" email variable. We'll make the update to the code as similar to the basic.erb (by adding code '!email.nil? &&')


Now, let's run again and see if we have implemented the persistent authentication (stored within our session object).


Victory! Yes, it works! Congratulations, you did it!

My Code

My code is exactly the same as in the GitHub tutorial for the "advanced_server.rb" file. However, I have a slight modification to the "advanced.erb" file. Here's how my code looks in the view.



What's Next?

Try using this authentication from an organization account instead of as a user.
https://developer.github.com/guides/managing-deploy-keys/

Monday, November 2, 2015

Duck-Typing

Dev Fam,

Here's something I just learned today - Duck Typing.

https://en.wikipedia.org/wiki/Duck_typing

The name of the concept refers to the duck test, attributed to James Whitcomb Riley, which may be phrased as follows:
When I see a bird that walks like a duck and swims like a duck and quacks like a duck, I call that bird a duck.[1]
I can't believe I never heard of this. Of course, I think this may be from the rising of so many dynamic programming languages and its popular use nowadays.

I like this quote:
Criticisms around duck typing tend to be special cases of broader points of contention regarding dynamically typed versus statically typed programming language semantics.

Of course, if I'm programming with a statically typed language, then I'm not wasting time with this "duck-typing". I need to avoid assumptions and get straight to the point.

But, this is good to know. I encountered this while learning Ruby.

Peace,
G2