This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Compiled Regex | |
Created Default params | |
cost_ins -> 1 | |
cost_del -> 1 | |
cost_subst -> 1 | |
max_cost -> 2147483647 | |
max_ins -> 2147483647 | |
max_del -> 2147483647 | |
max_subst -> 2147483647 | |
max_err -> 2147483647 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REG_EXTENDED = 1 | |
REG_ICASE = (REG_EXTENDED << 1) | |
REG_NOSUB = (REG_ICASE << 1) | |
REG_NEWLINE = (REG_NOSUB << 1) | |
flags = [REG_EXTENDED, REG_NOSUB] | |
p flags.reduce :| | |
# => 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pry' | |
class Object | |
LABELS = [:label1, :label2] | |
def breakpt(label, target=self) | |
LABELS.include?(label) ? Pry.start(target) : nil | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// kind of like ruby openstruct | |
var OpenObject = function () { | |
this.construct = function (defaults, params) { | |
for (var attr in defaults) this[attr] = defaults[attr]; | |
for (var attr in params) this[attr] = params[attr]; | |
}; | |
} | |
var Circle = function (opts) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PQueue | |
def initialize | |
@q = {} | |
end | |
def push(object, priority) | |
values = @q[priority] ||= [] | |
values.push object | |
sync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.all('*', function (req, res, next) { | |
req.setEncoding('utf-8'); | |
req.on('data', function (data) { | |
console.log(data); | |
}); | |
// next(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'formula' | |
class Vim < Formula | |
# Get stable versions from hg repo instead of downloading an increasing | |
# number of separate patches. | |
url 'https://vim.googlecode.com/hg/', :revision => '57e8b75298d6' | |
version '7.3.712' | |
homepage 'http://www.vim.org/' | |
head 'https://vim.googlecode.com/hg/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** WTF MAYNE **/ | |
Admin.User = Backbone.Model.extend({ | |
idAttribute: '_id', | |
setAction: function (action) { | |
this.action = action; | |
}, | |
getAction: function () { | |
if (!this.action) return ''; | |
var action = this.action; | |
this.action = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose'); | |
var db = mongoose.createConnection('localhost', 'test'); | |
var UserSchema = mongoose.Schema({ | |
name: String, | |
phone: Number | |
}); | |
var MemorySchema = mongoose.Schema({ | |
user: { type: Number, ref: 'User' }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A little code from Collective Intelligence translated to javascript | |
*/ | |
var critics = { | |
"Lisa Rose": { | |
"Lady in the Water" : 2.5 | |
, "Snakes on a Plane" : 3.5 | |
, "Just My Luck" : 3.0 | |
, "Superman Returns" : 3.5 |