Coming back to rails

I’ve worked with rails previously before , but that was a long time back and even though I’ve continued to dabble with it, I’d never built anything complete or large enough with it. This time, however, I’m working on an actual large-scale application with all the nuts-and-bolts that make rails such a pleasure to work with. Since I’m coming back to rails after such a long time, I thought I’d document some of the cool new features that I’ve found in rails this time around.

Spring

One of the major discomforts of working with rails on the command line was that it is heavy and slow. Spring works behind the scenes on the second issue, namely speed. Here’s how the project’s README describes itself:

Spring is a Rails application preloader. It speeds up development by keeping your application running in the background so you don’t need to boot it every time you run a test, rake task or migration.

You can update all the binaries in your PROJECT_ROOT/bin/ directory (which include rails, bundle and rake) to make use of spring by executing the following command:

bundle exec spring binstub --all

Any further execs (such as ./bin/rake -T) will make use of the spring pre-loader leading to much faster startup times. You can even use spring against the default system binaries by prefixing the commands with spring, such as spring rake -T.

Resque-Scheduler

I needed a job queue for background tasks and polling API services, and what better tool to use than resque. I’m using it in combination with resque-scheduler for running tasks on cron. How it works is that in addition to your main rails server and a long running resque job process, a separate resque-scheduler rake task is kept running, which loads up the schedule and inserts tasks accordingly into the resque queue as per the schedule.

For those new to resque in general, you can start the two processes by:

QUEUE=* rake environment resque:work #To start resque
rake resque:scheduler

Note that we are pre-loading the rails environment in the resque:work task as it will load rails for you across all of your tasks. Also note that you will need the following two lines in your Rakefile to get these tasks to run:

require 'resque/tasks'
require 'resque/scheduler/tasks'

Also remember to define the resque:setup task according to the resque-scheduler README, which would load the schedule and config as needed.

This blog post is a work-in-progress and I will continue to update it with bits of rails-foo as I learn more.

Rake-notes

I’d never tried using notes before, and as it turns out, using rake:notes is easy and super-awesome. Its allows you to spread your notes about TODOs, FIXMEs and such throughout your codebase and take a bird-eye’s look at them with just a single command.

Read more about it at http://siong1987.com/posts/powerful-and-hidden-rake-notes-in-rails/

A month with the System76 Galago Ultra Pro

With my recent CCTC Winnings, I decided to purchase a new laptop as my old Dell Inspiron was not performing up to the mark. Being of a time before the Intel i-series launch, it was also severely lacking in several features, most notably virtualization support, which is badly needed these days.

After taking a thorough look at the various offerings in the market (and being disappointed by most of them), I decided to go with the [System Galago Ultra Pro][galago] for the following reasons:

  • Linux Support (Just Ubuntu actually, but its nice to have a laptop that supports and comes with Linux pre-installed).
  • Intel HD 5200 Graphic Card. Even though the nVidia/ATI support has been getting better in Linux these days, I wanted a graphic card that I could use without worry, for both playing games, using webGL without having to worry about things like overheating and switching card modes (optimus/bumblebee and whatnot).
  • Haswell. Not many manufacturers are currently offering Haswell lineups, and System76 is one of the few with them in the market.

The other few machines I did consider included the Apple MBP, Lenovo Ideapad, Dell Sputnik 13. The MBP was rejected because I wanted a Linux machine, and it was overly costly; the Ideapad had a touch screen, which I abhor; and finally the Sputnik is too expensive as well.

A few other machines were rejected because I was exclusively looking for a 14-inch screen, due in part to my experience with my previous bulky machine.

Hardware Review

The build quality of the Galago is above average, but its still a flimsy offering, when compared to the MBP or other business class offerings such as the Vostro. A lot of the Galago reviews on the internet talk about the defective keyboards, but I faced no such issues. It seems to have been fixed, and the keyboard has been iterated several times since, I think.

The IPS screen (1920x1080) is a real gem, and I’ve gotten used to watching everything in full HD these days. The laptop has 2 small fans on the lower side, and they hardly ever kick in, making it a quiet laptop. The only times it heats up much is when I’m playing demanding games or doing something GPU intensive. A few issues that I’ve actually faced with it include:

  • The Esc key not responding to all presses. I have to hit it with a slightly extra pressure for each keypress to register. However, this is just a quirk I’ve come to accept, and work around. My muscle memory soon overtook and I’m now used to pressing it hard.
  • Missing Media keys. It does have the usual Mute, Volume, and the Play/Pause keys, but the next/previous media keys are missing on the keyboard.
  • The charger getting heated up (a lot). It even heats up when the charger is not connected to the laptop.
  • The inbuilt speaker quality is definitely not above average. I usually use my earphones with it, so its not much trouble to me anyway.
  • The “clickpad” becomes a “touchpad” in Windows, which means drag-drop becomes extremely uncomfortable if you’re not used to it. I’ve installed the official touchpad drivers in Windows from knowledge76, but I could not find a setting to use “clicks” instead of “touch”.

