Thursday, December 27, 2012

Quick Twitter Bootstrap review

So lately, I've been trying out Twitter Bootstrap. I came across it while googling for web frameworks. Bootstrap is basically a JavaScript of functionality and a CSS style sheet of design. What this provides is firstly; an easy way to layout your website in rows and columns, and secondly; a ton of interactive elements to add to your site. These elements are Buttons, Dialogs, Panels, Tables, Navbar and much more.

What is really great about bootstrap is that you don't have to write any JavaScript, if you don't want to. Much of the functionality provided is used simply by adding classes to your HTML tags.

An example is when you want to style a link (<a>) to look like a button. All you need to do is this:

<a class="btn btn-primary btn-mini" href="">Hello</a>
the 'btn' class makes your link look like a button, like this:

the 'btn-primary' class dyes the button blue (as default). Other classes exist for other colours. The basic setup is to have Primary, Warning, Info and Danger with their respective colours.


the 'btn-mini' class, as you might have already guessed sets the button to a certain size.


This, for me, is a great tool, as it is really easy to understand, and doesn't take much extra effort than typing raw HTML. Another really great thing is that when following the design practice presented by bootstrap, your website will be compatible with all modern browsers and they will be responsive, meaning your website will look good on tablets and phones as well.

To anyone wanting to put together a great looking website without having to spend hours at end becoming a CSS and JavaScript wizard, I'd recommend having a look at Twitter Bootstrap.

Here is their official http://twitter.github.com/bootstrap/

Friday, December 21, 2012

Clearing a Master Boot Record

I recently had to remove an ubuntu installation and install CentOS instead. The installer complained about “Your boot partition is on a disk using the GPT partitioning scheme but this machine cannot boot using GPT”.

To remedy this, i booted into rescue mode using the CentOS install disc. I clicked through the menu to get a shell and then ran

dd if=/dev/zero of=/dev/sda bs=512 count=1

This removed the Master Boot Record. I then rebooted and started the installer to install CentOS. Upen starting the installer I was greeted by a message:

"/dev/sda contains GPT signatures, indicating that it has a GPT table. [...] Is this a GPT partition table?"

To this I answered no.! This will make the installer ignore the signatures. The next message that I met was:

"The partition table on device sda [...] was unreadable.
To create new partitions it must be initialized, causing the loss of ALL DATA on this drive. [...]
Would you like to initialize this drive, erasing ALL DATA?"

Yes please.!

Now the installer runs as it should :)

Sunday, December 2, 2012

pyGraphviz

After i switched to using a Mac, I have really been missing MS Paint. Not many Apps for Mac can do the same things in the same way. Used to be, I used MS Paint for everything. If I needed a graph of nodes and edges, I used Paint.

When I started studying, I realised that this approach was lacking. Creating large graphs is tedious and when I discover an error, it takes time to correct.

This led me to find the DOT language. A language for representing graphs as text and rendering them with a binary into a .PNG or .SVG or similar. This is a very powerful tool, but I quickly got tired of the syntax. It has a lot of special characters, that I don't normally use, and so; takes time to get used to it.

Luckily, I was able to find a python implementation :)

The first goody is that the syntax is now wrapped in python objects, making me able to be smart with loops and conditions. The other up-side is that the syntax is more readable to me. Below is the example of a graph written in DOT:


digraph {
 graph [rankdir=LR];
 node [shape=circle];
 s0  [shape=doublecircle];
 s0 -> s0  [label="[0,3-9]"];
 s0 -> s1  [label=1];
 s0 -> s2  [label=2];
 s1 -> s0  [label=2];
 s1 -> s1  [label="[0,3-9]"];
 s2 -> s0  [label=1];
 s2 -> s2  [label="[0,3-9]"];
}

And now, in python:

g=pgv.AGraph(strict=False, directed=True, rankdir='LR')
g.node_attr['shape']='circle'

g.add_node('s0', shape="doublecircle")

g.add_edge('s0','s0', label='[0,3-9]')
g.add_edge('s0','s1', label='1')
g.add_edge('s1','s1', label='[0,3-9]')
g.add_edge('s1','s0', label='2')
g.add_edge('s0','s2', label='2')
g.add_edge('s2','s2', label='[0,3-9]')
g.add_edge('s2','s0', label='1')

print g.string()
g.draw(path+'w1-4a.png', prog='dot')

This is a tool I really appreciate. Now I can make logic statements in my graphs and editing them has never been easier.