Skip to content

Instantly share code, notes, and snippets.

@coderanger
coderanger / fuckitencoder.py
Created January 17, 2014 21:21
For when you absolutely, positively must get something that looks like JSON.
MEMORY = '<memory>'
class FuckItEncoder(json.JSONEncoder):
def default(self, obj):
try:
return json.JSONEncoder.default(self, obj)
except RuntimeError:
return '<recur>'
except MemoryError:
return MEMORY
except TypeError:
@coderanger
coderanger / rpm.rb
Last active January 3, 2016 00:08
Modified rpm formula to install the Python bindings too.
require 'formula'
class RpmDownloadStrategy < CurlDownloadStrategy
def initialize name, resource
super
@tarball_name = "#{name}-#{resource.version}.tar.gz"
end
def stage
safe_system "rpm2cpio.pl <#{tarball_path} | cpio -vi #{@tarball_name}"
@coderanger
coderanger / data.txt
Created December 24, 2013 06:57
Rackspace server info
$ knife rackspace flavor list
ID Name VCPUs RAM Disk
2 512MB Standard Instance 1 512 20 GB
3 1GB Standard Instance 1 1024 40 GB
4 2GB Standard Instance 2 2048 80 GB
5 4GB Standard Instance 2 4096 160 GB
6 8GB Standard Instance 4 8192 320 GB
7 15GB Standard Instance 6 15360 620 GB
8 30GB Standard Instance 8 30720 1200 GB
performance1-1 1 GB Performance 1 1024 20 GB
@coderanger
coderanger / README.md
Last active December 31, 2015 04:39
Notes from WiE: Change The Ratio

I was part of a group discussing recruiting and on-boarding of women (and to a lesser degree minorities in general). Some highlights that we settled on :

  1. Include at least one woman on interview panels for women candidates. This helps to make it clear that the company isn't a mono-culture and reduces the "I don't look like anyone here" effect of being a lone woman in a room full of middle-aged white guys (and maybe a woman recruiter, which only exacerbates things). This may not be possible if you currently have no woman engineers, but try.
  2. Be willing to hire junior engineers, both when looking for women and just in general. While it is a bigger risk and requires more upfront investment, you greatly increase your available talent pool.
  3. Have a "buddy system" during on-boarding, and actually train your mentors rather than just throwing them into it. When possible, pair new employees with someone of a similar gender/minority/background to help people know they are not alone in your organization. Some ti
@coderanger
coderanger / eveskill.py
Created September 17, 2013 02:54
Script to format an Eve skill plan for BBCode.
from __future__ import division
import copy
from gettext import ngettext
from bs4 import BeautifulSoup
attributes = {
'intelligence': 20,
'perception': 20,
'charisma': 19,
@coderanger
coderanger / pycon.md
Last active December 23, 2015 00:49
Possible PyCon 2014 talks

1: Application Deployment State of the Onion

An overview of the moving pieces in app deployment currently (ex. chef, puppet, salt, ansible, git, omnibus, compass, less, DB migrations, databases).

Description

Deploying a moderately complex web application has become quite a challenge over the years. As best-practices have evolved, it has become progressively more time-consuming to keep up with what tools exist and how to use them effectively. This talk will provide an overview of the ecosystem and provide pointers for more information about individual components or problems.

Audience

@coderanger
coderanger / gist:6429373
Last active December 22, 2015 06:09 — forked from ewdurbin/gist:6429299
url = require('url')
querystring = require('querystring')
component_name = (organization_id, component_id, cb) ->
http.get"http://#{organization_id}.statuspage.io/index.json", (res) ->
payload = JSON.parse(res.body.payload)
for comp in payload.components
if comp.id == component_id
return cb(comp.name)
@coderanger
coderanger / platforms.yml
Last active December 20, 2015 14:39
EC2 platform configuration for test-kitchen
----
platforms:
- name: ubuntu-12.04
driver_config:
image_id: ami-d726abbe
username: ubuntu
- name: ubuntu-10.04
driver_config:
image_id: ami-1ab3ce73
username: ubuntu
@coderanger
coderanger / holidays.py
Created March 23, 2013 22:49
Find streaks of days that overlap no holidays
# coding=utf-8
import datetime
from dateutil.parser import parse
# From http://www.huffingtonpost.com/2013/01/01/religious-holidays-2013_n_2372650.html
raw_holidays = """
Baha'i Holidays 2013:
Jan 20 - World Religion Day
Mar 2-20 - Baha'i Fast
Mar 20 - Nowruz (Baha'i, Zoroastrian, Iranian New Year)
class Chef
class SubResourceCollection < ResourceCollection
def initialize(parent)
@parent = parent
super()
end
def lookup(resource)
super
rescue Chef::Exceptions::ResourceNotFound