Working from home and not having it suck balls

10/02/2010

This is my typical desktop (well one of them) when I’m doing work at home. I really like kate as my code editor. It does pretty much everything I need and I like the built in terminal and the extensions & scripts you can use with it. But I’m not here to proclaim another holy war begun, instead I want to outline some of the tools I’m using in the background to avoid ripping out my hair and generally being more productive as a *nix based developer. For the most part, half of this shit works fine on a mac too out of the box. Something my good friend ServeBlunted will happily remind me of.

I say “some” tools. I really only mean one. SSH. Thats it. As a linux user both at home & at work I spend a lot of my time in X. It can be handy to have a GUI app I’ve got on my work machine running at home if I’m working so when I ssh into work I always tunnel through X. You can do this by just adding “-X” as an option.

ssh -X jaymz@work.company.com

X tunelling is handy, it sure beats trying to work via the likes of a VNC session, but the best thing about SSH for me is sshfs. Using that you can create a folder on your local machine and then mount a remote folder over SSH to it. Then you fire up your editor and work away. If you’re like “yeah, whatever, I can edit my files via FTP in my editor and it syncs” then shut up, go give it a go and get back to me. It’s a lot more flexible, you almost forget its a remote filesystem. To mount a remote folder as if it’s sitting on your home machine its typically done like this:

sshfs /tmp/local jaymz@work.company.com:/var/www/dev-code

Where you’d replace the names of the folders with whatever works for you. This lets me mount my code and work on it from within any application as if it was totally local. In the above screenshot I’m actually working on code on my work computer a few miles away. I’ve also ssh’d in via the built in terminal so for all intents and purposes its just like I’m working at the office. The final thing that ssh makes easy for me is port tunneling. I don’t use this as much but it can be handy. The basic command is:

ssh -L 8080:10.10.91.1:445 jaymz@bowser.worknetwork.com

The red number is the local port. This is what you are going to be using in any config or browser screen on your workstation. The green IP address is the machine you’re actually interested in connecting to and finally the orange port is the port in question that you want to connect to. Then you give it your login credentials as you would normally. This is really useful for when you have dev servers that are locked down to only local network connections (like a mysql setup to only connect via localhost for example). The above is what I would use if I wanted to connect to the firewall’s web interface. This is only accesible to my workstation in the office but using tunnelling I can bring it up from home without tunnelling X and loading firefox (which would also work :) ).

There are a whole lot of ways to set tunnels up with SSH, the -L means you are wanting the connection to go from your local machine to the SSH box and then to the destination. You can also use -R which goes from the SSH box to your local machine and then to the destination. You might need to read that a few times :) There’s a whole lot more info on tunneling here.

No Comments

Why I like open source

28/09/2008

I’ve been mucking about with Python of late, well more Django, and one of the ways I’ve been trying to learn it is by writing small scripts to do something ‘real’. Since one of the things I like doing is graphic work my python ‘apps’ are centered around doing something of use to do with that.

The first python app I wrote let me click on points in a photo to build up an RGB gradient. Writing this for GIMP was ridiulously easy since I could just have a look at the source code that handles gradient files. These GGR files are very simple consisting of just a plain text header & some (decimal) color codes. Photoshop on the other hand uses an undocumented binary file. So my script outputs GIMP compatible gradients.

Fast forward to last night and I was browsing my bookmarks and clicked through to ColorSchemer.com. Its a cool website with user submitted color schemes. Theres a couple of generated graphics on the site for each palette and the option to download the .cs file for it. This file is, like photoshop assets, in binary form but looking at it in a hex editor it’s quite obvious where the interesting bits are. It took maybe 15minutes to write a quick python script to convert these into GIMP compatible palette files.

This is one of the reasons why I like open source, information is transparent. I just opened an existing GIMP palette file into a text editor and there was the information I needed to create new files. And I didn’t have to jump through hoops or employ some sort of encryption. Nice and easy :D

No Comments