Skip to content

Instantly share code, notes, and snippets.

View kennethkalmer's full-sized avatar

Kenneth Kalmer kennethkalmer

View GitHub Profile
--
-- lena.lua
--
--
-- work queue operations
queue = {}
/*
* a smart poller for jquery.
* (by github)
*
* simple example:
*
* $.smartPoller(function(retry) {
* $.getJSON(url, function(data) {
* if (data) {
* doSomething(data)
@defunkt
defunkt / example.haml.mustache
Created February 12, 2010 22:16
Haml + Mustache
#content
.left.column
%h2 Welcome to our site!
.right.column
#users
{{#users}}
%p {{user}}
{{/users}}
@jlindsey
jlindsey / culerity.js
Created June 3, 2010 16:47
Using Cucumber/Capybara/Culerity, a step to wait until all AJAX calls are complete.
// this allows culerity to wait until all ajax requests have finished
jQuery(function($) {
var original_ajax = $.ajax;
var count_down = function(callback) {
return function() {
try {
if(callback) {
callback.apply(this, arguments);
};
} catch(e) {
@drnic
drnic / github_user_collaborations.rb
Created July 13, 2010 10:30
Discover the contribution status of a user for all their watched repos: owner, collaborator, or watcher
#!/usr/bin/env ruby
#
# Discover the contribution status of a user for all their watched repos: owner, collaborator, or watcher
# Returns either JSON (default) or HTML (example http://github-user-profiles-example.heroku.com/)
#
# JSON: Returns either Array of JSON; or streams each JSON result as discovered (--stream flag)
# { "repo" => { ... }, "owner" => is project owner?, "collaborator" => has collaborator access? }
#
# HTML: Sort-of pretty HTML output. Nice to use --stream | bcat.
#
I make this beer a couple times a year, and it is usually gone quickly. It is probably my favorite beer.
8 pounds light malt extract syrup
3 pounds raw, natural honey
1 pound Crystal 40 grain
2 oz Fuggles hops
2 Edinburgh Ale yeast
Typical extract procedure:
@lusis
lusis / iam-s3-policy.json
Created January 5, 2011 10:32
A sample AWS IAM json policy file with read-only access to certain S3 buckets
{
"Statement":[{
"Effect":"Allow",
"Action":["s3:ListBucket","s3:GetObject","s3:GetObjectVersion"],
"Resource":["arn:aws:s3:::my_bucket/*","arn:aws:s3:::my_bucket"]
}
],
"Statement":[{
"Effect":"Allow",
"Action":["s3:ListBucket","s3:GetObject","s3:GetObjectVersion"],
body = MultipartBody.new(:field1 => 'test', :field2 => 'test2')
http = EventMachine::HttpRequest.new('http://example.com').post(
:head => {'content-type' => "multipart/form-data; boundary=#{body.boundary}"},
:body => body.to_s
)
# Or with a file part included
part1 = Part.new('name', 'content', 'file.txt')
@redsquirrel
redsquirrel / gist:882117
Created March 22, 2011 21:28
It's annoying that this is valid Ruby and prints "hi mom"
if false
elsif
print "hi "
else
puts "mom"
end
@mislav
mislav / gist:938183
Created April 23, 2011 02:28
Faraday SSL example
connection = Faraday::Connection.new('http://example.com') do |builder|
builder.request :url_encoded # for POST/PUT params
builder.adapter :net_http
end
# same as above, short form:
connection = Faraday.new 'http://example.com'
# GET
connection.get '/posts'