Semantic CSS with Twitter's Bootstrap

Earlier this month, Twitter released an amazing UI toolkit for web developers called Bootstrap. In the creator's own words:

Bootstrap is great because it's more of a UI toolkit than similar projects. It lets you quickly create site designs from scratch, by providing all the necessary UI components, instead of just being a grid system, or just providing a library of mixins.

However, Bootstrap met with a lot of valid criticism

On looking through the CSS, it's laced with class names like '.row .span2' and '.container-fluid', which isn't semantic. When the big boys like Twitter dish this stuff out for everyone to use, they're condoning poor semantics for convenient styling and that is damaging to the industry.

I side with the guy, Ryan Taylor, who said the above. Semantic CSS is easier to maintain and Bootstrap isn't semantic. But I wonder if anyone bothered to give a thought about how easy it was to make it semantic, except one guy who ported it to sass.

It's pretty simple to write semantic CSS with Bootstrap if you have gone thru the docs for LessCSS, which Bootstrap uses. Unlike sass, which has a seperate "@mixin" syntax for mixins, LessCSS mixins are just CSS classes. When I got lazy to write my own UI using other libraries, I ported my current side-project to use Twitter Bootstrap and it was simple, other than a couple things which I needed to sort out in order to make it possible to write semantic code with it.

Here's lace.less. It's a couple CSS classes and a mixin to make your semantic life easier with Twitter's Bootstrap.

Use it like below. You should get that at first sight if you've written semantic CSS (else you wouldn't be reading this post).

I'm sure that there are some more stuff that need to be added. But for now, I have the grids working and it'll do for me. I'll add more later when required. That said, stop whining and go make something now!

Posted
 

Per-project environment variables with Foreman

If you haven't heard of Foreman, it's a painless way to kickstart an app that depends on running multiple tools or processes. In short, if you are using an app with a lot of stuff that requires to be run like Redis, a rake task, and then the development server, then Foreman is for you. Check it out.

I've been working with increasing number of projects lately and managing environments for each of those has been a time sink. I do maintain a per-project gemset using rvmrc, which does a nice job of isolating gems. But when each of your projects need some environment variables, your bashrc or bash_profile is going to hell. 

Well, not actually. I dug up the Foreman docs and found something very useful. If you use Foreman, it supports reading environment variables from a .env file in the project directory. So if your current project uses $GIRLFRIEND_VERSION and $GIRLFRIEND_PATH, just create the following ".env" file in project directory.

And start foreman. Your project can now find your girlfriend's version and path ;)

UPDATE: It is very likely that env variables may be different for your team members. I choose to add .env to my global gitignore file and create a "sample.env" file in the directory, with list of env vars with default values and add it to the repo. Anyone who clones the repo can setup the .env with the values specific to their setup.

Posted
 

Paying better

I just read a post by Shalin listing 5 reasons to hire freshers. The #5 reason which he states is "They're in-expensive".

My story till-date: graduated a month-and-three-days before the date of this blog post. Work remote for a startup in San Francisco and completed a month at my first job two days back. My pay is above average considering Indian pay scales for freshers. (I had to strike "above" after reading about the pay-scales at Amazon/Google in India)

Freshers come in 2 flavors (mild joke in a serious post) ones with the flair for programming (has programmed before, created stuff) and the others who can type out a bunch of random lines (you'll find a lot of these people).

I do not know which of these people Shalin was referring to. But if it's the ones with the flair for programming, I beg to disagree. You've got to give people a reason to join your startup. IMO, monetary incentives are under-rated, however interesting the work is.

Like some really nice guy stated a few days back - "Hiring is selling not buying". You are selling your idea/product to your potential hires, so that they join your cause. Ideally your new hires (referring to freshers) won't be getting any equity. So why not just pay them better than average and keep them happy? It isn't possible to mind-read and find out if that guy values monetary details of a job. Or you've got competition - startups that pay better for the same hire. I'm all for paying well.

Quoting one of my previous post:

And if you are trying to hire people to work for your startup for below-avg-pay, it shows that you are selfish and you want to taste success, without even wanting to thank those who led you there.

This post assumes that you are hiring only when you actually need to.

If someone said recession, I'm already crying. There was never a recession for the valuable employees/hires.

P.S: This post is in all faith a good discussion and totally my opinion.

Posted
 

Learning by Creating vs Learning by Books

Creator of Erlang, Joe Amstrong, posted a very nice message on the Erlang mailing list[1] in response to a post asking about ways to get started programming. The message is gracefully written and can be understood by anyone who has put in atleast some effort to learn about programming.

After playing with the compiler or interpreter for a while, he suggests buying decent a book and typing out programs from it. I respectfully disagree. Books and scientific papers were the only source of technical bytedom. But these ways, you can learn anything you want without books. Just google a few tutorials and you'll find a lot of get-started-in-10-minutes web pages trying to teach you X language. I strongly suggest googling one of these and skimming through it.

True, that these anything-in-10-minutes pages won't teach you much, but it does teach you enough to create something. I've always emphazised on creating stuff rather than just going through a book and typing out programs you find somewhere. The fun of creating something on your own is always a better learning experience. You beign to challenge your conventional knowlegde, against the way a task is done in a language's syntax. For example, people who come from an imperative languages background might feel a bit alien while trying out funcitonal languages. But when you try to search stuff on the net as to why you aren't able to do something, you begin to learn more, with reasons as to why something doesn't work the way you expected it to. You find such reasons on StackOverflow, or atleast that's where I find a lot of explanations :)

Creating is what constitutes better learning.

[1] You can find Joe Amstrong's message on the mailing list http://erlang.org/pipermail/erlang-questions/2011-July/059966.html

Posted
 

"Take your time" - Ronald Jenkees

In the last part of the video, Ronald says.

