Skip to content

Instantly share code, notes, and snippets.

@pepijndevos
pepijndevos / parsistent_heap.clj
Created January 15, 2011 17:13
A persistent heap implemented in Clojure
(ns persistent-heap)
(defn swap [heap idx idy]
(assoc heap idx (get heap idy) idy (get heap idx)))
(defn children [idx]
(let [idx (inc (* idx 2))
idy (inc idx)]
[idx idy]))
@tcr
tcr / async.coffee
Created July 18, 2011 21:13
Serial/Parallel functions in CoffeeScript
# Asynchronous DSL for CoffeeScript
serial = (f) ->
next = -> arr.shift().apply(null, arguments) if arr.length
arr = (v for k, v of f(next))
next()
null
parallel = (f, after = ->) ->
res = {}; arrc = 0
@nheinrich
nheinrich / gist:1171939
Created August 25, 2011 21:03
Using Sass & Compass in Rails 3.1

app/assets/stylesheets/application.css

/*
  *= require "application/all"
*/

app/assets/stylesheets/application/_all.sass

@bkimble
bkimble / gist:1365005
Last active May 2, 2024 01:27
List local memcached keys using Ruby
#!/usr/bin/env ruby
# List all keys stored in memcache.
# Credit to Graham King at http://www.darkcoding.net/software/memcached-list-all-keys/ for the original article on how to get the data from memcache in the first place.
require 'net/telnet'
headings = %w(id expires bytes cache_key)
rows = []
@Epictetus
Epictetus / heroku_autoscalling.rb
Created November 29, 2011 22:26 — forked from mataki/heroku_autoscalling.rb
Auto scalling dynos on heroku using NewRelic
=begin
Need to install gems heroku, newrelic_rpm
$ gem install heroku newrelic_rpm
Set your apps setting
app_name : heroku's app_name of auto scaling
license_key : NewRelic api key. You can get heroku's NewRelic admin console. "App setting" and "Agent configuration"
execute with cron every minutes
$ ruby ./adjust_dynos_with_newrelic.rb
// ==UserScript==
// @name Show Full Domain on Hacker News posts
// @description Sets full domain on hacker news posts.
// @namespace http://userscripts.org/users/119115
// @include http://news.ycombinator.com/*
// @include https://news.ycombinator.com/*
// @match https://news.ycombinator.com/*
// @match http://news.ycombinator.com/*
// ==/UserScript==
@burke
burke / 0-readme.md
Created January 27, 2012 13:44 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

@JoshuaEstes
JoshuaEstes / 000-Cheat-Sheets.md
Last active May 1, 2024 04:03
Developer Cheat Sheets for bash, git, gpg, irssi, mutt, tmux, and vim. See my dotfiles repository for extra info.
@dpk
dpk / gist:2830988
Created May 29, 2012 21:47
djb2 and djb2a hash functions in Ruby
def djb2 str
hash = 5381
str.each_byte do |b|
hash = (((hash << 5) + hash) + b) % (2 ** 32)
end
hash
end
def djb2a str
@gorenje
gorenje / Gemfile
Created June 8, 2012 11:05 — forked from fairchild/Gemfile
An example sinatra omniauth client app
source :rubygems
gem 'sinatra'
gem 'json'
gem 'omniauth'
gem 'omniauth-oauth2'
gem 'omniauth-github'
gem 'omniauth-facebook'
gem 'omniauth-twitter'
# gem 'omniauth-att', :path => File.expand_path("./../../omniauth-att", __FILE__)