Set JDK enviroment path in Fedora

After installing PHPStorm in Fedora 20, I was trying to run it for the first time and getting this error:

To solve this you need to edit ~/.bashrc

and add the following line.

Use PhpStorm External Tools

Phpstorm

PhpStorm is an awesome IDE.

One of the it’s features is the ability define External Tools and call them when needed.

The examples that I’m going to show in here is using the command line for calling some Symfony Framework App Console commands, but you can choose anything.

 

Mac Preferences Window

Mac Preferences

 

With PhpStorm open, go to PhpStorm > Preferences menu (mac) File > Settings (win) and in the window that popups, search and click on External Tools on the left side.

 

 

 

 

 

on Mac

on Mac

 

On the bottom right (mac) top right (win), you can see some buttons, click on the plus

 

 

on Mac

on Mac

 

A window popups with some command configuration stuff to add.

 

on Mac

on Mac

 

 

 

 

 

All the items in the popup are pretty self explanatory, so we are going to try to fill some of them.

After this we can click OK, and close the preferences window.

 

on Mac

on Mac

 

 

 

 

 

 

Now if you take a look at the Tools menu you might have something like this.

 

on Mac

on Mac

 

If you click on PHP Version, the terminal window will open and show you something like this.

 

 

 

 

This is a very simple example, but you can start being very creative with these commands. For example people who use Symfony2 many times have to clear the app/console cache or other stuff, so let’s going to create some shortcut’s.

on Mac

app/console clear cache on Mac

on Mac

doctrine update on Mac

 

Get creative :)

 

Prevent date_default_timezone_get() warning in Symfony2

Symfony

Hi,

For those who had this kind of problem when using Symfony2:

just add this to app/AppKernel.php

Unity 3D C# script for continuous rotation

Unity3D

Just some basic script for continuous rotation in Unity3D, with some simple params.

Also available on gists: https://gist.github.com/Narven/0e3c355f5ae675c2a352

jQuery prepend, append, before, after

jQuery

One of the most used methods (at least for me) are prepend, append, after, before

They allow to add html to specific areas.

prepend()

Imagine that we have something like this list:

If we need to add a new list item ‘Item 0′ at the beginning, we can do it by using “prepend()”

append()

Append works the same way, but adds to the end of the list

before()

Image that you want to add a item to the list, before the the last item:

after()

Image that you want to add a item to the list, before the the last item:

Demo

Vagrant, no more MAMP?

Vagrant

Vagrant, what is it?

Vagrant is a command line manager for VM (Virtual Machines). Vagrant allows developers to create and manage virtual machines using the command line, and most important of all, allows developers to specific say what they what to be included in that VM.

Vagrant was created by Mitchell Hashimoto (@mitchellh).

You can think of Vagrant as a “Virtual Machine Configurator and Manager”. Image that you go to a website and you can customise the car that you want to buy. You can choose the interior/exterior colours, type of engine, etc. This is what Vagrant does for you. You specify what you want to be included in the VM and Vagrant handles the rest.

That previous example was a little bit weird for a developer. Let me try to explain in another way. How many times, you had to setup one host so that you can work on a project? How much of that environment resembles the final production server where that project is going to be deployed? Probably you know that it uses LAMP, and you just fire up MAMP, and start coding.

How cool it would be that you could have an environment equal to the production server? With Vagrant you can. Just tell what you need and Vagrant creates that environment (VM) for you.

How to get started?

First of all you need to have install VirtualBox.

Then you need to download and install Vagrant. Just click the latest version, and choose the correct file for your OS.

After downloading and installing Vagrant you just need to create an empty directory for your project. And inside of it run the command:

and you get something like this:

A Vagrantfile has been placed in this directory. You are now

ready to vagrant up your first virtual environment! Please read

the comments in the Vagrantfile as well as documentation on vagrantup.com for more information on using Vagrant.

if you try listing the directory you get something like this:

This creates a simple .vagrant directory, and a Vagrantfile. This Vagrantfile is where we specify all of our configurations and specifications.

The Vagrantfile looks something like this:

NOTE: I’ve removed most of the comments in the file.

Now if we run the command:

you get something like this:

This make take a while, but only for the first time. You can change and update all the configuration and run the command:

and Vagrant will update the VM to the specified changes.

Soo now we have a VM at our disposal. Just run the command:

and we get something like this:

IT’SSSS ALIVE :D

now we are inside a Linux VM.

 

Vagrant works with something called a “box”. What is a “box”?

Well a box, is a pre-made VM (bootstrap) for the VM that you want to build and customise. So every VM that you want create/modify to your needs, starts with another “clean” VM.

In this default example, since we did not specified any box, Vagrant uses a Linux Ubuntu box called lucid32. There are a lot of box’s that we can specify that we want to be our base box. Please check this link (http://www.vagrantbox.es/)for more information about it.

If we take a look at our Vagrantfile we have this line where we can specify the url of the bootstrap box that we want:

just change it to something like:

By making this simple change, instead of using the Linux Ubuntu Lucid32, we are using, CentOS 6.2 32bit (with puppet).

The Vagrantfile is very simple and easy to understand. For more information, please take a look at the documentation.

Conclusion

Vagrant has a lot of more configurations and providers (Puppet, Chef, etc) that help to configure everything that you want to be installed in the VM. And has the main ability, that you can share the Vagrantfile with team developer and he will get the same VM to work.

I’ll be posting some more information soon explaining how can you achieve your perfect VM.

My fav Sublime Text 2 shortcuts

Sublime Text

Hi. These are the most common keyboard shortcuts that i use in Sublime Text 2 (WIN):

Ctrl + Shift + P – Commands list

Ctrl+P – Go to anything. I just hit Ctrl+P and type parts of files I want to open – huge time saver.

Ctrl + Space – Auto completion.

Alt + 1, 2, 3, 4, … – Switch between open files’ tabs. Not to waste your time grabbing a mouse, and clicking on a tab.

Ctrl + PgUp/PgDn – Cicles throught the open files

Ctrl + click somewhere in your code – multiplies your caret, so you can simultaneously enter, delete, overwrite your code. Hitting Esc will exit this function.

Alt + Shift + W – Wrap selection with a tag. Select text, hit shortcut, enter tag’s name, done.

Ctrl + Shift + T – Open last closed file

Alt + Shift + 1,2,3,4,5… – Splits the screen into multiple views for multiple files

Ctrl K ,  Ctrl B – Opens/Closes the file explorer

Ctrl + G – Goto line

Ctrl + H – Replace

Ctrl + F – Find

Shift + Ctrl + D – Duplicates the current line, or the selection, if something is selected.

Ctrl + D – If no thing is selected, (can be previous selected)  the current word closest to the caret is selected. Keep hitting this shortcut will select near by strings that are a match, and can be used for multiple editing.

Hope helps someone ~:o)