Take your time with your music!!
It doesn't have to be complicated...
It doesn't have to be perfect...
It just needs to be fun (most of the time)

What he says applies not just to music but to everything else.

Take your time

Anything requires patience. Startups especially take time to mature to a level when they can become profitable. Very few startups or their founders hit the jackpot in the first fortnight.

It doesn't have to be complicated

The ideas for these startups don't come by sitting under the peepal tree. They can be as simple as helping people create form (Wufoo), helping people find indie music (TheSixtyOne) or just a simple game that lets you build what you like (MineCraft).

It doesn't have to be perfect

I don't have to tell you what an MVP is or why most startups insist on an MVP. MVPs are supposed to be half-a-product not half-assed product.

It just needs to be fun or useful.

Yammer might be fun for businesses. Facebook or Google+ maybe fun for people. Salesforce isn't fun. Some businesses just find Salesforce useful and so they pay for it.

Thanks to @kevzettler I found out about Ronald Jenkees and his awesome music.

Posted
 

Time machines would be limited or partially broken

I'm a fan of science fiction, especially fiction that has the possibility of being real tomorrow. One of those topics is time travel. Everybody at some point in their life has wished to go back or forward in life for some purpose, however silly it might have been.

I watched the movie The Time Machine (2002) today and it is based on the book by H.G.Wells and had an interesting thought, that time travel would be partially broken.

If it means that time travel, can take you backward or forward in time, it would be only uptil a limit. The limit would be the life of the time machine.

So if you are in 2011 and want to travel forward in time to 30 years, it would only be possible if 30 years later the time machine would be existing. So for example if the time machine would actually be destroyed or be broken in 2021, then you can travel in the machine upto 20 years and nothing more, because after 20 years, the machine itself would not exist to travel :)

Now consider the other case - travelling backward in time. That cannot be possible at all. Because in the past, the time machine you built just today would not exist at all :) So to travel backwards, the time machine would have to be that old.

Ok now for all this I assume that it requires a machine to do time travel. But if you can time travel using your mind, like Hiro Nakamura of the TV soap Heros, then you might not face this problem.
Posted
 

Center and left positioning in Polycode

I just go started with Polycode with their nicely written docs. There's one thing about positioning tho, which I thought I could explain better. There are two modes to position objects in Polycode - center position mode and left position mode.

If the crossed box is a polycode Entity object, this is what the center positioning and left positoning would look like:

Position_center
Position_left

Now isn't that simple :P

Posted
 

Susam Pal nails it; explains why large services corporations suck

On a topic that has been discussed a lot in recent years, Susam Pal nails it

I've read a lot of blog posts on the culture at large services corporations, and most (including me) share the same view, that they provide a very bad learning environment for curious engineers. Susam differs by pointing out certain things which not many have done and he does it in detail. When I group companies under the label "traditional services corporations", I don't mean the new services startup like C42, whom I've observed, maintain a very nice environment like that of a startup.

About training provided by these organizations, Susam says,

People think that these organizations are good for freshers because they get a lot of training which they wouldn't get in other organizations. I must remind such people that attending trainings is not equivalent to learning.

He then moves on to talk about other stuff on training. But I would love to expand on the above sentences and add my views to it.

I strongly believe that what the new-comers are taught as trainees, is what is useful from the organizations point of view. The training provided at these organizations is only to ensure that the new guys stay productive from the organization's perspective. The trainees aren't taught with the intention that they are to be moulded as good engineers who can think, ask questions and feed their curious self. They are taught to be code monkeys who type out code according the spec provided and don't even bother to know, if the given spec or architecture is right or requires improvement or hell, it's even worse if you don't know the reason why something is being built in a particular way.

A startup-like culture promotes innovative thoughts, which lead to interesting implementations of ideas. That is one reason why a lot of startups who have gone on to become huge corporations, are striving hard to maintain the startup culture even to this day. Wearing formal attire and producing a bunch of clearly typed documents don't mean good software is being produced. These organizations are walled gardens of technical knowledge for avid tinkerers and like Susam says, they promote mud slinging in different forms. Engineer! Build! Create! (and whatever other verbs that are synonymous). Stop treating them as the only places to work at. You can teach a high school kid Java in a month and comfortably push him to such places.

P.S: If you have constructive ctirique or something to add to this topic, you are welcome. Else don't bug me with corporate nonsense. Feel free to rant about me on your blog!

 

Posted
 

the handy bundle-exec

I found myself in a pretty confusing situation today when I was trying out Rails 3.1.rc1. In my Gemfile, I specified Compass to be installed from the github repo and bundler did just that. But I had to run Compass's executable in my rails app and I had no clue as to how to do it, because my rvm gemset for trying the RC version of Rails doesn't have Compass installed in the gem environment. So running the following command, generated a command not found error.

Bundler installs it local to the application, when you choose to install from the git repo, so the executables aren't in your gem path. In such situations, bundle-exec comes handy.

Will run the compass command with it's arguments in the scope of the bundle (I'm referring to the gem dependency environment managed by bundler not to git-bundle).

 

Posted
 

The binding method in ruby

I stumbled upon the binding method in Ruby.

Try Binding.new and it'll throw an error. It seems that the only way you can get an instance of the Binding class is by calling the binding method. I'm sure this method calls the Object.binding method either directly or indirectly. Try Object.binding and i'll say that its a private method.

So what's binding?

binding contains the scope of the current ruby block and allows accessing stuff that would else not be in scope. For example,

And you get a NameError. (I love the errors in Ruby. They are well named and are a pleasure to read.)

Modify the say method to accept an argument. Change the puts to eval a ruby expression and pass the binding as second argument to it. When the binding instance is passed, eval evaluates the expression in the scope of the binding.

Now try passing the scope to the say method and see how msg is accessed by magic

Posted