Skip to content

Instantly share code, notes, and snippets.

@jdar
jdar / gist:182486
Created September 7, 2009 18:03 — forked from rhynix/gist:182485
map.resources :users, :except=>[:new, :create]
map.resources :users, :only=>[:new,:create], :as => :register
# Creates these routes
users GET /users(.:format) {:controller=>"users", :action=>"index"}
edit_user GET /users/:id/edit(.:format) {:controller=>"users", :action=>"edit"}
user GET /users/:id(.:format) {:controller=>"users", :action=>"show"}
PUT /users/:id(.:format) {:controller=>"users", :action=>"update"}
DELETE /users/:id(.:format) {:controller=>"users", :action=>"destroy"}
POST /register(.:format) {:controller=>"users", :action=>"create"}
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
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
@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")
@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
# in the console ...
def try_to_fail(p)
begin
MyModel.transaction do
p.name = "Eustace"
p.save
5+5
raise Exception
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
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
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")
@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'
#####