Skip to content

Instantly share code, notes, and snippets.

View mtodd's full-sized avatar
🔐
[redacted]

Matt Todd mtodd

🔐
[redacted]
View GitHub Profile
BEFORE:
sam@ubuntu discourse % rm -fr tmp/cache
sam@ubuntu discourse % rm -fr public/assets
sam@ubuntu discourse % time RAILS_ENV=production bin/rake assets:precompile
58.55s user 1.79s system 100% cpu 1:00.02 total
AFTER:
@schaary
schaary / ldapsearch.rb
Last active August 29, 2015 13:58
shows an example ldapsearch call with net/ldap gem, when you have the dn of the entry
basedn = "uid=foo,ou=bar,c=baz"
attrs = ["mail", "cn", "sn", "objectclass"]
ldap.search(:base => basedn, :attributes => attrs) do |entry|
puts "DN: #{entry.dn}"
entry.each do |attr, values|
puts "#{attr}:"
values.each do |value|
puts "#{value}"
end
end
#!/bin/bash
DOMAIN=$1; shift
if [ -z "${DOMAIN}" ]; then
echo "No domain specified, assuming github.net"
DOMAIN="github.net"
fi
BASE=$(pwd)
ROOT_CA_KEYSIZE=4096
# Proposal for mapping responses back to requests for Net::LDAP.
require "fiber"
module Net
module LDAP
class Connection
# Hash of Responses keyed by message_id
attr_reader :responses
# Fake socket to read/write from
I've always had a vision of GitHub as a roving pack of feral liquor store patrons,
migrating from section to section, stopping only to grab another bottle of rotgut
whiskey or slaughter an unsuspecting stockboy for food.
Code, I imagine, gets written on aisle 7 (cocktail olives, napkins, and mixers),
on tiny desks made from empty beer cases and wine bottles.
#! /usr/bin/env ruby
status = DATA.flock(File::LOCK_EX | File::LOCK_NB)
if status == 0
puts "we have the lock..."
sleep
else
@jesseproudman
jesseproudman / Github FI Nginx SSL.conf
Created February 10, 2011 06:07
This setup allows you to run Github FI behind an SSL curtain.
worker_processes 1;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
user daemon daemon;
http {
// Based on http://bit.ly/215MBZ
function FailureDetector(ws) {
// ws stands for window size.
// How many heartbeat intervals we keep track of.
this.ws = ws || 100;
this.window = [];
this.last = null;
}
exports.FailureDetector = FailureDetector;
@Janiczek
Janiczek / ProjectEuler.coffee
Created May 31, 2011 21:57
First few Project Euler problems solved in CoffeeScript. Comments on how to make it more beautiful (in terms of CoffeeScript, not algorithm) highly appreciated!
@_1 = ->
# sum of multiples of 3 or 5 (not both) under 1K
answer = 0
for n in [1...1000]
if n % 3 == 0 or n % 5 == 0
answer += n
@blithe
blithe / .zshrc
Last active October 5, 2015 16:03 — forked from burtlo/.zshrc
This is a shortcut to change into my journal directory, create a new article, and then immediately start editing it.
read () {
open "http://blitherocher.com"
}
article () {
# change in to the directory where I keep my journal project
cd /projects/personal_projects/personal_site
echo "Creating article '$@'"