Archive for May, 2009

28
May
09

ruby gem creation


To create a ruby gem using the gem tool, you have to create a gem specification file, next to your sources :


specification = Gem::::Specification.new do |s|
	s.name 	= "module_name"
	s.version 	= "0.0.1"
	s.author 	= "geo"
	s.homepage  = "https://ssscripting.wordpress.com"
	s.has_rdoc	= false
	s.files	= ["script_file.rb"]
	s.summary	= "this is your description"
end

If you need a gem dependency, you can add some lines like the following :

s.add_dependency("some_gem",">= x.y")

where some_gem is the name of the gem ( like you would require it,ex: require “hpricot” ) and x and y are version numbers.

I think this is the minimum gem specification that works. To create the gem from the specification & sources, you need to run the gem command :

gem build gem_spec.spec

This will create a .gem file, that can be installed.

To install the gem, you run gem like this :

gem install gem_name.gem

26
May
09

remove line numbers from python


When you copy-paste code from some snippet, you’ll sometimes copy the line numbers as well. So, to remove them, I’ve wrote this script :


import sys
import re

def remove_line_numbers(line):
  components = re.split("\s+",line)
  if(re.search("\d+:?",components[0])):
    return " ".join(components[1:])
  else:
    return line

if __name__ == "__main__":
	file = sys.argv[1]
	fhnd = open(file,"r")
	for line in fhnd:
	  line = remove_line_numbers(line)
	  print line
	fhnd.close()

23
May
09

duran duran – come undone



23
May
09

flypside – happy birthday


A song I love :


23
May
09

another italian song



22
May
09

the deal with visual c++ express 2005

I had to install Visual C++ Express, the 2005 version, in order to take a look at some windows code. The thing is, by default, you can’t write “windows-specific” code with it. It wouldn’t find windows.h.

After some googling, I found out that I needed to install Microsoft Platform SDK … which I did, but then I kept receiving linker error messages like this one :

unresolved external symbol __imp__DestroyWindow@4

Googling some more, I found out the solution for it here. Long story short, you need to modify the corewin_express.vsprops and include the additional libs.

21
May
09

cpan-like site for python


I didn’t know python had something like CPAN. You can find their alternative at pypi.




Blog Stats

  • 221,316 hits