Archive

Posts Tagged ‘Ruby’

bsdiff/bspatch ruby extension

May 24th, 2009

bsdiff and bspatch are great little tools for creating patches of binary files. I used them for the updater in SimoHealth and I believe firefox and chromium use them to deliver application updates. I’m thinking they may be very useful for backups and archiving.   I extracted out the bsdiff and bspatch binaries into an easy to use ruby interface.    For now the ruby interface is exactly the same interface as the command line counterparts meaning all patching and diffing is done via files.  E.g.

bsdiff oldfile newfile patchfile

in ruby would be:

BSDiff.diff('oldfilepath', 'newfilepath', 'patchfilepath')

and patching would be:

bspatch oldfile newfile patchfile

in ruby would be:

BSDiff.patch('oldfilepath', 'newfilepath', 'patchfilepath')

Software , , ,

release a new version of rbtagger

May 21st, 2009

Just released a new version of rbtagger gem. It’s much easier to use as I now include the Brown Corpus and Lexicon in the gem. This means to create the tagger using the default Corpus no arguments are required.

tagger = Brill::Tagger.new
tagger.tag("some body of text")

To install:

gem install rbtagger


				

Software , ,

Character Encoding in Ruby with ActiveSupport

May 18th, 2009

In rails environment the following works:

"àáâãäå".mb_chars.normalize(:kd).gsub(/[^\x00-\x7F]/n,'').downcase.to_s

Outside of rails you might need to wrap your strings explicitly in a ActiveSupport::Multibyte::Chars object. The following for example:

ActiveSupport::Multibyte::Chars.new("àáâãäå").mb_chars.normalize(:kd).gsub(/[^\x00-\x7F]/n,'').downcase.to_s

Software , ,

Typhoeus Another libcurl Ruby binding?

May 7th, 2009

I just saw this today: http://www.pauldix.net/2009/05/breath-fire-over-http-in-ruby-with-typhoeus.html Looks like a really nice library. I really like the libcurl easy bindings it provides.

Software , ,

Accessing process memory usage

April 21st, 2009

Did some googling and figured out it’s not too difficult to get your processes rough memory usage.  Packged things up as a basic ruby extension and now from ruby you can access the process memory usage via:

RMem::Report.memory

It return’s the number of bytes reported as in use by the specific system… In the case of linux reading from the /proc file system and Darwin using the libproc.h.

Check it out here: http://github.com/taf2/rmem/tree/master

Software ,

ANN – Curb 0.3.1 magic multi release

March 19th, 2009

It’s been nearly 8 months, since I decided to add multi interface support to curb.  Now we have a new release on rubyforge (0.3.1)

The major changes includes:

  • Add multi interface support
  • Avoid blocking other ruby threads while in a easy perform
  • Add support for HTTP DELETE Requests
  • Add basic support for HTTP PUT Requests (not from a file)
  • Ruby 1.9.1 Support
  • Upgraded packaging and dependencies for build and package
  • Upgraded test harness to run stressing the libcurl http code base
  • Incorporated 8 months of testing and development through github contributors

Read more…

Software ,

working with processes and ruby

December 5th, 2008

Some code for working with processes using ruby.


# get status from child process before daemonizing
rd, wr = IO.pipe
fork do
  rd.close
  fork do
    wr.write "hello"
    wr.close
    sleep 10
  end
  wr.close
end
wr.close
puts rd.read

# run a command and get exit status and command output
rd, wr = IO.pipe
pid = fork do
  $stdout.reopen wr
  $stderr.reopen wr
  $stdin.reopen rd
  exec '/opt/local/bin/ls -l'
end
wr.close

pid, status = Process.wait2(pid)
puts rd.read
puts status.inspect

Pretty easy in ruby.

Software