Monday, August 27, 2012

Creating a node in Nokogiri with both an attribute and content

Using Nokogiri's builder is a quick way to generate an HTML page when required.

When creating a Node in ruby there can be a case where you

doc.h4 "Some text" 


<h4>"Some text"</h4>


(Note since text-align has a dash in the middle you will need to use quotes around the key name.)


<h4 text-align="right"/>

So how would you generate:

<h4 text-align="right">"Some Text"</h4>  ???

doc.h4(:'text-align'=>"right") "Some Text"

Results in:

./result2html.rb:73: syntax error, unexpected tSTRING_BEG, expecting '}'
              doc.h4(:'text-align'=>"right") "Some Text"

Reading the documentation turned up the answer:

doc.h4(:'text-align'=>"right") { doc.text "Some Text" }

Wednesday, June 27, 2012

Listing all available classes in ruby

I have to look further into the ObjectSpace module.

But this command lists all the available classes.

ObjectSpace.each_object(Class) {|c| p c}

You could also save all the results to an array, require your new module, call it again and subtract one set from another just to get the new classes from the library (If you're lacking documentation).

Saturday, November 26, 2011

Fix unity after disabling in in Compiz

I thought I'd disable Unity in Compiz after a fresh install of Ubuntu 11.10. Alas, it's so ingrained in the system that it totally borks the UI. To fix this I created a terminal launcher on the desktop (as Ctrl-Alt-T and Alt-F2 didn't work any more) that looked like this:


Then selected the file's properties and set the execute bit to true. Then ran the file. This left me with an open terminal in which I then typed:


This brought back unity and now the computer's back to a functional UI.

Now all I need to do is work out how to disable that damn sidebar that gets in the way more than it help...

Wednesday, November 2, 2011

Download the android source as a zip

Hmmm, the repo script doesn't appear to be working thanks to conflicting variables on the work set up. So to get a zip of the android source I went to and downloaded the latest.

All the other google results were severely outdated.