Skip to content

Instantly share code, notes, and snippets.

View vjt's full-sized avatar
💭
looking at the stars

Marcello Barnaba vjt

💭
looking at the stars
View GitHub Profile
# Originally posted on http://pastie.org/25291 (1 December 2006)
# Transmigration between two different database configurations.
# Schema must be already in place. e.g: rake db:schema:load
# Licensed in the Public domain (or the DWTFYW License, at your
# option).
# -vjt@openssl.it
source:
Originally posted on http://pastie.org/pastes/26489 (8 December 2006)
COPY FROM STDIN / LOAD DATA INFILE method for Rails PostgreSQL and MySQL Adapters.
The mysql adapter is completely untested. It is self-explanatory, isn't it? :)
Public domain, or DWTFWYW License, at your option.
-vjt@openssl.it
@vjt
vjt / README.txt
Created January 28, 2009 10:23
A simple class decorator.
A simple class decorator. Useful when implementing some sorts of the evil twin pattern.
It works by creating a blank class slate (with Class.new), removing on it EVERY
method, except `__id__`, `__send__` and `initialize`. It then defines the `class`
method to return the original class, and implements both an `initialize` and a
`method_missing`.
The `initialize` sends the `new` method to the original class, therefore creating
a new instance of the original class and saves it in the @_object instance variable.
# Originally posted on http://pastie.org/pastes/36861 (31 January 2007)
Boolean/Mathematical Expressions Parser, built with the *excellent* Dhaka language
generation library, available on http://dhaka.rubyforge.org/.
Have a look at the extensive test suite for insights on how to use this software,
especially the protected methods in `test/boolean_expression_parser_test.rb`.
The software is licensed under the same terms as Ruby.
class Base
class_inheritable_attribute(:root) { |root| Pathname.new(root).realpath }
end
class A < Base
root '.'
end
>> Base.root
=> nil
#
# Action View hook for .rpdf views, to have them filtered via htmldoc and
# rendered as a PDF file.
#
# Put it in your lib/ directory, save it with a name of your choice, and require
# it in your environment.rb. Sample controller usage is below.
#
# Your view must be an HTML 3.2 file, and you can use the additional HTMLDOC comments.
#
# See <http://www.htmldoc.org/> for more information oh htmldoc, and
#
# Implements the ArrayWithFinders class, that adds
# finders with names similar to ActiveRecord's ones:
#
# * find_by_XYZ -> calls the `XYZ` method on the array items,
# returing the first one on which the method
# didn't return nil/false
# * find_all_by_XYZ -> calls the `XYZ` method on the array items,
# returing all the ones on whose the method
# didn't return nil/false
# Originally posted on http://pastie.org/131174 (21 December 2007)
# Alphanum implementation -- http://www.davekoelle.com/alphanum.html
# (C) 2007 Marcello Barnaba <vjt@openssl.it>
#
# Released under the terms of the Ruby License:
# http://www.ruby-lang.org/en/LICENSE.txt
#
class String
# The algorithm breaks strings into chunks, where a chunk contains either all alphabetic characters,
# or all numeric characters. These chunks are then compared against each other. If both chunks contain
# Originally posted on http://pastie.org/140321 (18 January 2008)
#
## Rbot plugin that interfaces with why's http://tryruby.hobix.com/.
# Based on Kirby 4.2 by Evan Weaver (http://blog.evanweaver.com).
# Implemented for #ruby-it@freenode by Marcello Barnaba (vjt@openssl.it).
# Released under the terms of the Academic Free License (AFL) v. 3.0.
#
# version 0.5, Fri Jan 18 01:57:16 CET 2008 -vjt
#
@vjt
vjt / INSTALL.txt
Created January 28, 2009 12:01
lighthouse-github integration
# Assuming you're on Ubuntu or OSX
#
GIT=$(dirname `which git`)
sudo install -m 755 git-lh.rb $GIT/git-lh
sudo install -m 755 git-lh-push.sh $GIT/git-lh-push