Skip to content

Instantly share code, notes, and snippets.

@hardbap
hardbap / migration.rb
Last active December 20, 2015 20:08
Is this a Rails bug? JRuby bug? jdbcpostgersql bug? This works fine on MRI.
jruby 1.7.4
rails (4.0.0)
jdbc-postgres (9.2.1002.1)
activerecord-jdbc-adapter (1.2.9.1)
activerecord-jdbcpostgresql-adapter (1.2.9)
undefined method `enable_extension' for #<CreatePosts:0x30186092>org/jruby/RubyBasicObject.java:1696
@hardbap
hardbap / routes.rb
Last active December 17, 2015 12:09
resources :sellers, only: [ :index, :show ] do
resources :contracts, shallow: true
end
@hardbap
hardbap / gist:5084073
Created March 4, 2013 17:51
Gems installed by Rails 4
Using rake (10.0.3)
Installing i18n (0.6.4)
Installing minitest (4.6.2)
Installing multi_json (1.6.1)
Installing atomic (1.0.1)
Installing thread_safe (0.1.0)
Installing tzinfo (0.3.36)
Installing activesupport (4.0.0.beta1)
Installing builder (3.1.4)
Installing erubis (2.7.0)
@hardbap
hardbap / chat.rb
Created February 7, 2013 19:07 — forked from rkh/chat.rb
# coding: utf-8
require 'sinatra'
set server: 'thin', connections: []
get '/' do
halt erb(:login) unless params[:user]
erb :chat, locals: { user: params[:user].gsub(/\W/, '') }
end
get '/stream', provides: 'text/event-stream' do
@hardbap
hardbap / readme.md
Created September 20, 2012 13:15
Wall-E readme

Wall·E

Ruby powered robots.

Prerequisites

  1. Download and install the Arduio IDE for your OS
  2. Download and unzip Firmata 2.2
  3. Plug in your Arduino via USB
  4. Open the Arduino IDE, select: File > Open > [Path from step 2] > examples > StandardFirmata
@hardbap
hardbap / observable_example.rb
Created September 18, 2012 14:28
EventSpitter vs. Observable
# We only care about Tick and Alarm events.
# The Alarm event should only be handled once.
# All other events should be ignored.
require 'observer'
class Clock
include Observable
def tick
@hardbap
hardbap / ruby_arduio_meetup.markdown
Created September 16, 2012 12:59
Welcoming our new robot overlords: Arduino programming with Ruby

Prereq

Arduino

What is Arduino?

Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments.

@hardbap
hardbap / routes.rb
Created August 15, 2012 19:27
Sample routes
MyApp::Application.routes.draw do
# we only need index and show
resources :posts, :only => [:index, :show]
# we need everything but destroy
resources :widgets, :except => [:destroy]
end
@hardbap
hardbap / gist:2851226
Created June 1, 2012 11:03
error upgrading 3.2.5
/Users/hardbap/.rvm/gems/ruby-1.9.2-p290@thumb/gems/activesupport-3.2.5/lib/active_support/core_ext/class/attribute.rb:75:in `accessible_attributes': wrong number of arguments (1 for 0) (ArgumentError)
from /Users/hardbap/.rvm/gems/ruby-1.9.2-p290@thumb/gems/actionpack-3.2.5/lib/action_controller/metal/params_wrapper.rb:171:in `_set_wrapper_defaults'
from /Users/hardbap/.rvm/gems/ruby-1.9.2-p290@thumb/gems/actionpack-3.2.5/lib/action_controller/metal/params_wrapper.rb:133:in `inherited'
from /Users/hardbap/.rvm/gems/ruby-1.9.2-p290@thumb/gems/actionpack-3.2.5/lib/abstract_controller/railties/routes_helpers.rb:7:in `block (2 levels) in with'
from /Users/hardbap/.rvm/gems/ruby-1.9.2-p290@thumb/gems/actionpack-3.2.5/lib/action_controller/railties/paths.rb:7:in `block (2 levels) in with'
from /Users/hardbap/code/opinionaided/thumb/app/controllers/pages_controller.rb:1:in `<top (required)>'
from /Users/hardbap/.rvm/gems/ruby-1.9.2-p290@thumb/gems/activesupport-3.2.5/
<!--[if IE]>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<![endif]-->
<!--[if !IE]>-->
<script src="/assets/zepto.min.js?body=1" type="text/javascript"></script>
<!--<![endif]-->