Skip to content

Instantly share code, notes, and snippets.

View raine's full-sized avatar

Raine Virta raine

View GitHub Profile
#!/usr/bin/env ruby
#
# NIEC BENCHMARKER:
#
# == Usage
#
# 1. Create a ruby source file containing methods with arbitrary names.
# Those are the methods that will be benchmarked.
# For example, contents of my-benchmarks.rb:
#
@chriseppstein
chriseppstein / dry_inner_content_using_capture.haml
Created May 23, 2011 19:07
This gist shows some approaches for using haml without repeating inner content
- content_for(:inner_content) do
= render :partial => "inner_content"
- if some_condition
%outertag1= yield :inner_content
- else
%outertag2= yield :inner_content
@MSch
MSch / .vimrc
Created July 3, 2011 16:58
JavaScript highlighting inside underscore.js templates for vim
" Add this to the bottom of your ~/.vimrc to enable jst highlighting
au BufNewFile,BufRead *.jst set syntax=jst
@louisremi
louisremi / animLoopX.js
Created July 29, 2011 17:34
Animation loop with requestAnimationFrame
// Cross browser, backward compatible solution
(function( window, Date ) {
// feature testing
var raf = window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.msRequestAnimationFrame ||
window.oRequestAnimationFrame;
window.animLoop = function( render, element ) {
var running, lastFrame = +new Date;
@kagemusha
kagemusha / gist:1569836
Created January 6, 2012 09:20
Dump Heroku Postgres DB and load locally
Get the Heroku db as detailed here:
http://devcenter.heroku.com/articles/pgbackups#exporting_via_a_backup
1. heroku pgbackups:capture
2. heroku pgbackups:url <backup_num> #=>backup_url
- get backup_num with cmd "heroku pgbackups"
3. curl -o latest.dump <backup_url>
Then locally do:
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb latest.dump
@paulirish
paulirish / rAF.js
Last active March 22, 2024 00:00
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@docwhat
docwhat / example1.vim
Created June 22, 2012 15:29
Wrapper function to save your cursor and window positions and your last search.
" Re-indents buffer.
nmap <silent> <Leader>g :call Preserve("normal gg=G")<CR>
" Removes all trailing whitespace in buffer.
nmap <silent> <Leader><space> :call Preserve("%s/\\s\\+$//e")<CR>
@scttnlsn
scttnlsn / README.md
Created July 30, 2012 22:16
Pub/sub with MongoDB and Node.js

Pub/sub with MongoDB and Node.js

Setup:

$ mongo
> use pubsub
> db.createCollection('messages', { capped: true, size: 100000 })
> db.messages.insert({})
#!/bin/bash
set -x verbose #echo on
coffee --bare -c */**.coffee
rsync --delete-excluded \
--exclude '.git*' \
--exclude 'deploy.sh' \
--exclude '*.coffee' \
-va $(pwd) ~/Dropbox/Public