Syed Aslam

Author posts

Working with Files in Ruby

in Ruby · 10 min read

It all starts with the IO class. The IO class is the basis for all input and output in Ruby either by itself or via its descendant classes, particularly File. To a large extent, IO's API consists of wrappers around system library calls, with some enhancements and modifications. A ...

Centering a Fixed-Sized Element with CSS

in Css · 1 min read

Here is one way to center a fixed-width/fixed-height div at the center of its container. This could be adapted to centering text, images, etc. within their containers. Essentially, we do a bit of arithmetic to get the fixed-sized element centered using absolute positioning and ma ...

Loading data from multiple files in Ruby using Hash

in Ruby · 2 min read

Lately, I have been working applications which require data from an external source to be loaded into the local database. One such application is Sydrea (in the making!), which requires the Drug information to be loaded. Drugs@FDA is freely downloadable compressed zip file which ...

Adding close link to flash messages

in Rails · 1 min read

The flash provides a way to pass temporary objects between actions. Anything you place in the flash will be exposed to the very next action and then cleared out. This is a great way of doing notices and alerts, such as a create action that sets flash[:notice] = "Successfully crea ...

Connecting to multiple databases in a Rails app

in Rails · 2 min read

A traditional Rails application uses a single application. We interact with it by writing models that inherit from ActiveRecord::Base which translate connection details (from config/database.yml) via the method establish_connection. Its a spatial application where everything is c ...