Skip to content

Instantly share code, notes, and snippets.

View myndzi's full-sized avatar

Kris Reeves myndzi

  • Sigma Bold
  • Olympia, WA
View GitHub Profile
@myndzi
myndzi / gist:2839254
Created May 30, 2012 22:10
(not!) Uncatchable socket errors
var http = require('http'),
net = require('net');
try {
var req = http.request({
host: '127.0.0.1',
port: 18602,
'createConnection':
function (port, host) {
var s = new net.Socket();
Username for 'https://github.com': myndzi
Password for 'https://[email protected]':
Counting objects: 553, done.
Delta compression using up to 16 threads.
fatal: unable to create thread: Resource temporarily unavailable
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
fatal: write error: Bad file descriptor
@myndzi
myndzi / gist:5325367
Created April 6, 2013 08:12
LearnBoost antiscroll modified to compile under closure's advanced mode. Remember to pass it a jQuery externs file.
// ==ClosureCompiler==
// @compilation_level ADVANCED_OPTIMIZATIONS
// @output_file_name default.js
// ==/ClosureCompiler==
// ADD YOUR CODE HERE
(function ($) {
/**
* Augment jQuery prototype.
*/
@myndzi
myndzi / gist:5325369
Created April 6, 2013 08:13
LearnBoost Antiscroll run through Closure Compiler's advanced optimizations
var f=null,k=!1;
(function(b){function l(a,e){this.b=b(a);this.e=e||{};this.g=k!==this.e.x||this.e.forceHorizontal;this.h=k!==this.e.y||this.e.forceVertical;this.i=k!==this.e.autoHide;this.f=void 0==this.e.padding?2:this.e.padding;this.a=this.b.find(".antiscroll-inner");this.a.css({width:"+="+(this.h?g():0),height:"+="+(this.g?g():0)});var d={};this.g&&(d.width="+="+g());this.h&&(d.height="+="+g());this.a.css(d);this.k()}function c(a){this.a=a;this.a.b.append(this.b);this.c=this.a.a.get(0);this.d=this.f=this.e=k;
this.a.b.mouseenter(b.proxy(this,"z"));this.a.b.mouseleave(b.proxy(this,"y"));this.b.mousedown(b.proxy(this,"x"));this.l=b.proxy(this,"u");this.a.a.scroll(this.l);this.k=b.proxy(this,"w");this.a.a.bind("mousewheel",this.k);a=this.a.e.initialDisplay;a!==k&&(this.h(),this.a.i&&(this.g=setTimeout(b.proxy(this,"hide"),parseInt(a,10)||3E3)))}function n(a,e){function d(){}d.prototype=e.prototype;a.prototype=new d}function g(){if(void 0===m){var a=b('<div class="antiscroll-inner" style="width:50px;height:50
@myndzi
myndzi / gist:6101585
Last active December 20, 2015 08:39 — forked from anonymous/gist:6101412
Friend.findOne({
userId: req.signedCookies.userid
}, function (err, signedInUser) {
var friends = signedInUser.friends.map(
function (a) { return { user: a, type: 'friend' }; }
),
sentRequests = signedInUser.request_sent_to.map(
function (a) { return { user: a, type: 'sent' }; }
),
* In 'funcs.js':
module.exports = {
generatePseudoRandomToken: generatePseudoRandomToken,
cookieWatcher: cookieWatcher
};
function generatePseudoRandomToken() {
require('crypto').randomBytes(48, function(ex, buf) {
var token = buf.toString('hex');
});
@myndzi
myndzi / gist:7164515
Last active December 26, 2015 14:19
Pseudo-code implementation of IRC-like flood control
var api = require('socket.io')
, io = null;
var Message = require('./message')
, User = require('./user');
var waitDelay = 1
, linePenalty = 2
, burstThreshold = 10
, numCharsPenalty = 120
#include <v8.h>
#include <node.h>
#include <node_buffer.h>
#include <node_version.h>
#include <unistd.h>
#include <string>
#include <map>
#include <exception>
#include <exiv2/image.hpp>
#include <exiv2/exif.hpp>
function circle(buffer, cx, cy, radius) {
var error = -radius,
x = radius,
y = 0,
lastY;
while (x >= y) {
lastY = y;
error += y;
Setup:
// (actually this is module.exports)
var Prompt = new Blackbird(function (Promise) {
function Prompt(opts, ctx) {
this._opts = opts || { };
// copy over initialization variables
ctx = ctx || { };
for (var key in ctx) {
if (ctx.hasOwnProperty(key)) {