Skip to content

Instantly share code, notes, and snippets.

@passcod
passcod / extend.js
Last active December 21, 2015 17:29
JavaScript version of https://gist.github.com/passcod/6340716, compiled and then made prettier by hand.
Namespace.extend = function(src, obj) {
if (obj == null) {
obj = {};
}
var newObj;
if (typeof obj.init === 'function') {
newObj = obj.init;
delete obj.init;
} else {
@passcod
passcod / extend.coffee
Last active December 21, 2015 17:29
This is really normal prototypal inheritance, and the #extend and #create methods are just there for convenience, not to hide away the magic.
Namespace.extend = (src, obj = {}) ->
if typeof obj.init is 'function'
newObj = obj.init
delete obj.init
else
newObj = ->
newObj.prototype = Object.create src.prototype
newObj.prototype.constructor = newObj
for prop of obj
@passcod
passcod / gist:6338870
Created August 26, 2013 07:33
WTFUUUUUUUUCK
Object.keys(Ao).forEach (prop) ->
v = Ao[prop] #=> correct value
p = Object.getOwnPropertyDescriptor(Ao, prop) #=> correct descriptor
p.value = v #<- does FUCKING SHIT ALL
console.log JSON.stringify p #=> returns descriptor ONLY
props[prop] = p
@passcod
passcod / libwww.diff
Last active December 21, 2015 14:09 — forked from anonymous/-
Patches for LineMode (see http://cern.ch/first-website)
diff --git a/Library/src/Makefile.am b/Library/src/Makefile.am
index be1857d..5139eca 100644
--- a/Library/src/Makefile.am
+++ b/Library/src/Makefile.am
@@ -405,7 +405,6 @@ BUILT_SOURCES = \
HTAtom.h \
HTBInit.h \
HTBTree.h \
- HTBind.h \
HTBind.h \
registerNewUser: ->
@session.flush().then (models)=>
newUser = @get('content')
@transitionToRoute('user', newUser)
, (response)->
console.log response
@passcod
passcod / hookz.rb
Created August 15, 2013 04:10 — forked from anonymous/hookz.rb
Hookz: Lolcommits plugin to execute custom hooks. Place an executable (shell script, binary, something else with a shebang...) in ~/.lolcommits/project-name/Hookfile, and it will be called every time a commit picture is taken, with its path as argument. Use for anything you can't be bothered writing Ruby for: posting to tumblr, sending email, up…
module Lolcommits
class Hookz < Plugin
def initialize(runner)
super
self.name = 'hookz'
self.default = true
end
def run
@passcod
passcod / gist:6096628
Last active December 20, 2015 07:49 — forked from anonymous/gist:6096625
exports.user = function (req, res) {
User.findById(req.params.id, function (err, user) {
if (err) {
res.send(err);
} else {
Friend.findOne({
userId: req.signedCookies.userid
}, function (err, user2) {
console.log('hit1');
console.log(user2);
@passcod
passcod / deb2targz-any-data.patch
Last active December 18, 2015 00:29
deb2targz patch from gentoo
Support any/all compression formats for data.tar
--- deb2targz
+++ deb2targz
@@ -47,10 +47,11 @@
($header, $data) = ($data =~ /(.*?)\n(.*)/s);
my($name, $num1, $num2, $num3, $num4, $len) = split /\s+/, $header;
#print "header='$header'\n\tname='$name', len=$len\n";
- if ($name eq "data.tar.gz") {
+ if ($name =~ /^data\.tar(.*)$/) {
# Found it
@passcod
passcod / gist:5554007
Created May 10, 2013 12:06
Totally boosting my ego by including me twice
Total number of files: 16
Total number of lines: 1,411
Total number of commits: 291
+----------------------+-------+---------+-------+---------------------+
| name | loc | commits | files | percent |
+----------------------+-------+---------+-------+---------------------+
| Félix Saparelli | 1,277 | 35 | 16 | 90.5 / 12.0 / 100.0 |
| Tim-Smart | 42 | 13 | 3 | 3.0 / 4.5 / 18.8 |
| rick | 24 | 31 | 2 | 1.7 / 10.7 / 12.5 |
| Charlie McConnell | 14 | 65 | 3 | 1.0 / 22.3 / 18.8 |
@passcod
passcod / tr.js
Last active December 17, 2015 03:58
>>> ''.tr
function (a, b) {
a = a || "aeioubcdfghjklmnpqrstvwxyz";
return this.replace(RegExp("([" + a + "])", "ig"), function (c,d,e) {
e = c.toLowerCase();
d = (b || "iouaenpqrstvwxyzbcdfghjklm")[a.indexOf(e)];
return c==e ? d : d.toUpperCase();
});
}
function(a,b){a=a||"aeioubcdfghjklmnpqrstvwxyz";return this.replace(RegExp("(["+a+"])","ig"),function(c,d,e){e=c.toLowerCase();d=(b||"iouaenpqrstvwxyzbcdfghjklm")[a.indexOf(e)];return c==e?d:d.toUpperCase();});}