Skip to content

Instantly share code, notes, and snippets.

View devinus's full-sized avatar

Devin Alexander Torres devinus

View GitHub Profile
# Maximum number of file descriptors
kern.maxfiles=65536
# Maximum number of file descriptors per process
kern.maxfilesperproc=32768
# Max number of incoming connections in queue
kern.ipc.somaxconn=512
# Maximum number of processes
Connection.prototype.query = function (sql) {
if (!this._queries) this._queries = [];
var promise = new process.Promise;
promise.sql = sql;
this._queries.push(promise);
this.maybeDispatchQuery();
return promise;
};
[translation:ERROR] Error:
[translation:ERROR] Traceback (most recent call last):
[translation:ERROR] File "translate.py", line 277, in main
[translation:ERROR] drv.proceed(goals)
[translation:ERROR] File "/Users/devin/Projects/pypy/pypy/translator/driver.py", line 744, in proceed
[translation:ERROR] return self._execute(goals, task_skip = self._maybe_skip())
[translation:ERROR] File "/Users/devin/Projects/pypy/pypy/translator/tool/taskengine.py", line 116, in _execute
[translation:ERROR] res = self._do(goal, taskcallable, *args, **kwds)
[translation:ERROR] File "/Users/devin/Projects/pypy/pypy/translator/driver.py", line 279, in _do
[translation:ERROR] res = func()
var LRUCache = {};
LRUCache.Cache = function(maxsize) {
this._keys = [];
this._items = {};
this._expires = {};
this._size = 0;
this._maxsize = maxsize || 1024;
if (this._maxsize < 2) throw Error("max size must be > 2");
};
var LRUCache = {};
LRUCache.Cache = function(maxsize) {
this._keys = [];
this._items = {};
this._expires = {};
this._size = 0;
this._maxsize = maxsize || 1024;
if (this._maxsize < 2) throw new Error("max size must be > 2");
};
var LRUCache = function (maxsize) {
this._keys = [];
this._items = {};
this._expires = {};
this._size = 0;
this._maxsize = maxsize || 1024;
if (this._maxsize < 2) {
throw new Error("max size must be > 2");
}
};
@devinus
devinus / gist:415179
Created May 26, 2010 22:38
Turn CSS rules into inline style attributes using jQuery
(function ($) {
var rules = document.styleSheets[document.styleSheets.length-1].cssRules;
for (var idx = 0, len = rules.length; idx < len; idx++) {
$(rules[idx].selectorText).each(function (i, elem) {
elem.style.cssText += rules[idx].style.cssText;
});
}
$('style').remove();
$('script').remove();
})(jQuery);
@devinus
devinus / gist:450612
Created June 23, 2010 21:49
A Transliterating Erlang URL Slugifier
-module(slugs).
-export([slugify/1]).
-define(tolower(C), (C+32)).
-define(islower(C), (C >= $a andalso C =< $z)).
-define(isupper(C), (C >= $A andalso C =< $Z)).
-define(isdigit(C), (C >= $1 andalso C =< $9)).
-define(isspace(C), (
C =:= $\s orelse C =:= $\n orelse C =:= $\t orelse C =:= $\r
@devinus
devinus / gist:453520
Created June 25, 2010 22:09
A Natural Sorting Comparator for JavaScript's Array.prototype.sort
var NUMBER_GROUPS = /(-?\d*\.?\d+)/g;
var naturalSort = function (a, b) {
var aa = String(a).split(NUMBER_GROUPS),
bb = String(b).split(NUMBER_GROUPS),
min = Math.min(aa.length, bb.length);
for (var i = 0; i < min; i++) {
var x = parseFloat(aa[i]) || aa[i].toLowerCase(),
y = parseFloat(bb[i]) || bb[i].toLowerCase();
<?php
function getPath($target, $path, $default=null) {
if (!$target) return $default;
if (!$path) return $target;
$parts = explode('.', $path);
while (list($idx, $key) = each($parts)) {
if (isset($target->$key)) {
$target = $target->$key;