Ignoring local changes with Git

Jan 17th, 2011 | Filed under Git

If you have configuration files or any other files in the local repository that you would like to keep as they are without the danger of adding them by mistake in a commit, you can specify that using the local git exclude file and update-index.

echo path/to/file >> .git/info/exclude
git update-index --assume-unchanged path/to/file

To start tracking changes to the file again, remove it from the exclude list and run:

git update-index --no-assume-unchanged path/to/file

Reading and writing XML in Ruby

Dec 16th, 2010 | Filed under Ruby

The fastest library for XML parsing and building in ruby is libxml-ruby. The library does not use the familiar DOM methods, but it’s pretty easy to use.

First, install the libxml-ruby gem:

gem install libxml-ruby

Parsing an XML string:

require 'xml'
 
xml = '<?xml version="1.0"?><root><child attr="value">text</child></root>'
root = XML::Parser.string(xml).parse.root
child = root.children.find { |node| node.name == "child" }
attr = child["attr"]

Building an XML:

require 'xml'
 
xml = XML::Document.new
root = XML::Node.new("root")
child = XML::Node.new("child", "text")
child["attr"] = "value"
root << child
xml.to_s

Installing Varnish or htop on CentOS

Sep 20th, 2010 | Filed under Linux

I just found out today about EPEL. Extra Packages for Enterprise Linux (EPEL) is a volunteer-based community effort from the Fedora project to create a repository of high-quality add-on packages for Red Hat Enterprise Linux (RHEL) and its compatible spinoffs such as CentOS or Scientific Linux.

For more information, visit the EPEL homepage.

Booting OpenBSD in XenServer

Sep 18th, 2010 | Filed under BSD, OpenBSD

If OpenBSD hangs while trying to boot in a XenServer virtual machine, type the following at the boot prompt:

boot> boot -c
UKC> disable uhci
UKC> quit

Then, after booting, log in as root and type:

# config -e -f /bsd
ukc> disable uhci
ukc> quit