Skip to content

Instantly share code, notes, and snippets.

@passcod
passcod / delegate.js
Last active December 15, 2015 11:19
Delegated commands for jsBot
// Requires npm packages:
// request and underscore
var _ = require('underscore');
var request = require('request');
module.exports = function Module(bot) {
var delegates = {};
var say = function(client, to, message) {
bot.emit('command_say', client, bot.details.nick, to, message.split(' '));
var require('request');
var processFoo = function(arg) {
// do something
};
request('http://example.com', function(error, body, response) {
processFoo(response);
});
@passcod
passcod / attention
Last active December 15, 2015 23:58
Obfuscated
Google's Closure Compiler
throws up if you give it this.
Just sayin'
@passcod
passcod / dynojs.md
Last active December 16, 2015 04:59
Notes on Dyno.js

Default at 3 workers. (Most processors today on both desktop and mobile are quad-core, => 1 main thread + 3 workers). Spawn them immediately.

An actor is a single function. Prototype additions are not taken into account (not straightforward to serialise). It behaves like a function, but async: arguments you give to the actor are passed through unaltered (but they must comply with the serialisation restrictions).

There's two ways to signify completion and both are bubbled up as events: return something; and this.done(something);. The something argument is

@passcod
passcod / PKGBUILD
Last active December 17, 2015 03:38 — forked from anonymous/PKGBUILD
Fixed mongoose PKGBUILD (project moved to github)
# Contributor: Leslie P. Polzer <polzer@gnu.org>
# Contributor: bender02 at archlinux dot us
# Contributor: Felix Saparelli <me@passcod.name>
pkgname=mongoose
pkgver=3.7
pkgrel=1
pkgdesc="Small and quick-to-use web server; https/php/cgi support"
arch=('i686' 'x86_64')
license=('MIT')
@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();});}
@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 / 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: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 / 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