Skip to content

Instantly share code, notes, and snippets.

View toolmantim's full-sized avatar
:shipit:
🎉

Tim Lucas toolmantim

:shipit:
🎉
View GitHub Profile
# License
#
# Copyright (c) 2010 Tim Lucas <[email protected]>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// A Javascript version of Allan Odgaard's thousands separator regex
// http://blog.macromates.com/2007/recursion-in-regular-expressions/
123456789.toString().replace(/(\d{1,3})(?=(\d{3})+(?!\d))/g, '$1,');
// => "123,456,789"
# Rackup file for serving up a static site from a "public" directory
#
# Useful for chucking a static site on Heroku
class IndexRewriter
def initialize(app) @app = app end
def call(env)
env["PATH_INFO"].gsub! /\/$/, '/index.html'
@app.call(env)
end
# Simple class for adding a subscriber to a Campaign Monitor list:
#
# See bottom of file for license.
require 'net/http'
require 'uri'
class CampaignMonitorList
def initialize(api_key, list_id)
<!--
A complete and valid HTML5 document, from a code example in:
http://toolmantim.com/thoughts/getting_started_with_node_and_coffeescript
-->
<!DOCTYPE html>
<html lang="en-x-lolcat">
<head>
<title>Teh coffees and nodes</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script src="http://jashkenas.github.com/coffee-script/extras/coffee-script.js"></script>
#!/bin/sh
# Simple deployment script
#
# Requires access to to github repository, as well as a host defined in
# ~/.ssh/config like so:
#
# Host myhost
# User appuser
# Hostname hostname
# In answer to: http://twitter.com/jimwhimpey/status/11727440383
#
# "I want to output 10 Flickr photos one at a time as the REST response
# is returned for each rather than wait for all 10."
class FlickrStreamer
def initialize(photos)
@photos = photos
end
def each
// For today's WTF moment, I present to you:
//
// The wp_get_archives function from WordPress 2.9.2 (the latest)
//
// ...but wait, there's more! The total line count for the file this
// can be found in (general-template.php): 2049 lines.
//
// Save me jeebas!
function wp_get_archives($args = '') {
global $wpdb, $wp_locale;
desc "Boot up the app"
task :default do
exec "ruby -rrubygems myapp.rb -p 4567"
end
desc "Boot up the app with shotgun (uses config.ru)"
task :shotgun do
exec "shotgun -rinit -o 0.0.0.0 -p 4567"
end
# Configure ActionMailer
require 'action_mailer'
ActionMailer::Base.template_root = options.views
ActionMailer::Base.smtp_settings = {
:address => "smtp.sendgrid.net",
:port => "25",
:authentication => :plain,
:user_name => "[email protected]",
:password => "yourpassword"
}