domenica, aprile 15, 2007

 

Desktop


Desktop
Originally uploaded by paraFLU.


 

Ruby: lista + stampa file ruby nella directory corrente

Elenca tutti i .rb presenti nella directory corrente stampandoli a video


Dir.foreach(".") { |f|
if ( f !~ /^\./ && f !~ /\~$/ && f =~ /\.rb$/)
printf("-- %s --\n",f)
for r in File.new(f,'r').readlines do
printf("%s\n",r.chomp)
end
printf("-- %s --\n\n",f)
end
}

Etichette: , ,


 

Ruby: unit test

Ruby test unit con il modulo 'test/unit'



require 'test/unit'

class TC_MyTest < Test::Unit::TestCase
# def setup
# end

# def teardown
# end

def test_fail
assert(false, 'Assertion was false.')
end
end

Etichette: ,


 

Scrivania


Scrivania
Originally uploaded by paraFLU.
Chiudo con la scrivania nuova dell'ikea WOW finalmente ho sistemato un po' sto casino! Peccato che l'ordine sia durato un paio di giorni

 

C'era una volta


C'era una volta
Originally uploaded by paraFLU.


 

Natale 2006


Natale 2006 015
Originally uploaded by paraFLU.
Era da molto tempo che dovevo postarla :) oggi ho trovato il tempo :D

 

Exerb

Qui si trova uno script ruby per convertire uno script in un eseguibile win32!

 

http://exerb.sourceforge.jp/index.en.html


 

Shell: sostituzione globale su file


#!/bin/sh
find . -name '*.txt' -exec perl -p -i.bak -e 's/old/new/' {} \; -print

Etichette: , ,


 

Shell: Elenco delle maschere in un sorgente

$ egrep “^.MSK” $pgm |sed 's/!MSK=\s*//;s/\s*[|/]\s*/:/'|awk -F: '{printf(%s:%s,,,)}'|sed 's/,$//'

Etichette: , ,


 

Ruby: marshaling via xml

Modulo disponibile all'indirizzo http://clabs.org/clxmlserial.htm



require 'cl/xmlserial'

class MyClass
include XmlSerialization

attr_accessor :attr

def initialize
attr = 0
end
end

doc = REXML::Document.new(File.open("class.xml"))
c = MyClass.from_xml(doc.root)
c.attr = 60
f = File.new("class.xml", File::CREAT|File::TRUNC|File::RDWR)
c.to_xml.write(f, -1)
f.close

Etichette: ,


 

Ruby : file system watcher

require "filesystemwatcher"
watcher = FileSystemWatcher.new()
watcher.addDirectory("/inetpub/ftproot", "*.xml")
watcher.sleepTime = 10
watcher.start { |status,file|
if(status == FileSystemWatcher::CREATED) then
puts "created: #{file}"
elsif(status == FileSystemWatcher::MODIFIED) then
puts "modified: #{file}"
elsif(status == FileSystemWatcher::DELETED then
puts "deleted: #{file}"
end
}

watcher.join() # join to the thread to keep the program alive

Etichette: ,


This page is powered by Blogger. Isn't yours?

Iscriviti a Post [Atom]