Skip to content

Instantly share code, notes, and snippets.

@jdar
jdar / ruby convenience gems
Created February 25, 2011 13:44
ruby convenience gems: ~/.irbrc
require 'rubygems'
# Gem.use_paths(nil, Gem.paths + [...])
require 'wirble'
require 'bond'
Wirble.init
Wirble.colorize
Bond.start
# other gems might include: 'ap' 'map_by_method'
@jdar
jdar / overriding ruby Test::Unit
Created October 9, 2010 18:05
can't seem to overwrite the run method
require 'curb'
class Test::Unit::TestCase
def run(result)
## CALL TO REMOTE ###
require 'ruby-debug'
debugger
Curl::Easy.http_post('apigen.info') {|g| true }
puts 'do stuff'
#####
require 'rubygems'
# options available by superclassing. See defs/examples below.
class MDS
class << self
def shalphadecimal(number)
case number
when String
require 'digest'
shalphadecimal( Digest::MD5.new << number ).rjust(20,"0")
def coefs_to_parabola(*coefs)
proc, order = coefs.inject([lambda{|x|x},0]) do |(proc,order),coef|
[
Proc.new {|x| coef * x**order + proc.call(x) },
order += 1
]
end
proc
end
As an anonymous user
I want to search to apicomparison.com
So that I can see what steps are necessary to do cross-site API
Scenario 1 - Add new framework is a select drop-down with event observer
Given
I am on the home page
When
I fill "framework_1" select with "Add new framework"
Then
# in the console ...
def try_to_fail(p)
begin
MyModel.transaction do
p.name = "Eustace"
p.save
5+5
raise Exception
end
@jdar
jdar / catches
Created September 17, 2009 16:30
## words/word.py
import pdb
import scriptutil as SU
import re
import psycopg2
from psycopg2.extras import DictCursor
from psycopg2.extensions import adapt
@jdar
jdar / python
Created September 17, 2009 15:35
## words/word.py
import scriptutil as SU
import re
import psycopg2
from psycopg2.extras import DictCursor
from psycopg2.extensions import adapt
try:
db = psycopg2.connect(database="scrabble", user="python", password="python")
I am mapping devices. Led is a light emitting diode. BluetoothDetector is a modular microcontroller that holds the logic and is
I have an ARobject BluetoothDetector which inherits (but is NOT STI) from ArduinoBt.
p = BluetoothDetector.first; p
=> #<BluetoothDetector id: 1, name: "the main controller device">
>> p.children << BluetoothDetector.create(:name=>'slave device')
=> [#<BluetoothDetector id: 45, name: "slave device">]
>> DeviceConnection.first
class AddElectricOpToVehicleModels < ActiveRecord::Migration
def self.up
test = VehicleModel.find(:first)
if test.attributes["electric_percent"] != nil
down
end
add_column :vehicle_models, :electric_percent, :float, :default => 0