Skip to content

Instantly share code, notes, and snippets.

@wingrunr21
wingrunr21 / catchall.coffee
Created October 23, 2013 13:27
A simple catchall script for Hubot to process anything it doesn't know how to handle via Wolfram|Alpha
Wolfram = require('wolfram-alpha').createClient(process.env.HUBOT_WOLFRAM_APPID)
module.exports = (robot) ->
robot.catchAll (msg) ->
r = new RegExp "^(?:#{robot.alias}|#{robot.name}) (.*)", "i"
matches = msg.message.text.match(r)
if matches != null && matches.length > 1
Wolfram.query matches[1], (e, result) ->
if result and result.length > 0
msg.send result[1]['subpods'][0]['text']
@wingrunr21
wingrunr21 / osx_compat.rb
Created October 11, 2013 22:52
A simple utility module we used to detect the version of OS X currently running in order to work around the oracle-instant-client segfault problem.
module OSXCompat
OSX_REGEX = /darwin\d{2}/
SNOW_KITTY = "darwin10"
class << self
def snow_kitty_or_lower?
if darwin?
osx_version <= SNOW_KITTY
else
@wingrunr21
wingrunr21 / config.rb
Created June 13, 2013 15:31
RBX 2.0.0-dev compile problem on 12.10 with MRI build ruby
module Rubinius
# Make this reload friendly without silly constant defined warnings.
BUILD_CONFIG = {
:command_line => "--prefix=/opt/rbenv/versions/rbx-2.0.0-dev --gemsdir=/opt/rbenv/versions/rbx-2.0.0-dev",
:which_ruby => :ruby,
:build_ruby => "/usr/bin/ruby1.9.1",
:build_rake => "rake",
:build_perl => "perl",
:llvm => :prebuilt,
:llvm_configure => "/tmp/ruby-build.20130613152938.5290/rubinius-2.0.0-dev/vendor/llvm/Release/bin/llvm-config",
@wingrunr21
wingrunr21 / config.rb
Created June 13, 2013 15:28
RBX 2.0.0-dev compile problem on 12.10
module Rubinius
# Make this reload friendly without silly constant defined warnings.
BUILD_CONFIG = {
:command_line => "--prefix=/opt/rbenv/versions/rbx-2.0.0-dev --gemsdir=/opt/rbenv/versions/rbx-2.0.0-dev",
:which_ruby => :rbx,
:build_ruby => "/opt/rbenv/versions/rbx-2.0.0-dev/bin/rbx",
:build_rake => "rake",
:build_perl => "perl",
:llvm => :prebuilt,
:llvm_configure => "/tmp/ruby-build.20130613144949.24356/rubinius-2.0.0-dev/vendor/llvm/Release/bin/llvm-config",
@wingrunr21
wingrunr21 / output.txt
Created March 7, 2013 21:15
her does not pass query parameters when doing relation lookups
2013-03-07 14:14:35] INFO WEBrick 1.3.1
[2013-03-07 14:14:35] INFO ruby 1.9.3 (2013-01-15) [x86_64-darwin12.3.0]
[2013-03-07 14:14:35] INFO WEBrick::HTTPServer#start: pid=54326 port=3000
her version: 0.4.1
localhost - - [07/Mar/2013:14:14:35 MST] "GET /users/1?foobar=true HTTP/1.1" 200 10
- -> /users/1?foobar=true
localhost - - [07/Mar/2013:14:14:35 MST] "GET /users/1/projects HTTP/1.1" 200 10
- -> /users/1/projects
[2013-03-07 14:14:35] INFO going to shutdown ...
@wingrunr21
wingrunr21 / postal_code_lookup.rb
Created January 4, 2013 23:55
A quick module for doing postal code lookups from the geonames.org JSON API.
require 'multi_json'
module PostalCodeLookup
GEONAMES_URL = 'http://api.geonames.org/postalCodeSearchJSON'
def self.find_postal_code_data(code)
info = nil
begin
client = HTTPClient.new
@wingrunr21
wingrunr21 / airbrake.rb
Created November 26, 2012 21:11
Airbrake environment by hostname
Airbrake.configure do |config|
# ...
if Rails.env.staging?
config.environment_name = `hostname -f`.strip
end
# ...
end
@wingrunr21
wingrunr21 / postbox_gpu_fix.sh
Created November 5, 2012 22:42
Bash script to update the Postbox Info.plist file to support automatic GPU switching
#!/bin/bash
info=/Applications/Postbox.app/Contents/Info.plist
backup=$info.backup
if [[ $1 == "restore" ]]; then
cp $backup $info
exit
fi
@wingrunr21
wingrunr21 / backtrace.txt
Created September 27, 2012 17:13
Backtrace for factory_girl issue #440
undefined method `name' for "":String
@ vendor/bundle/ruby/1.9.1/gems/factory_girl-4.1.0/lib/factory_girl/declaration/implicit.rb:11:in `=='
vendor/bundle/ruby/1.9.1/gems/activerecord-oracle_enhanced-adapter-1.4.1/lib/active_record/connection_adapters/oracle_enhanced_dirty.rb:20:in `field_changed?'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.17/lib/active_record/attribute_methods/dirty.rb:57:in `write_attribute'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.17/lib/active_record/attribute_methods/write.rb:14:in `product_id='
vendor/bundle/ruby/1.9.1/gems/factory_girl-4.1.0/lib/factory_girl/attribute_assigner.rb:16:in `block (2 levels) in object'
vendor/bundle/ruby/1.9.1/gems/factory_girl-4.1.0/lib/factory_girl/attribute_assigner.rb:15:in `each'
vendor/bundle/ruby/1.9.1/gems/factory_girl-4.1.0/lib/factory_girl/attribute_assigner.rb:15:in `block in object'
vendor/bundle/ruby/1.9.1/gems/factory_girl-4.1.0/lib/factory_girl/attribute_assigner.rb:14:in `tap'
vendor/bundle/ruby/1.9.1/gems/factor
@wingrunr21
wingrunr21 / ceton-1.7.ebuild
Created November 3, 2011 17:22
Ceton 1.7 ebuild
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
EAPI="2"
inherit eutils versionator linux-mod
DESCRIPTION="Ceton InfiniTV Linux Drivers"
HOMEPAGE="http://cetoncorp.com/infinitv_support/linux-drivers/"
SRC_URI="http://cetoncorp.com/downloads/ceton_infinitv_linux_driver_1_7.tar.gz"