Skip to content

Instantly share code, notes, and snippets.

rvm install rbx-head -- --enable-version=19,18 --default-version=19
rvm use rbx-head
gem install capistrano -v 2.9.0
gem list
overwrite_accessor :date= do |date|
# We want to end up with a Time object with one-day resolution.
# This is the cleanest, most-readable, faster-than-using-Date
# way to do it.
case date
when String then
@date = if /\A(\d{4})-(\d{2})-(\d{2})\Z/ =~ date then
Time.local($1.to_i, $2.to_i, $3.to_i)
else
require 'time'
$ irb
irb(main):001:0> RUBY_VERSION
=> "1.9.2"
irb(main):002:0> Module.constants
=> [:Object, :Module, :Class, :Kernel, :NilClass, :NIL, :Data, :TrueClass, :TRUE, :FalseClass, :FALSE, :Encoding, :Comparable, :Enumerable, :String, :Symbol, :Exception, :SystemExit, :SignalException, :Interrupt, :StandardError, :TypeError, :ArgumentError, :IndexError, :KeyError, :RangeError, :ScriptError, :SyntaxError, :LoadError, :NotImplementedError, :NameError, :NoMethodError, :RuntimeError, :SecurityError, :NoMemoryError, :EncodingError, :SystemCallError, :Errno, :ZeroDivisionError, :FloatDomainError, :Numeric, :Integer, :Fixnum, :Float, :Bignum, :Array, :Hash, :ENV, :Struct, :RegexpError, :Regexp, :MatchData, :Marshal, :Range, :IOError, :EOFError, :IO, :STDIN, :STDOUT, :STDERR, :ARGF, :FileTest, :File, :Dir, :Time, :Random, :Signal, :Process, :Proc, :LocalJumpError, :SystemStackError, :Method, :UnboundMethod, :Binding, :Math, :GC, :ObjectSpace, :Enumerator, :StopIteration, :RubyVM, :Thread, :TOPLEVEL_BINDING, :ThreadGroup,
epall@Everett$ ruby --1.9 -e 'require "mail"'
RegexpError: /.../n has a non escaped non ASCII character in non ASCII-8BIT script
Patterns at /Users/epall/.rvm/gems/jruby-head/gems/mail-2.3.0/lib/mail/patterns.rb:31
Mail at /Users/epall/.rvm/gems/jruby-head/gems/mail-2.3.0/lib/mail/patterns.rb:3
(root) at /Users/epall/.rvm/gems/jruby-head/gems/mail-2.3.0/lib/mail/patterns.rb:2
require at org/jruby/RubyKernel.java:970
require at /Users/epall/.rvm/rubies/jruby-head/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36
Mail at /Users/epall/.rvm/gems/jruby-head/gems/mail-2.3.0/lib/mail/patterns.rb:45
(root) at /Users/epall/.rvm/gems/jruby-head/gems/mail-2.3.0/lib/mail.rb:2
require at org/jruby/RubyKernel.java:970
--------------------
have_library: checking for PQconnectdb() in -lpq... -------------------- no
"gcc -o conftest -I/opt/chef/embedded/include/ruby-1.9.1/x86_64-linux -I/opt/chef/embedded/include/ruby-1.9.1/ruby/backward -I/opt/chef/embedded/include/ruby-1.9.1 -I. -I/opt/chef/embedded/include -I/usr/include/postgresql -L/opt/chef/embedded/lib -I/opt/chef/embedded/include -fPIC conftest.c -L. -L/opt/chef/embedded/lib -Wl,-R/opt/chef/embedded/lib -L/usr/lib/x86_64-linux-gnu -Wl,-R/usr/lib/x86_64-linux-gnu -L/opt/chef/embedded/lib -Wl,-R/opt/chef/embedded/lib -L. -Wl,-rpath /opt/chef/embedded/lib -L/opt/chef/embedded/lib -I/opt/chef/embedded/include -rdynamic -Wl,-export-dynamic -L/usr/lib -Wl,-R -Wl,/opt/chef/embedded/lib -L/opt/chef/embedded/lib -lruby-static -lpq -lpthread -lrt -ldl -lcrypt -lm -lc"
/usr/lib/libpq.so: undefined reference to `SSL_CTX_use_certificate_chain_file@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_write@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference
@epall
epall / jenkins.plist
Created October 4, 2012 22:25
Jenkins slave launch agent
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>jenkins</string>
<key>ProgramArguments</key>
<array>
@epall
epall / hannah-motiondetect.nut
Created October 15, 2012 18:31
Vibration sensor using accelerometer on Hannah
// Vibration sensor using accelerometer on Hannah
//I2C Addresses
const i2c_ioexp = 0x7C;
const i2c_temp = 0x98;
const i2c_als = 0xE8;
const i2c_accel = 0x38;
//----------------------------------------
//-- Configure I2C
@epall
epall / using_async.js
Created October 23, 2012 15:35
example of JavaScript "coroutines" in practice
var async = require('async');
async.waterfall([
Foo.create.bind(Foo, fooId, false),
function(foo, cb) {
Bar.create(barId, '0000000000000001', false, null, utils.randomID(12), cb);
},
function(result, cb) {
Baz.create('baz_'+utils.randomID(4), true, 1, 'hello, world', cb);
},
@epall
epall / server.js
Created November 8, 2012 20:24
graceful restart
var net = require('net')
var child_process = require('child_process')
var number = process.argv.length > 2 ? parseInt(process.argv[2], 10) : 0;
function listen(server) {
server.on('connection', function(socket) {
socket.write('hi from #'+number+'\n');
});
@epall
epall / emma.js
Created November 14, 2012 14:52
Post tweets with a hashtag to an Electric Imp "Emma" board
var twitter = require('node-twitter')
, util = require('util')
, https = require('https')
var twitterClient = new twitter.SearchClient({
consumer_key: '__YOUR_TWITTER_CONSUMER_KEY__',
consumer_secret: '__YOUR_TWITTER_CONSUMER_SECRET__'
});
var lastTweet;