Installation
gem install rmagick # you'll need ImageMagick & Ruby first
gem install colormath
gem install micro-optparse
license: gpl-3.0 |
for month_table in action*.txt; do | |
echo "$(date) splitting $month_table..." | |
split -l 1000000 $month_table curmonth_ | |
for segment in curmonth_*; do | |
echo "On segment $segment" | |
time mysql -hlocalhost action_credit_silo <<-SQL | |
SET FOREIGN_KEY_CHECKS = 0; | |
SET UNIQUE_CHECKS = 0; | |
SET SESSION tx_iso |
proxy_cache_path /tmp/recipe_cache levels=1:2 keys_zone=RECIPE:64m inactive=3600m max_size=360m; | |
# Yada yada yada... | |
server { | |
# Yada yada yada, more in here... | |
location ^~ /recipes { | |
rewrite ^/recipes\??(.*) /recipes?key={your_private_api_key_here}&$1 break; |
# I created a Post controller to accept a parameter for tag name. | |
# The problem is, the tag "Drupal 6.x", or anything with a period was triggering :format | |
get 'posts/tag/:tag' => 'posts#tag', :format => false, :constraints => {:tag => /.*/} |
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
## based on http://pastie.org/private/bclbdgxzbkb1gs2jfqzehg | |
import sublime | |
import sublime_plugin | |
import subprocess | |
class PromptRunExternalCommand(sublime_plugin.WindowCommand): |
cribbed from http://pastebin.com/xgzeAmBn
Templates to remind you of the options and formatting for the different types of objects you might want to document using YARD.
var soundex = function (s) { | |
var a = s.toLowerCase().split(''), | |
f = a.shift(), | |
r = '', | |
codes = { | |
a: '', e: '', i: '', o: '', u: '', | |
b: 1, f: 1, p: 1, v: 1, | |
c: 2, g: 2, j: 2, k: 2, q: 2, s: 2, x: 2, z: 2, | |
d: 3, t: 3, | |
l: 4, |
def generate_secure_s3_url(s3_key) | |
# | |
# s3_key would be a path (including filename) to the file like: "folder/subfolder/filename.jpg" | |
# but it should NOT contain the bucket name or a leading forward-slash | |
# | |
# this was built using these instructions: | |
# http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?S3_QSAuth.html | |
# http://aws.amazon.com/code/199?_encoding=UTF8&jiveRedirect=1 | |
s3_base_url = MyApp::Application::S3_BASE_URL # i.e. https://mybucket.s3.amazonaws.com |
# Runs a specified shell command in a separate thread. | |
# If it exceeds the given timeout in seconds, kills it. | |
# Returns any output produced by the command (stdout or stderr) as a String. | |
# Uses Kernel.select to wait up to the tick length (in seconds) between | |
# checks on the command's status | |
# | |
# If you've got a cleaner way of doing this, I'd be interested to see it. | |
# If you think you can do it with Ruby's Timeout module, think again. | |
def run_with_timeout(command, timeout, tick) | |
output = '' |