Skip to content

Instantly share code, notes, and snippets.

@jasonroelofs
jasonroelofs / README.rdoc
Created March 3, 2011 20:16
Code from the now defunkt password_generator project
# THIS is how you hook up mongo mapper to Heroku's MongoHQ plugin.
# Everything else is WRONG or OLD (or both, it happens)
production:
uri: <%= ENV["MONGOHQ_URL"] %>
class Animal
def noise(sound, &block)
block.call(sound)
end
end
class Cow < Animal
def moo(&block)
noise("moo", &block)
end
OIS::ParamList pl;
size_t windowHnd = 0;
std::ostringstream windowHndStr;
mWindow->getCustomAttribute("WINDOW", &windowHnd);
windowHndStr << windowHnd;
pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
mInputManager = OIS::InputManager::createInputSystem( pl );
//http://blog.gmane.org/gmane.comp.compilers.gccxml/month=20081201
//
// The built-ins that are missing and need to be added
#if defined(__MMX__)
/* The real m64 type may vary per-platform. Hopefully this is good enough. */
typedef int __gccxml_m64 __attribute__ ((__vector_size__ (8), __may_alias__));
typedef int __gccxml_v2si __attribute__ ((__vector_size__ (8)));
typedef short __gccxml_v4hi __attribute__ ((__vector_size__ (8)));
typedef char __gccxml_v8qi __attribute__ ((__vector_size__ (8)));
] ruby benchmark/rubinius/pack/bm_SILNQV.rb
Rehearsal --------------------------------------------------
loop 0.010000 0.000000 0.010000 ( 0.007720)
[S].pack('I') 0.070000 0.000000 0.070000 ( 0.077884)
[S].pack('I*') 0.340000 0.000000 0.340000 ( 0.337353)
[M].pack('I*') 0.760000 0.010000 0.770000 ( 0.762425)
[L].pack('S*') 1.460000 0.000000 1.460000 ( 1.466097)
[L].pack('I*') 1.480000 0.000000 1.480000 ( 1.487361)
[L].pack('L*') 1.470000 0.010000 1.480000 ( 1.480759)
[L].pack('N*') 1.490000 0.000000 1.490000 ( 1.488815)
roelofs@Trillian:~/.rvm/src/ruby-1.8.7-p299
] export CFLAGS="-arch i386"
roelofs@Trillian:~/.rvm/src/ruby-1.8.7-p299
] export LDFLAGS="-arch i386"
roelofs@Trillian:~/.rvm/src/ruby-1.8.7-p299
] ./configure --prefix=/Users/roelofs/.rvm/rubies/ruby-1.8.7-p299 --enable-shared
checking build system type... i686-apple-darwin10.4.0
checking host system type... i686-apple-darwin10.4.0
checking target system type... i686-apple-darwin10.4.0
checking for gcc... gcc
In file included from st_test.cpp:1:
st.h:73: error: invalid conversion from ‘int (*)(long int, long int)’ to ‘int (*)()’
st.h:73: error: invalid conversion from ‘int (*)(long int)’ to ‘int (*)()’
st.h:80: error: invalid conversion from ‘int (*)(const char*, const char*)’ to ‘int (*)()’
st.h:80: error: invalid conversion from ‘int (*)(const char*)’ to ‘int (*)()’
st.h:134: error: ‘size’ was not declared in this scope
st.h:135: error: expected ‘,’ or ‘;’ before ‘int’
st.h:136: error: expected unqualified-id before ‘{’ token
# Finds all setter methods for the object,
# builds a new object with these methods set to an arbitrary value,
# checks if the given attrs are able to be mass assigned and all others are not,
# and finally returns true if there are no failures.
#
# (modified from: http://chrisconley.posterous.com/using-rspec-to-test-attraccessible)
Spec::Matchers.define :only_mass_assign_accessible_attributes do |*attrs|
match do |object|
@attrs = attrs
setters = object.methods.map{|m| m if m.match(/[a-z].*\=$/)}.compact
class Parent
def show_my_path(binding)
puts File.expand_path(File.dirname(eval("__FILE__", binding)))
end
end
class App < Parent
end
App.new.show_my_path(binding)