Skip to content

Instantly share code, notes, and snippets.

@dustMason
dustMason / STDERR
Created May 30, 2014 00:17
s3 tar streamer attempt
events.js:72
throw er; // Unhandled 'error' event
^
Error: write after end
at writeAfterEnd (_stream_writable.js:133:12)
at WriteStream.Writable.write (_stream_writable.js:181:5)
at Pack.<anonymous> (/Users/jordan/Code/nuts.com/image-archiver/node_modules/knox-mpu/lib/multipartupload.js:246:28)
at Pack.EventEmitter.emit (events.js:95:17)
at EntryWriter.<anonymous> (/Users/jordan/Code/nuts.com/image-archiver/node_modules/tar/lib/pack.js:191:8)
at EntryWriter.EventEmitter.emit (events.js:95:17)
@dustMason
dustMason / Streamer.js
Created May 30, 2014 06:20
Streamer.js
var knox = require("knox");
var mpu = require("knox-mpu");
var s3lister = require("s3-lister");
var async = require("async");
var fs = require("fs");
var archiver = require("archiver");
var client = knox.createClient({
key: process.env.S3_ACCESS_KEY_ID,
secret: process.env.S3_SECRET_KEY,
@dustMason
dustMason / gulpfile.js
Last active August 29, 2015 14:11
Gulp / Browserify
...
var makeScriptBundler = function(options) {
var cache = {};
// load the cache from disk
if (fs.existsSync(options.cache)) { cache = require(options.cache); }
var mainScriptPackageCache = {};
var bundler = browserify({
entries: options.entries,
extensions: ['.coffee'],
@dustMason
dustMason / knob.scad
Last active August 29, 2015 14:14
OpenSCAD Knobber Jobber Epcot Flavor
knob_radius = 24;
knob();
module knob() {
union() {
difference() {
sphere(r=knob_radius);
translate([0, 0, 0-(knob_radius)]) {
cylinder(r1=knob_radius, r2=knob_radius, h=knob_radius);
@dustMason
dustMason / ajaxOverride.js
Created September 13, 2010 17:50
Custom error handling with jQuery.ajax()
// CUSTOM AJAX FUNCTION FOR STRUCTURED ERROR HANDLING
(function(){
// Store a reference to the original ajax method.
var originalAjaxMethod = jQuery.ajax;
var EF = function(){};
// override the default $.ajax to include special handlers for error and success
// to utilize new custom error box. existing success and error callbacks are
// left intact and given the expected params.
jQuery.ajax = function(options) {
var thisSuccess = (typeof options.success == 'function') ? options.success : EF;
@dustMason
dustMason / Validate.cfc
Created September 20, 2010 19:48
Measurement Parsing and Display in cfscript
<cfcomponent extends="Controller" output="false" hint="A set of functions to interface with the jQuery validator plugin">
<cfscript>
function measurement() {
// gets either params.w, params.d or params.h
// m = params.w OR params.d OR params.h;
if (isDefined("params.w")) { m = params.w; }
if (isDefined("params.d")) { m = params.d; }
if (isDefined("params.h")) { m = params.h; }
var dmp = new diff_match_patch();
var text1 = "your input text source";
var text2 = "your input text destination";
var current_unicode = parseInt('2000',16);
var charmap = {};
var replaceFirstTag = function(str,code) {
var nu = code+1;
@dustMason
dustMason / gist:1252515
Created September 30, 2011 02:34
Fix precompilation DB dependency
namespace :assets do
# Prepend the assets:precompile_prepare task to assets:precompile.
task :precompile => :precompile_prepare
# This task will be called before assets:precompile to optimize the
# compilation, i.e. to prevent any DB calls.
task 'precompile_prepare' do
# Without this assets:precompile will call itself again with this var set.
# This basically speeds things up.
# ENV['RAILS_GROUPS'] = 'assets'
ruby-1.9.2-p180 :061 > Signup.last
Signup Load (0.4ms) SELECT "signups".* FROM "signups" ORDER BY "signups"."token" DESC LIMIT 1
#<Signup:0x0000010a51f5a8> {
:token => "ab377c84",
:email => "email1@example.com",
:referred_by => nil,
:notified => nil,
:user_id => nil,
:created_at => Tue, 01 Nov 2011 13:25:06 PDT -07:00,
:updated_at => Tue, 01 Nov 2011 13:25:06 PDT -07:00,
@dustMason
dustMason / scorekeeper.rb
Created November 22, 2011 12:51
ScoreKeeper.rb : A quick command-line app written in Ruby for keeping score during Gin Rummy games. Run `ruby scorekeeper.rb` to start the game.
module ScoreKeeper
class Player
attr_accessor :name, :scores
def initialize(name)
@name = name
@scores = []
end
def <<(points)
@scores << points