- see https://gist.github.com/machty/5723945 for the latest API (unlikely to change from now on)
- latest Ember build: https://machty.s3.amazonaws.com/ember/ember-async-routing-10.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ "master" = "$(git rev-parse --abbrev-ref HEAD)" ] ; then | |
echo "\033[1;31mYou may not shove master\033[0m" | |
exit 1; | |
fi | |
exec git push --force origin HEAD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -z "$1" ] || [ -z "$2" ] ; then | |
echo "Usage: imsg [address] [message]" | |
else | |
/usr/bin/osascript -e 'tell application "Messages" | |
send "'"$2"'" to buddy "'"$1"'" of service "E:[email protected]" | |
end tell' | |
echo "Sent" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = 1 # one | |
b = a - 1 # zero | |
(b..a).include?(a) #=> true | |
(b..a).include?(a.to_f) #=> true | |
(b..a).include?(0.5) #=> true | |
a = DateTime.now # now | |
b = a - 1 # 24 hours ago | |
(b..a).include?(a) #=> true | |
(b..a).include?(a.to_date) #=> false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import urllib | |
import urllib2 | |
import time | |
""" Nike plus activity log | |
https://developer.nike.com | |
Output: | |
-- May -- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ember.GoogleAnalytics = Ember.Mixin.create({ | |
trackPageView: function() { | |
if(!Ember.isNone(ga)) { | |
Ember.run.next(function() { | |
var loc = window.location, | |
page = loc.hash ? loc.hash.substring(1) : loc.pathname + loc.search; | |
ga('send', 'pageview', page); | |
}); | |
} |
class VotesController < ApplicationController
def create
@vote = Vote.find_or_initialize_by_submitted_by_ip(request.remote_ip)
@vote.update_attributes(params[:vote]) if !@vote.has_user?(session[:user_id])
render json: @vote
end
end
class Vote < ActiveRecord::Base
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'addressable/uri' | |
#Accepts options[:message] and options[:allowed_protocols] | |
class UriValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
uri = parse_uri(value) | |
if !uri | |
record.errors[attribute] << generic_failure_message | |
elsif !allowed_protocols.include?(uri.scheme) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rake-pipeline-web-filters' | |
input "static" do | |
output "static/js/src" | |
#compile handlebars templates into Ember.TEMPLATES | |
match "coffee/templates/**/*.handlebars" do | |
handlebars | |
concat "templates.js" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Use like this (or with <dl>, <ol>, <table>)... | |
<ul> | |
<li> | |
<input type="checkbox" class="check-all" /> | |
</li> | |
<li> | |
<input type="checkbox" /> | |
</li> |