Skip to content

Instantly share code, notes, and snippets.

View simianarmy's full-sized avatar

Marc Mauger simianarmy

View GitHub Profile
@simianarmy
simianarmy / Questions
Created September 6, 2011 00:17
GOTO Amsterdam
Day job: Web developer
What is your language of choice: Ruby
Open Source contributions: mogli, cocos2d-javascript
How do you use GitHub: Private repos for work projects, public ones for everything else. Used with Capistrano deploys locally & for EngineYard deployment
@simianarmy
simianarmy / rails_xss_gsub_crash
Created October 12, 2011 16:55
rails_xss gsub bug
str = ActiveSupport::SafeBuffer.new "<script>alert</script>"
CGI::unescapeHTML str
=>TypeError: can't dup NilClass
from /Users/marcm/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/cgi.rb:371:in `dup'
UnescapeHTML chokes b/c $1 = nil on line 371:
369 def CGI::unescapeHTML(string)
370 string.gsub(/&(amp|quot|gt|lt|\#[0-9]+|\#x[0-9A-Fa-f]+);/n) do
=> 371 match = $1.dup
@simianarmy
simianarmy / custom-memcached-chef
Created October 18, 2011 00:12
custom memcached Chef recipe
require 'pp'
#
# Cookbook Name:: memcached
# Recipe:: default
#
node[:applications].each do |app_name,data|
user = node[:users].first
case node[:instance_role]
@simianarmy
simianarmy / active_record_extensions.rb
Created November 17, 2011 18:26
Explicitly add tables' engine in schema.rb dump
module ActiveRecord
class SchemaDumper
# Monkeypatch table() to support mixed-engine database schemas by
# making the table engine explicit
def table(table, stream)
columns = @connection.columns(table)
begin
tbl = StringIO.new
@simianarmy
simianarmy / config.json
Created October 2, 2013 00:36 — forked from anonymous/config.json
Cool exploding tile css custom filter from Adobe CSS FilterLab
{
"hasVertex": true,
"hasFragment": true,
"mix": {
"blendMode": "normal",
"compositeOperator": "source-atop"
},
"mesh": {
"columns": 100,
"rows": 100
@simianarmy
simianarmy / walk_2_dirs.sh
Last active August 29, 2015 14:25
Loop semi-recursively through directories for batch shell operations
for d in `ls`; do pushd $d; for l in `ls`; do YOUR_COMMANDS_HERE; done; popd; done;
@simianarmy
simianarmy / findlargefiles.sh
Created August 27, 2015 21:59
Find large files
find / -xdev -type f -size +100M
@simianarmy
simianarmy / findlargedirs.sh
Last active November 5, 2015 17:32
Find large directories
for i in G M K; do du -ah | grep [0-9]$i | sort -nr -k 1; done | head -n 11
@simianarmy
simianarmy / ducks.sh
Created November 5, 2015 17:31
du ducks
du -cks * | sort -rn | head
@simianarmy
simianarmy / gist:9e48fbec2a00f2db353184b29bb6b409
Last active September 5, 2018 19:09
Checkout by partial branch name
/**
* Checkout branch by partial branch name
* If only matches single branch, checks it out automatically.
* If matches multiple branches, displays selection user can pick from
*
* Usage:
* > gcobr JIRA-1432
* > gcobr partial-branch-name
*/
function gcobr {