Skip to content

Instantly share code, notes, and snippets.

View afeld's full-sized avatar

Aidan Feldman afeld

View GitHub Profile
@afeld
afeld / gist:907334aaa586d885a12b
Created November 5, 2014 16:46
zero-length response in Node
var http = require('http');
var server = http.createServer(function (request, response) {
response.setHeader('content-length', 0);
response.end();
});
server.listen(8000, function() {
console.log("Server running at http://127.0.0.1:8000/");
@afeld
afeld / gist:017862706282c10edb6e
Last active August 29, 2015 14:11
list contributors to a Git repository
require 'rugged'
repo = Rugged::Repository.new('.')
walker = Rugged::Walker.new(repo)
walker.push('refs/heads/gh-pages')
emails = walker.map do |commit|
commit.author[:email]
end
@afeld
afeld / contributions.rb
Last active August 29, 2015 14:20
GitHub org outside contribution stats
# goals:
#
# * find how frequently others contributed (issues or whatever)
# * how many contributors there are
#
# relevant links:
#
# * https://gist.github.com/afeld/017862706282c10edb6e
# * http://octoboard.com/
# * http://bitergia.com/index.html
@afeld
afeld / 18fers.rb
Last active September 14, 2015 16:43
list 18F team members
require 'octokit'
Octokit.auto_paginate = true
client = Octokit::Client.new(access_token: ENV['GITHUB_TOKEN'])
teams = client.organization_teams('18F')
team = teams.find{|team| team.slug.downcase == '18f' }
members = client.team_members(team.id)
members.each do |member|
puts member.login
end
@afeld
afeld / ride4ruby.rb
Created January 12, 2011 02:52
solution for Ride4Ruby
# Ride4Ruby solution by Aidan Feldman
# aidan.feldman@gmail.com
# contest: http://www.engineyard.com/blog/2011/january-contest-ride4ruby/
# 1/11/10
require 'rubygems'
require 'rest_client'
require 'active_support'
require 'active_support/core_ext'
@afeld
afeld / countries.rb
Created February 7, 2011 18:54
A nested array of country names with their ISO country codes, useful for select fields in Rails
# this is useful inside of an initializer
COUNTRIES = [
["United States", "US"],
["Afghanistan", "AF"],
["Albania", "AL"],
["Algeria", "DZ"],
["American Samoa", "AS"],
["Andorra", "AD"],
["Angola", "AO"],
@afeld
afeld / jquery-clearinput_empty_submit.js
Created March 16, 2011 21:05
when the form is submitted, the form should submit empty values for the input elements with empty values
// note: this is not tested, but gives you the idea :-)
// for a normal html form:
$('form').submit(function(){
$(this).find('input.clear-input').each(function(i, elt){
// for each clear-input field
if ($(elt).val() === $(elt).initialValue()) {
// value has not changed
// empty the value
$(elt).val('');
@afeld
afeld / soloistrc
Created October 26, 2011 05:08
dev machine setup with pivotal_workstation and soloist
# Using soloist to set up a new Lion machine
# http://pivotallabs.com/users/cunnie/blog/articles/1872-got-lion-now-get-everything-else-
cookbook_paths:
- ./workspace
recipes:
- pivotal_workstation::bash_profile-git_completion
- pivotal_workstation::bash_profile-ps1
- pivotal_workstation::dropbox
- pivotal_workstation::firefox
@afeld
afeld / 01.rb
Created November 14, 2011 03:33
99 bottles using PDD
# sing "99 bottles of beer on the wall..."
# sing "98 bottles of beer on the wall..."
# ...keep counting down...
@afeld
afeld / encapsulate.js
Created November 17, 2011 18:40
code to encapsulate CSS with a class name
/**
* Encapsulates the css for a given bit. Prepends the bit name as an ancestor selector,
* as well as a "self" selector for each element and class selector found in a sheet.<br><br>
*
* For example, given a bit with name "myBit", the sheet:
* <pre><code>
.myClass { color: blue; }
.myOtherClass { color: red; }
* </pre></code>
* would be converted to: