Skip to content

Instantly share code, notes, and snippets.

View mikeymckay's full-sized avatar

Mike McKay mikeymckay

View GitHub Profile
<html>
<head>
<script id="form-element-template" type="text/x-handlebars-template">
<td>
<label for='{{id}}'>{{label}}</label>
</td>
<td>
<input {{#options}}data-{{name}}='{{value}}' {{/options}} id='{{id}}' type='{{type}}'></input>
</td>
</script>
<html>
<head>
<script id="form-element-template" type="text/x-handlebars-template">
<td>
<label for='{{id}}'>{{label}}</label>
</td>
<td>
<input {{#options}}data-{{name}}='{{value}}' {{/options}} id='{{id}}' type='{{type}}'></input>
</td>
</script>
<html>
<head>
<script id="form-template" type="text/x-handlebars-template">
{{#formElements}}
<tr>
<td>
<label for='{{id}}'>{{label}}</label>
</td>
<td>
<input {{#options}}data-{{name}}='{{value}}' {{/options}} id='{{id}}' type='{{type}}'></input>
@mikeymckay
mikeymckay / gist:1023706
Created June 13, 2011 21:07
Form renderer
<html>
<head>
<script id="form-template" type="text/x-handlebars-template">
{{#formElements}}
<tr>
<td>
<label for='{{id}}'>{{label}}</label>
</td>
<td>
<input {{options}} id='{{id}}' type='{{type}}'></input>
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'couchrest'
database_uri = "http://mikeymckay.couchone.com/capital-bikeshare"
#database_uri = "http://mikeymckay:cln7qzw.@mikeymckay.cloudant.com/capital-bikeshare"
#database_uri = "http://localhost:5984/test"
current_time = Time.now.to_i
@mikeymckay
mikeymckay / config
Created February 28, 2011 20:50
git config for auto push to gh-pages
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git@github.com:mikeymckay/capital-bikeshare-station-monitor.git
push = +refs/heads/master:refs/heads/master
push = +refs/heads/master:refs/heads/gh-pages
require 'rubygems'
require 'sinatra'
require 'nokogiri'
require 'open-uri'
get '/station/:identifier_type/:identifier' do |identifier_type, identifier|
station = Nokogiri::XML(open('http://www.capitalbikeshare.com/stations/bikeStations.xml')).css("stations station #{identifier_type}:contains('#{identifier}')").first.parent
template_data = {
:header => station.css("name").first.content,
:content => station.children.map{|e|e.name + ": " + e.content}.join("<br/>"),
@mikeymckay
mikeymckay / coffee-script_notifications.sh
Created December 30, 2010 21:39
Use notify-send to get growl like notifications for coffee-script compile errors
#!/bin/bash
while read line; do
echo $line
if [[ "$line" =~ In ]]; then
echo $line
mplayer "/home/crazy/Old Home Folders/crazy/src/GPRS_Easy_Connect_301/data/share/gprsec/sounds/error.wav"
notify-send "$line"
fi
done
@mikeymckay
mikeymckay / hooks.rb
Created October 20, 2010 19:36
cucumber hook to filter current context thru lynx on a content error
After do |scenario|
if scenario.exception and scenario.exception.message.match(/(expected #has_content)|(found)/)
name = File.join(*["/tmp", "capybara-#{Time.new.strftime("%Y%m%d%H%M%S")}.html"].compact)
unless Capybara.save_and_open_page_path.nil? || File.directory?(Capybara.save_and_open_page_path )
FileUtils.mkdir_p(Capybara.save_and_open_page_path)
end
FileUtils.touch(name) unless File.exist?(name)
tempfile = File.new(name,'w')
Then /^lynxdump the page$/ do
name = File.join(*[Capybara.save_and_open_page_path, "capybara-#{Time.new.strftime("%Y%m%d%H%M%S")}.html"].compact)
unless Capybara.save_and_open_page_path.nil? || File.directory?(Capybara.save_and_open_page_path )
FileUtils.mkdir_p(Capybara.save_and_open_page_path)
end
FileUtils.touch(name) unless File.exist?(name)
tempfile = File.new(name,'w')
tempfile.write(body)