Best Vagrant Lamp Stack

imagine setting up a vagrant and playing around with the vagrant config file. boots up and some libraries are not working, dependencies not working…etc.

thanks to scotch box, a vagrant lamp stack that just works

https://box.scotch.io/

FTP in yosemite

we can use the in build ftp daemon

To load:

sudo -s launchctl load -w /System/Library/LaunchDaemons/ftp.plist

To unload:

sudo -s launchctl unload -w /System/Library/LaunchDaemons/ftp.plist

Vagrant Authentication fails

Sometimes things go wrong during vagrant setup especially if have set it up already. You might get errors like “Authentication Failure” during “vagrant up” command. It is troublesome to get into the VM if there is no ssh key.

Type in

vagrant ssh-config

To see whats happening.

make sure u have ssh keys already.

then get into the vm with user “vagrant” and passwd “vagrant”

put id_rsa.pub into ~/.ssh/authorized_keys

you should be able to ssh into vagrant vm with “vagrant ssh” now.

Asynchronous vs synchronous in javascript

you often see the terms asynchronous and synchronous in javascript. there is significant difference between the 2 and it affects the way you code. When executing something synchronously, you wait for it to finish before moving on. When executinge something asynchronously, you move on to the next task before it finishes.

google map geocoding is asynchronous for example, so you need to pass a callback method to execute upon completion of the request

Form by_reference = true

if you are extending an entity, most of the time, you can ignore the by_reference field option. This is because it is set to true by default and its usually what you want.

for example

$formMapper->add('owner', 'entity', array(
                'class' => 'YourBundle:User',
                'multiple' => false,
                'required' => true,
                'label' => 'Gallery Owner'
                ))

This form field uses the variable “owner” as defined in the user class. it will call setOwner in the user class when the form is submitted before saving into the db.

Setting by_reference to false forces the framework to call the setter on the parent object instead. Since you are extending the parent entity, most of the time, you don’t want to touch the parent entity.

Simple way to redirect user if Mobile

Javascript can detect screen size and redirect users if they are using mobile. I’ve found that checking the screen size and redirecting users based on that can cover 99% of the use cases rather than injecting some complicated browser detection javascript libraries.

The screen width of IPAD is 768px and screen width of a bigger mobile is 500px. So it would be safe to say that you anyone browsing the site using mobile phone would have a resolution lesser than 700px.

A simple script like that will work

if (screen.width <= 700) {
  window.location = "http://your-mobile-site";
}

The most time consuming part of software development process

People seem to think that the most time consuming and tedious part of developing a software is the coding of the software. This is wrong.

The most tedious process is to get the right requirements for the project. Good business requirements without loopholes give good boundary of how the software will evolve. Screenshots and user journeys are really important. People seem to underestimate the importance of this beginning step, leading to scope creep while developing the software.

You can outsource coding but you cannot outsource requirements gathering. You cannot outsource the relationship with your client.

People say “we are agile now”, why are we still taking so long to develop a bug free software? You have the answer yourself.

Software developer survival skills

To have a career as a developer, you need to have some important basic skill sets. All (new) technologies are built on top or around some commonly used technologies. People always say, “WOW, this technology is really hot now, you should learn it!”. Yes, but to even know the basics, it will take years to learn the pre-requisites.

Take a modern framework – Symfony for example, to know the framework well, you will need to know HTTP protocols, MVC, Object oriented methodologies, HTML, CSS, Javascript, Forms, Database Relationships, PHP, Version control, Basic Linux…etc.

Technologies evolved so fast that most University curriculum could not catch up. Most of the time. people spend years learning something that you only use 1% in your real job. That is why practical training is so important.

If you are looking to become a developer, learn these skills and you can branch off to anywhere:

1. Git and Git flow
2. HTML, CSS
3. Javascript
4. MVC and Object Oriented thinking
5. Basic system administration (bash scripting)

The last most important skill is personality. Be a human and don’t be a robot.

You will need these skills irregardless whether you want to be a front or backend developer majoring in any framework like rails, angularjs, nodejs, laravel, django, symfony…etc.

Why Symfony?

Choosing the best framework for rapid development has been a topic that has been debated to death. Today, there is no longer “the best framework” because all modern day framework is scalable and robust, they learn from each other. They are all adapting very fast to new techniques of doing things.

At the time of writing, nodejs and rails continue to innovate with php chasing fast behind. They have all very similar development methodology, so knowing one framework well means you can jump between other modern day frameworks easily.

For php, its Laravel and Symfony. if you want to invest your time, I recommend symfony because it is more stable when compared to the rest. Symfony components have been used by many projects including Drupal and Laravel.

as for Django and Rails, I am leaning more towards rails.

Symfony 2 is a mature framework. A mature framework means information and libraries don’t get outdated quickly. Some framework moves so fast that the 3rd party libraries couldn’t catch up. Rails early days suffered from this. Nothing worked out of the box because googled information was often outdated. Choose a stable framework so that you don’t spend lots of time setting up the right environment and troubleshooting the libraries for example. You should be spending more productive time learning the software.