Archive for January, 2012

29
Jan
12

running a single test with rspec


Assuming 31 is the line at which your test starts, do this:

rspec some.spec:31

27
Jan
12

some treetop debug tips


Treetop seems pretty nice, but information on it’s usage is kind of scattered all over internet :). Here are a few tips that I used to debug grammars:

  1. You can try a specific rule by writing this:

    tree = parser.parse(content,:root => "rule_name")
  2. I usually have my code structured like this, to get some info about where the parser chokes:
    
    if tree
        puts "succesful"
    else
        puts "unsuccesful at #{parser.index}"
        puts parser.failure_reason
    end
    

Hope this helps you as much as it helped me.

23
Jan
12

unknown encoding: cp0


If you receive this when deploying django on apache, it’s because you have something like:


print "Something %s" % value

The fix is to change it to:


print "Something %s" % str(value)

17
Jan
12

easy xml parsing in c#

Just a simple usage example:


using System.Xml;
...
XmlDocument doc = new XmlDocument();
// loading a file
doc.Load("file.xml");

// searching for multiple nodes via XPath; this will select all  elements wherever they may be
XmlNodeList books = doc.SelectNodes("//books");

foreach(XmlNode node in books)
{
   // getting attributes; assuming <book Author="Whatever">
   XmlAttribute author = node.Attributes["Author"];
   string value = author.Value;
}

16
Jan
12

current fitness plan


Monday: complexes ( as shown in T-Nation’s screw cardio article )
Tuesday: stationary bike cardio
Wednesday: running
Thursday: pyramid training
Friday:complexes again
Saturday: stationary bike cardio




Blog Stats

  • 215,219 hits