Skip to content

Instantly share code, notes, and snippets.

@tobym
tobym / gist:105754
Created May 2, 2009 23:58
jQuery PUT and DELETE requests
/* Extend jQuery with functions for PUT and DELETE requests. */
function _ajax_request(url, data, callback, type, method) {
if (jQuery.isFunction(data)) {
callback = data;
data = {};
}
return jQuery.ajax({
type: method,
url: url,
@tobym
tobym / exuberant ctags javascript
Created November 13, 2009 16:47
alternate JavaScript langmap for exuberant ctags
--langdef=js
--langmap=js:.js
--regex-js=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\{/\1/,object/
--regex-js=/([A-Za-z0-9._$()]+)[ \t]*[:=][ \t]*function[ \t]*\(/\1/,function/
--regex-js=/function[ \t]+([A-Za-z0-9._$]+)[ \t]*\(([^)])\)/\1/,function/
--regex-js=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\[/\1/,array/
--regex-js=/([^= ]+)[ \t]*=[ \t]*[^"]'[^']*/\1/,string/
--regex-js=/([^= ]+)[ \t]*=[ \t]*[^']"[^"]*/\1/,string/
@tobym
tobym / insert date and time into vim.vim
Created November 13, 2009 20:29
Insert date and time into vim (in insert mode) by typing 'ddate', 'ttime', or 'ptime'
iab <expr> ddate strftime("%c")
iab <expr> ttime strftime("%H:%M")
iab <expr> ptime strftime("%l:%M %p")
@tobym
tobym / command_line_website_benchmarking.sh
Created November 18, 2009 15:24
Website speed benchmarking with command line
# time how long it takes to load your website 100 times and save it to "non_cached.txt"
for i in {1..100}
do
time (curl http://www.yourwebsite.com > /dev/null 2> /dev/null) 2>> non_cached.txt
done
# Set up caching or whatever performance tweaks you need, then run it again (saving to different file)
for i in {1..100}
do
time (curl http://www.yourwebsite.com > /dev/null 2> /dev/null) 2>> cached.txt
@tobym
tobym / redis_pubsub_demo.rb
Created April 1, 2010 16:50 — forked from pietern/redis_pubsub_demo.rb
Redis PubSub demo with EventMachine (chat service)
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
# - a browser with WebSocket support
#
# Usage:
# ruby redis_pubsub_demo.rb
#
@tobym
tobym / secure_taps.rb
Created June 6, 2010 05:13
Secure and easy database transfers using Taps
# From Scott Wheeler: http://blog.directededge.com/2010/06/05/using-taps-without-running-a-taps-server/
# Tunnels the connections over SSH, initiates a pull from the production side, then kills the Taps server.
# Saved for posterity
#!/usr/bin/env ruby
require 'rubygems'
require 'active_support/secure_random'
require 'net/ssh'
@tobym
tobym / vim_url_regex_syntax_hightlighting.vim
Created September 17, 2010 20:34
Vim-formatted regular expression to match a URL for syntax highlighting
" File: .vim/syntax/rdoc.vim
" RDoc inline links: protocol optional user:pass@ sub/domain .com, .co.uk, etc optional port path/querystring/hash fragment
" ------------ _____________________ --------------------------- ________________________ ----------------- __
syntax match rdocInlineURL /https\?:\/\/\(\w\+\(:\w\+\)\?@\)\?\([A-Za-z][-_0-9A-Za-z]*\.\)\{1,}\(\w\{2,}\.\?\)\{1,}\(:[0-9]\{1,5}\)\?\S*/
HtmlHiLink rdocInlineURL htmlLink
# Convert a UTC date to a EST date, factoring in DST
# GNU time
$ TZ=America/New_York date -d "Sep 19 04:58 UTC"
Sun Sep 19 00:58:00 EDT 2010
# BSD time (equivalent to above)
$ TZ=America/New_York date -j -f "%b %d %R %Z" "Sep 19 04:58 GMT" "+%b %d %R %Z %Y"
Sep 19 00:58 EDT 2010
((fn [s] (print (list s (list (quote quote) s)))) (quote (fn [s] (print (list s (list (quote quote) s))))))
@tobym
tobym / sbt_script.patch
Created October 2, 2010 22:25
patch to fix macports SBT wrapper script
20,26d19
< # Capture any arguments
< QUOTED_ARGS=""
< while [ "$1" != "" ] ; do
< QUOTED_ARGS="$QUOTED_ARGS \"$1\""
< shift
< done
<
33c26
< exec java $JAVA_OPTS -jar "$LAUNCHJAR" $QUOTED_ARGS