Skip to content

Instantly share code, notes, and snippets.

View mikew's full-sized avatar

mikew mikew

  • 709scene
  • St. John's, Newfoundland
View GitHub Profile
components = {}
addOne = (name, component) ->
components[name] = component
return
addMany = (obj) ->
addOne name, component for own name, component of obj
id title address created_on lat lng notes
1 Academy Canada 167-169 Kenmount Road 2005-12-25 07:27:07 47.555099 -52.766663 Unsecure connection from nearby house
2 Airport Airport Heights 2005-12-25 07:28:26 47.6202811 -52.751712 NULL
3 Chad's House 13 Liverpool Ave 2005-12-25 07:28:45 47.565027 -52.726991 NULL
4 Coffee & Company 204 Water Street 2005-12-25 07:29:08 47.563719 -52.707639 NULL
5 Convergys Customer Management 274 Torbay Road 2005-12-25 07:29:37 47.599109 -52.711220 Unsecure (admin:admin) from a nearby house
6 Credit Union 341 Freshwater Road 2005-12-25 07:30:39 47.561087 -52.746051 NULL
7 Don Cherry's 290 Freshwater Road 2005-12-25 07:31:28 47.563165 -52.741338 NULL
8 Future Shop 20 Stavanger Dr 2005-12-25 07:31:45 47.615481 -52.718738 NULL
9 Hava Java 216 Water Street 2005-12-25 07:32:13 47.564143 -52.707250 NULL
#!/bin/sh
calculate ()
{
local value=$(echo "$*" | bc -q)
echo $value
}
float_conditional ()
{
@mikew
mikew / .bash_profile
Created October 2, 2009 00:58
Helper script to open rails projects
# ...
workon () {
OLDIFS=$IFS
IFS=$'\n'
output=$(workon.rb $1)
for line in $output; do
echo $line
@mikew
mikew / keycode
Created October 2, 2009 01:00
Helper scripts to send applescript key codes from terminal input
#!/bin/sh
osascript - <<EOF
tell application "System Events"
key code $1
end tell
EOF
@mikew
mikew / README
Created October 8, 2009 21:21
Convenience methods for Rails' flashes with I18n support
Given
class Post < ActiveRecord::Base
def to_s; title; end
end
Then
notice :create => :post
# flash[:notice] = I18n.t :"post.create.notice", :scope => [ :flashes ], :post => @post.to_s
class ActionController::TestCase
# setup :mock_warden
teardown :cleanup_warden_env
def warden
@_warden ||= mock
end
def mock_warden_for(*scopes)
scopes.each do |scope|
# shoulda validation that a partial has been rendered by a view
class Test::Unit::TestCase
def self.should_render_partial(partial)
should "render partial #{partial.inspect}" do
# add the underscore. it's expected anyways
assert_template :partial => partial.to_s.sub(/\/(\w+)$/, '/_\1')
end
end
class BooksController < ApplicationController
def index
@books = resources
end
private
def resources
administrator? ? Book.all : Book.published
end
end
class RegistrationsController < ApplicationController
STEP_VALIDATIONS = [
%w(first_name last_name),
%w(billing_address)
]
def new
@user = User.new
end