I’ve moved my blogging home to a new place
From now on I’ll only post in there, so update your rss subscription!
I’ve migrated some articles to the new blog so you might get some duplicates, sorry about that.
Iván<
I’ve moved my blogging home to a new place
From now on I’ll only post in there, so update your rss subscription!
I’ve migrated some articles to the new blog so you might get some duplicates, sorry about that.
Iván<
Firefox is a great browser and is also a great development tool in itself. There are some problems though with the numerous extension available to developers. They are a great resource when programming but they slow down (and in some scenarios they might even break) our normal web browsing.
So the idea is to have a normal Firefox installation to use as our browser and then a separate install (and profile) used only for development purposes. This way we can install tons of development related addons without worrying about slowing down our normal browsing. Of course this is only useful if you use Firefox as your primary browser.
c:\dev\Develfoxfirefox.exe -no-remote -ProfileManager
develfox.bat with the following contents. It’ll copy on each run the firefox executable to develfox.exe so we can tell it apart from our normal browser on the task manager (we copy it on each run so that automatic updates are correctly applied).@echo off
copy “c:\dev\develfox\firefox.exe” “c:\dev\develfox\develfox.exe” > null
start “” “c:\dev\develfox\develfox.exe” -no-remote -P “Devel”
Following with the series I will introduce in this chapter Cygwin.
Cygwin is an excellent collection of Unix utilities and programs ported to Windows. While its ‘emulation‘ of an Unix like environment is quite good I actually don’t use it. I install it just for the helpful utilities it has. Although I do occasionally use its shell to perform some command line tasks which on Windows’ cmd.exe would be a real nightmare to perform.
Lets set it up and then we can see some tips and tricks.
c:\dev\cygwin and launch itc:\dev\cygwin and the Local Package Directory to c:\dev\cygwin\packagesc:\dev\cygwin\cygwin.batOk, so Cygwin is now setup and it’s time to learn a few tips.
On a standard installation Cygwin will create a home directory for the user in c:\dev\cygwin\home\[USER]. However we might want to re-use our Windows folder so we have a unique location for our stuff. To do it we just need to create an environment variable (in System Preferences) called HOME with the path to our profile folder (c:\Users\[USER] in Vista). Now we have to edit /etc/passwd and change the home folder to our Windows profile one (/cygdrive/c/Users/[USER]), we can move the contents of the old home folder to the new one with the following commands:
mv /home/[USER]/* /cygdrive/c/Users/[USER]/.
mv /home/.* /cygdrive/c/Users/[USER]/.
By default the Windows drive letters are accessible in /cygdrive/[DRIVE], that is ok but it’s used often so we can save a few key strokes by creating symlinks at the root of the file system. Create one for each of your drive letters so you can access them as /[DRIVE]/my/path/to/a/file.
$ ln -s /cygdrive/c /c
As we have seen Cygwin uses Unix like paths so to launch Windows programs from the shell we have to make an extra step and that is to convert between paths. Fortunately there is a little tool called cygpath. When used without modifiers it will translate a Windows path to a Cygwin one and when used with the -w or the -m modifiers it will do the opposite conversion.
Another nice tool is cygstart which launches a program (or the default program associated with a document). The good about it is that it will launch the program and detach the process from the console.
For commonly used programs it’s a bit uncomfortable to use cygpath and cygstart, like for example to launch our favourite text editor. In this example I’m going to use Notepad as an example. We just have to change our bash init script (~/.bashrc) to include a function to launch Notepad easily from the command line. Add the following to your .bashrc file:
notepad () {
cygstart “c:/Windows/System32/notepad.exe” “`cygpath -w $1`”
}
Now we can edit the contents of a text file just doing notepad /var/log/setup.log. This is a great way to really integrate Cygwin with Windows, which actually makes the Cygwin system ready for real work.
Another useful utility is cdargs which while not an official part of the Cygwin system can be compiled from source. To install cdargs we just have to download its latests source tarball and unpack it into your Cygwin home directory. Then issue the following commands:
$ cd cdargs-1.XX
$ ./configure
$ make
$ make install
$ cp contrib/cdargs-bash.sh /etc/profile.d/.
$ source /etc/profile.d/cdargs-bash.sh
Explaining how to use this tool is beyond the scope of this article. There is a nice mini tutorial at Linux.com and Google will give you plenty of information about this tool.
There is a lot of software compatible with Cygwin beyond the packages included in the official repository. The Cygwin Ports project offers a few dozens of applications already compiled and ready to be installed. It’s well worth a look.
Besides there are many Unix/Linux applications which can be compiled to be used in Cygwin even if they don’t redistribute the binary packages.
Disclaimer: This will be a series of posts dedicated to document my current development setup. This setup tries to be the one of a Ninja. It won’t end up with a bunch of boring application windows typical of a bald engineer. It also won’t be a group of black terminal windows running vi as a pseudo operating system like the average geek wannabe. I’m in the search of the Ninja feeling, with white on black text editors, translucent terminals and a dose of eye candy so that I feel special without having to resort to browsing youtube with Lynx.
After many years I am finally happy with my current development setup. It fits my needs and this series of articles should serve myself as a reminder on how to setup the different pieces. However I guess that it will also be of inspiration for other developers who haven’t already found their peace of mind with their environment.
I’ll focus on Microsoft Windows systems but most of the stuff can be easily implemented in other operating systems. Actually much of the things I do for windows come standard in several operating system distributions, it’s just that I happen to like Windows (which obviously harms my geek status).
The main building blocks for this environment are the following ones:
Before we begin I would like to note the following:
Nothing really new since there is already a firefox extension which does just the same but I also wanted support other browsers.
So this bookmarklet toggles the cookie Xdebug uses to flag if it should debug the running script or not.
Drag it to your bookmarks (or favourites or whatever is called in your browser) toolbar so it’s easy to access. Assign it a keyboard shortcut if your browser has that function.
By default it’ll prompt for the idekey to be used by Xdebug, it’s a good idea to modify the idekey variable at the start of the bookmarklet’s source with your idekey or with ‘default’ if you’re not using a DBGp proxy.<