Skip to content

Instantly share code, notes, and snippets.

View jpinnix's full-sized avatar

Jeremy Pinnix jpinnix

View GitHub Profile
#!/usr/bin/env ruby
require 'net/imap'
# Source server connection info.
SOURCE_HOST = 'mail.example.com'
SOURCE_PORT = 143
SOURCE_SSL = false
SOURCE_USER = 'username'
SOURCE_PASS = 'password'
@jpinnix
jpinnix / remove_textile_and_html_helper.rb
Created October 29, 2008 01:13
Remove textile and HTML
def remove_textile_and_html(text)
textilize(text).gsub(/<\/?[^>]*>/, "")
end
class Foo
def bar
"test"
end
end
@jpinnix
jpinnix / .irbrc
Created March 12, 2009 18:37
.irbrc with wirble
# load libraries
require 'rubygems'
require 'wirble'
require 'pp'
alias q exit
# Easily print methods local to an object's class
class Object
def local_methods
class Test::Unit::TestCase
def self.should_have_default_scope(scope_call, find_options = nil)
klass = model_class
matcher = have_default_scope(scope_call).finding(find_options)
should matcher.description do
assert_accepts matcher.in_context(self), klass.new
end
end
end
# Back up your iTunes library to S3
git clone git://github.com/sstephenson/mackerel.git
ruby -rubygems mackerel/examples/itunes_backup.rb amazon-s3://YOUR_ACCESS_KEY_ID:YOUR_SECRET_ACCESS_KEY@s3.amazonaws.com/YOUR_BUCKET_NAME/itunes.mackerel
# Lo-fi client for the Facebook API. E.g.:
#
# fb = FacebookClient.new(:api_key => 'api-key', :secret => 'secret')
# fb.call 'users.getInfo', :session_key => 'session-key', :uids => 'user-id', :fields => 'birthday'
#
class FacebookClient
def initialize(default_params={})
@default_params = default_params.reverse_merge({
:rest_server => 'http://api.new.facebook.com/restserver.php',
:format => 'JSON',
formatted_time_accessor :occurs_at, :occurs_until
@jpinnix
jpinnix / gist:400152
Created May 13, 2010 18:07
jQuery - Make all external links open in new tab/window
// JQuery - Make all external links open in new tab/window
// Mashup of:
// http://travisroberts.tumblr.com/post/595428703/jquery-external-links-open-new-window
// http://snipplr.com/view.php?codeview&id=29949
$(document).ready(function() {
$("a[href*='http://']:not([href*='"+location.hostname+"'])").click( function() {
window.open( $(this).attr('href') );
return false;
});
@jpinnix
jpinnix / Pixelgrazer.taskpapertheme
Created July 8, 2010 17:59
Pixelgrazer TaskPaper Theme
<theme>
<!-- Window Style -->
<color id="foreground" red="1.0" green="0.776" blue="0.427" alpha="1.0" />
<color id="background" red="0.255" green="0.255" blue="0.255" alpha="1.0" />
<window foregroundColorID="foreground" backgroundColorID="background" shouldUseHUDScrollers="no" />
<!-- Text View Style -->
<color id="tag" red="0.800" green="0.471" blue="0.200" alpha="1.0" />
<color id="handle" extendsColorID="foreground" />
<color id="insertionPoint" red="1.0" green="1.0" blue="1.0" alpha="1.0" />