Skip to content

Instantly share code, notes, and snippets.

View kellyredding's full-sized avatar
👍
Awesome.

Kelly Redding kellyredding

👍
Awesome.
View GitHub Profile
@kellyredding
kellyredding / coderay-github.css
Last active August 29, 2015 14:04
A coderay theme that mimicks GitHub syntax highlighting (not perfect, still a work-in-progress, but close...)
/* https://gist.github.com/kellyredding/30ac3bbf4534e00b0c04 */
code,
.CodeRay,
.CodeRay * {
box-sizing: border-box;
}
code,
.CodeRay .code pre {
@kellyredding
kellyredding / pg_reassign.sql
Created December 14, 2012 23:51
Mass-modify owner roles for an entire db in Postgres. I used this when changing a db user an app uses to access its data.
REASSIGN OWNED BY old_role [, ...] TO new_role
@kellyredding
kellyredding / steps.md
Created September 13, 2012 19:57
Moving to rbfu
@kellyredding
kellyredding / concat.rb
Created June 27, 2012 19:11
TIL: this form of Ruby string concatenation
puts 'hello ''there'
# => 'hello there'
puts "Wow! "\
"This is a better way to get long "\
"strings into your code without "\
"violating your style guide that "\
"recommends no line be longer than "\
"80 characters long."
# => "Wow! This is a better way to get long strings into your code without violating your style guide that recommends no line be longer than 80 characters long."
@kellyredding
kellyredding / so_i_dont_forget.rb
Created June 7, 2012 21:00
ruby `ObjectSpace` usage from debugging a memory leak in inbox-sync
# used to make sure old mail items were getting garbage collected
# in the runner loop...
puts "InboxSync objects in memory:
ObjectSpace.each_object(Object) do |x|
if x.class.name.include?('InboxSync')
puts "#<#{x.class}:#{'0x%x' % (x.object_id << 1)}"
end
end
#!/bin/bash
if [ -z $1 ]; then
echo "usage: mkgit project-name project-description"
else
gitdir="/srv/repos/$1.git"
if [ -d $gitdir ]; then
echo "error: the repo '$gitdir' already exists."
else
@kellyredding
kellyredding / run.rb
Created May 16, 2012 17:54
Pull Gmail labels via IMAP using Gmail IMAP extensions
require 'net/imap'
# Net::IMAP raises a parse error exception when fetching attributes it doesn't
# recognize. Here I patch an instance of Net::IMAP's `msg_att` method to
# recognize the Gmail IMAP extended attributes
# Refer to:
# * https://developers.google.com/google-apps/gmail/imap_extensions#access_to_gmail_labels_x-gm-labels
# * http://blog.wojt.eu/post/13496746332/retrieving-gmail-thread-ids-with-ruby
@kellyredding
kellyredding / config.rb
Created December 5, 2011 15:47
Git-style namespaced key-value config file parser
class NamespacedKeyValueConfigFile
# This class parses a git-style config file of key=value configs grouped
# by [namespaces]. Each namespace gets a method that returns a hash of
# the key-value configs for the namespace. So given:
# [thing]
# key1 = val1
# key2 = val2
# [other]