Ruby on Rails
The world is falling down with books, methodologies, techniques, tips and tricks on how to be more efficient in life, work, and everything else you can think of. What isn’t often discussed is how the desktops, both real and virtual can be tailored to act as a strong foundation, and take things to the next level.
I’ve been thinking about this ever since I tidied my (physical) desktop a couple of weeks ago. Wow.. what a difference. Not my strength keeping that tidy, but it got me thinking about my virtual desktop too. As a Ubuntu User with multiple virtual desktops available to me, I’ve always had a strong sense of standard placement of specific applications but after some thought, have taken that to the next level.
The Physical Desktop
I love my latpop, and there are times when I get in the habit of sitting in front of the fire for a few days with it on my lap, but nothing beats the productivity benefits of a desk, a second monitor, a real keyboard and mouse, kick ass sound, and somewhere to set your coffee.
I’m not really going to say much more about it than that – the pictures says 1000 words.
The Virtual Desktop(s)
Now things get interesting. If you are a Windows user then unless things have changed since I last braved using one, you are SOL when it comes to virtual desktops. For Mac and Linux uses, multiple virtual desktops are things that we’ve been using (or haven’t bothered to use) for years.
Anyhoo. Ubuntu and Mac users can have as many virtual desktops as they like. Not sure about Mac, but with Ubuntu you can configure how they are arranged, and maybe because of my old Cube days, I like 4 virtual desktops side by side, and configured so you when you get to one end you wrap straight around to the other.
That means I have four full desktops that I can flick back and forward between, and each has 2 monitors.. 8 distinct areas.
So the secret to making this a haven of joy and efficiency is always keeping things in the same place relative to each other. For example, say all you use is a browser and Word Processor all day long as part of your core job, then an email client, and a music player.
You might do something like this:
Virtual Desktop 1
Laptop: Music Player
Virtual Desktop 2
Monitor: Word Processor
Why is that good? If you are working on a document, and you need to send an email you know that the email client is just over there on the Virtual Desktop to the right. Not a great example, but what happens when things get a bit more complex. I’m a rails developer, and at the very least that involves:
- a browser
- a terminal running the rails server (and putting out useful information)
- an editor
- a terminal running a rails console (used constantly while writing code)
- often a MySQL GUI
As if this isn’t enough, in development one is typically working with many open files at the same time, so multiple tabs within the editor. It’s this last part that made me really rethink my old strategy and for the first time move editing and the browser to different virtual desktops.. and try something that has turned out to be incredibly valuable.
I now have 4 different editors open, with the folder tree in each open to a specific folder of a rails project.
- Project Root (for other.. migrations, configs, helpers, css / js)
Each of these editors
- is not full screen
- has a corner visible no matter what (so you can get to it with a click)
- is always in the same on the screen (I go M/V/C/Other clockwise starting top corner).
It’s all kinds of awesome. The result of this separation of browser and editor left some really great gaps for other things. Here’s a rundown of my 4 Virtual Desktops going left to right.
I have to say after running with this for a couple of weeks, I can’t imagine going back. My fingers have absolutely learned things like CTRL-S, CTRL-ALT-LEFT,F5 (Save code, move left one desktop, refresh browser) and having the Rails server beside the browser and the rails server beside the editor makes so much sense.
Give it a go!
I have no idea how often people ACTUALLY look at their logs looking for someone scraping their pages, but sometimes you want to just fly under the radar. I generally don’t agree with stealing web content by scraping, but I do believe that if someone is in the data distribution business, but they suck at it, it’s ok to bend the rules a little. For example, if they offer an RSS feed that is buggy, slow, huge etc. but their homepage offers the same information more reliably – go for it.
There are basically two things at play here:
- Spoofing a user-agent (pretending to be a browser not a script)
- Spoofing the source of the request.
Here’s a little function you can call to get a random user agent, based on a list of really common user agents.. Thanks to the guy who posted this to a blog, sorry, I don’t have the reference anymore.
I usually put such things in a model utility.rb so I can just call it with Utility.random_desktop_agent
That takes care of user agent, now on to proxy. You’re going to go out and get your own list of proxies.. whether you get some reliable free ones or pay for services. The best services you call a single proxy of theirs, and it will then cycle through a bunch of IP addresses with the call. Each call, through a different one round robin. They then dump those IPs every 30 minutes or so.. not bad.
Again – I put that in the Utility.rb model.
So put it all together..
Calling a page looks something like this with open-uri
That’s about it.