Skip to content

Instantly share code, notes, and snippets.

View secretfader's full-sized avatar
🚩
new winds

Nicholas Young secretfader

🚩
new winds
View GitHub Profile
---
db1:
name: originalmachine
type: mysql
db2:
name: bobbyhorton
type: mysql
web1:
name: originalmachine
document_root: drupal
@secretfader
secretfader / gist:3762527
Created September 21, 2012 16:37
Rubinius with Puma
[BUG: requested Object for unknown NativeMethod handle type]
2 ruby 0x000000010f47d8e3 rubinius::bug(char const*) + 67
3 ruby 0x000000010f5ae38b rubinius::GenericArguments::invoke(rubinius::State*, rubinius::NativeMethod*, rubinius::NativeMethodEnvironment*, rubinius::Arguments&) + 1195
4 ruby 0x000000010f5adce2 rubinius::Object* rubinius::NativeMethod::executor_implementation<rubinius::GenericArguments>(rubinius::State*, rubinius::CallFrame*, rubinius::Executable*, rubinius::Module*, rubinius::Arguments&) + 908
5 ruby 0x000000010f4832ed rubinius::InlineCache::empty_cache(rubinius::State*, rubinius::InlineCache*, rubinius::CallFrame*, rubinius::Arguments&) + 629
6 ruby 0x000000010f486a46 rubinius::MachineCode::interpreter(rubinius::State*, rubinius::MachineCode*, rubinius::InterpreterCallFrame*) + 9814
7 ruby 0x000000010f4ef846 rubinius::Object* rubinius::MachineCode::execute_specialized<rubinius::TwoArguments>(rubinius::State*, rubinius::CallFrame*, rubinius::Executable*, rubinius::Module*,
var express = require('express'),
api = express();
var validateVersion = function (matched, def, callback) {
var header = null;
if (typeof def === 'function') {
callback = def;
def = false;
}
return function (req, res, next) {
@secretfader
secretfader / express_view_helper.js
Created December 3, 2011 16:00
Express.js View Helper
var ViewProperty = function(type, formatter) {
this.type = type;
if(typeof(formatter) === 'undefined') {
this.plain = true;
} else {
this.formatter = formatter;
}
};
ViewProperty.prototype.set = function(new_value) {
@secretfader
secretfader / dreaming.md
Created September 15, 2011 22:18
sinatra help

Building big Sinatra apps

I love many things about Sinatra, but it seems to assume that most of the applications built with it will be in a single file. That bugs me, and maybe you can help dispel this notion.

There are a few things I require if I'm to use Sinatra for my daily dev tasks:

An easy way to specify controllers

The resources and match methods in Rails, combined with the standard RESTful method definitions make this easy. While I understand that's not necessarily DRY by some standards, it's certainly better than writing:

@secretfader
secretfader / fib.coffee
Created July 22, 2011 04:06
Python / MRI / REE / Rubinius / JRuby / PHP / Node.js Fib Shootout
fib = (n) ->
if n < 2
return n
else
return fib(n - 1) + fib(n - 2)
i = 0
while i <= 35
console.log 'n = ' + i + ' => ' + fib(i)
@secretfader
secretfader / gist:940921
Created April 25, 2011 18:12
net-http-stack.js
/*
A Custom StreamStack HTTP implementation.
Based off the work by Nathan Rajlich.
(C) 2011 Nicholas Young. All rights reserved.
*/
var inherits = require('util').inherits,
querystring = require('querystring'),
StreamStack = require('stream-stack').StreamStack,
CRLF = '\r\n',
.centerize(@width, @height) {
@backwards_width: (@width - @width * 2);
@backwards_height: (@height - @height * 2);
width: @width;
height: @height;
position: fixed;
top: 50%;
left: 50%;
margin-top: @backwards_height / 2px;
margin-left: @backwards_width / 2px;
@secretfader
secretfader / sox_batch.sh
Created November 11, 2010 20:16
awesomely fast batch audio trimming with sox
for i in *aiff; do sox "$i" "./converted/${i}" trim 20 60 fade 1 60 2; done;
@secretfader
secretfader / rails3-template.rb
Created November 3, 2010 19:02
Rails 3 template with HAML, jQuery, Devise, and Mongoid
# Application Generator Template
# Modifies a Rails app to use Mongoid and Devise
# Usage: rails new app_name -m http://github.com/fortuity/rails3-mongoid-devise/raw/master/template.rb
# More info: http://github.com/fortuity/rails3-mongoid-devise/
# If you are customizing this template, you can use any methods provided by Thor::Actions
# http://rdoc.info/rdoc/wycats/thor/blob/f939a3e8a854616784cac1dcff04ef4f3ee5f7ff/Thor/Actions.html
# and Rails::Generators::Actions
# http://github.com/rails/rails/blob/master/railties/lib/rails/generators/actions.rb