As an aside, I really like the keyboard layout (I don’t like numeric keypads much) and the placement of Del-End keys, which is incidentally same as my previous laptop. I really dislike those layouts where you have to press a combination of Fn+Some key just to trigger Page Up/Down. A note to laptop manufacturers : Please stop messing with the keyboards.

Having a branded Ubuntu key is also a good show-off at some places :) I also have to mention that the laptop is very silent. The fans rarely kick in, and I have faced no heating issues so far.

Software Side

Despite being built for Linux, I’ve still faced a few software issues on Linux. None of these are a deal-breaker though for me. The first time I realized that it wasn’t really built for Linux was when I booted using my external to Ubuntu 12.04 and the WiFi didn’t work. Apparently you need a combination of System 76 custom (though open-source) drivers and 14.04 on this machine to get the drivers to work. This is one of the reasons I haven’t downgraded to Elementary Luna (which is based on Ubuntu 12.04). The issues I’ve faced (along with my workarounds) include:

  • Flash not working on Google Chrome Stable. I talked to System76 support over this, and I’m yet to get it working. As a workaround, I’ve been using Google Chrome Unstable (which I usually use anyway), and it detects flash fine.
  • WebGL support in Chrome is a bit sketchy. Chrome stable doesn’t detect the graphic card as supported, while the Chrome Unstable version did detect it as working for a while, but the graphic card was either removed from the whitelist, or added to the blacklist in a future update, making it non-working again. Currently, I’m using the “Disable WebGL Blacklist” flag from chrome://flags to get it working.
  • Webcam not being detected. This has gotten me a bit puzzled. It was working fine on the fresh Ubuntu 14.04 setup, but some driver issue is preventing it from working now. I think a dist-upgrade should fix it, but I’m not sure. I might try to re-install the system76-driver package if that doesn’t work. Update: It started working again after just a restart.
  • Another minor issue I face is that the brightness key on the keyboard (Fn+F8/F9) allows you to take the brightness level all the way down to zero. So you could make your screen pitch-black, with absolutely no idea how to get it back to normal. This happens only on ubuntu, though.

Overall

Despite its few quirks, I’m liking my new laptop. I’m enjoying gaming on it (on both Linux and Windows), and it has more than enough power to run whatever combination of VMs I want to.

Gaming

All the Linux games from my various Humble Bundle purchases are finally being put to good use. The only game that I haven’t been able to run is Oilrush, which doesn’t support Intel Graphic cards on Linux for some reason. Some of the games that I’ve tried and enjoy on Linux include:

  • Mark of the ninja
  • The Swapper
  • Don’t Starve
  • Fez
  • Bit Trip Runner 2
  • Counter Strike: Source
  • Portal
  • Half-Life 2
  • Civilization 5
  • Trine 2
  • Minecraft

Trine 2 does show some noticable lag on full settings, but its not supported on Intel drivers anyway. Rest of the games run wonderfully on full settings.

I haven’t tried gaming much on Windows, but I do play Blur (admittedly a 3 year old game) sometimes on it at the highest settings.

Specs

The only thing I upgraded in my laptop was an increase in RAM from the default of 4GB to 8GB, primarily because I intend to run lots of VMs on this machine. The rest is same as the specs on the official site (scroll to bottom):

Processor: Intel(R) Core(TM) i7-4750HQ CPU @ 2.00GHz
RAM: Samsung, SODIMM DDR3 Synchronous 1600 MHz (0.6 ns), M471B5173QH0-YK0 (4GiB) x2
Graphic Card: Intel Iris Pro Graphics 5200 with 128 MB eDRAM, Crystal Well Integrated Graphics Controller
Hard Disk:  Western Digital, WDC WD5000LPVX-2, 500GB (465GiB)
Memory: 8GB 204 pin Dual Channel DDR3 @ 1600 MHz (2x4GB)
Intel ME Version: 9.0.20.1447

If you’re interested in getting any further details about the laptop, feel free to contact me.

Deloitte CCTC Wave III

I was winner of the Deloitte CCTC Wave I, and a finalist for the Wave II. It was natural I was participating this year as well. While the first year involved a simple penetration test as the first round, and it was an abstract submission in Wave II; this time it was a closed jeopardy-style CTF contest between different teams from various colleges.

There were altogether more than 30 teams participating in the CTF. I was lucky to have teammates like Abhishek Das(CCTC Wave II Winner) and Ravi Kishore who endured through several challenges when I gave up.

We’ve published all challenges over on GitHub along with writeups and problems being made available wherever we can.

The challenges ranged from very easy to difficult to absurd trivia. We topped the round with the most number of points across the board, making sure we got the +30 bonus for solving first on all but 2 challenges out of 13.

We’ll be leaving for Hyderabad for the finals in the first week of April. Wish us luck, will you.

Update: We won the final event at Hyderabad as well. More details (and a pic) on our blog post on SDSLabs here.