Skip to content

Instantly share code, notes, and snippets.

@dre1080
dre1080 / varbinary_migration_columns_initializer.rb
Created August 24, 2012 14:18
Setup varbinary columns or any other unsupported data type in rails migrations
# Provide varbinary columns in a Migration.
# Probably a better way to do this?
#
# Usage:
# => t.varbinary :column, :limit => 20, ....[options]
#
ActiveRecord::ConnectionAdapters::SchemaStatements.module_eval do
def type_to_sql_with_varbinary(type, limit = nil, precision = nil, scale = nil)
return type_to_sql_without_varbinary(type, limit, precision, scale) unless :varbinary == type.to_sym
@dre1080
dre1080 / burp.md
Last active October 6, 2015 22:38
How to code drunk

How to code drunk

Some people born with it, some people are self-taught on this, some people just discover how. How about a guide on how to code great software while still drunk as a cow?

Rules

  • You can add your patterns by forking this gist.
  • You must be drunk before sending a pattern.
@dre1080
dre1080 / watch.sh
Created April 27, 2012 04:57
Compile and watch Sass (using Compass) and CoffeeScript files with one command
#!/bin/bash
type -P compass &>/dev/null || { echo "Compass command not found."; exit 1; }
type -P coffee &>/dev/null || { echo "Coffee command not found."; exit 1; }
# Get current directory (project path)
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SASS_DIR="$DIR/public/stylesheets/sass/"
CSS_DIR="$DIR/public/stylesheets/"
@dre1080
dre1080 / async_iteration.js
Created February 20, 2012 12:03
Everything in node happens at the same time, which means, unless you're doing your processing inside your callbacks, you cannot guarantee asynchronous functions have completed yet.
/**
* Source: http://stackoverflow.com/questions/6287908/nodejs-express-fs-iterating-files-into-array-or-object-failing
*/
var fs = require('fs'),
EventEmitter = require('events').EventEmitter,
filesEmitter = new EventEmitter(),
files = [];
// this event will be called when all files have been added to the files array
@dre1080
dre1080 / gist:988488
Created May 24, 2011 10:27
Simple ini parser
$debug = function($var, $exit = true) {
echo '<pre>';
(is_array($var) || is_object($var)) ? print_r($var) : var_dump($var);
echo '</pre>';
if ($exit)
exit;
};
$parse = function($file, $show_debug = false) use ($debug) {