Skip to content

Instantly share code, notes, and snippets.

@acdha
acdha / active_value_filter.py
Created August 31, 2012 20:14
Django admin list_filter which filters out values which are not used in the current queryset
from django.contrib.admin import FieldListFilter
from django.utils.translation import ugettext as _
class ActiveValueFilter(FieldListFilter):
"""list_filter which displays only the values for a field which are in use
This is handy when a large range has been filtered in some way which means
most of the potential values aren't currently in use. This requires a
queryset field or annotation named "item_count" to be present so it can
@alexspeller
alexspeller / source_maps.rb
Created September 16, 2012 00:03
Coffeescript Source Maps in Rails
# config/initializers/source_maps.rb
if Rails.env.development?
require 'open3'
module CoffeeScript
class SourceMapError < StandardError; end;
class << self
def map_dir
@kennethlove
kennethlove / Description.md
Created October 12, 2012 23:47
GSWD Chef needs
  • Install build-essentials, git-core, vim, mercurial
  • Install postgresql-server
  • Edit /etc/postgresql/9.1/main/postegresql.conf
    • Change listen_address to = '*'
  • Edit /etc/postgresql/9.1/main/pg_hba.conf
    • Add new line host all all 10.0.0.0/16 md5
  • Add new postgresql superuser named "vagrant" with password "vagrant"
    • sudo su postgres
    • createuser -s -W vagrant
  • Add postgresql to defaults so it runs at boot
@jbgo
jbgo / debug_system_stack_error.md
Created January 9, 2013 15:08
debug SystemStackError in ruby 1.9

This is how I debug SystemStackError when there is no stack trace.

My first attempt was:

begin
  a_method_that_causes_infinite_recursion_in_a_not_obvious_way
rescue SystemStackError
  puts caller
end
maintainer "YOUR_COMPANY_NAME"
maintainer_email "YOUR_EMAIL"
license "All rights reserved"
description "Installs/Configures pants"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version Time.at(`git --git-dir=#{File.join(File.dirname(__FILE__),'.git')} log --max-count=1 --pretty=format:%ct`.to_i).strftime("1.0.%Y%m%d%H%M")
@ssimeonov
ssimeonov / chef_resource_rake.rb
Created June 18, 2013 22:40
Chef LWRP subclassing example: rake resource subclasses rvm_shell.
class Chef
class ResourceFactory
class Rake
def self.create(*args, &block)
register
Chef::Resource::Rake.new(*args, &block)
end
def self.register
@klass ||= begin
@fnichol
fnichol / README.md
Last active April 27, 2023 15:24
Auto-enable Local HTTP Caching in Test Kitchen

Auto-enable Local HTTP Caching in Test Kitchen

Note: total experiment and hack, looks nasty, could be awesome:

Setup

  • Drop the kitchen.local.yml into $HOME/.kitchen/config.yml
  • Install polipo (with Mac: brew install polipo, with Ubuntu: apt-get install polipo)
  • Drop polipo-start and polipo-console somewhere useful (perhaps $HOME/bin?)
@rgbkrk
rgbkrk / hubdecrypt.sh
Last active April 6, 2022 02:55
Encrypt a (short) file using someone's public key from github
#!/usr/bin/env bash
# HubCrypt
# ========
#
# Decrypt a file encrypted using hubencrypt (ok, it's just openssl + rsautl +
# your SSH keys). It needs the private key that matches your last public key
# listed at github.com/<user>.keys
#
#!/bin/sh
bin_path=/opt/ruby-210/embedded/bin
update-alternatives --install /usr/bin/ruby ruby $bin_path/ruby 10 \
--slave /usr/bin/irb irb $bin_path/irb \
--slave /usr/bin/erb erb $bin_path/erb \
--slave /usr/bin/rdoc rdoc $bin_path/rdoc \
--slave /usr/bin/ri ri $bin_path/ri \
--slave /usr/bin/testrb testrb $bin_path/testrb \
@0xabad1dea
0xabad1dea / singularthey.md
Last active June 18, 2022 18:01
Singular They in Technical English

Guidelines for Singular They in Technical English

by 0xabad1dea, December 2014

This document is an RFC of sorts for increasing the adoption rate of Singular They in technical English. This is not an ultimatum; this is not shaming anyone who has done otherwise; and this is definitely not applicable to any other language.

What is Singular They?