Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am chad3814 on github.
  • I am chad3814 (https://keybase.io/chad3814) on keybase.
  • I have a public key whose fingerprint is FEC7 4FF5 182D B552 4729 D20D 7886 F7FB F31A D420

To claim this, I am signing this object:

@chad3814
chad3814 / gist:2778491
Created May 23, 2012 23:39
problem with passportjs
passport.use('twitter', new TwitterStrategy({
consumerKey: config.tw_consumer_key,
consumerSecret: config.tw_secret,
callbackURL: config.base_url + '/twitter/callback'
}, function (token, token_secret, profile, done) {
// twitter callback comes here to get the twuser obj
log.info('got twitter profile:', profile);
var TWUser = require('../models/twuser');
// find the twitter obj if it exists
db.findTWUser({providerid: profile.id}, function (err, doc) {
@chad3814
chad3814 / van.js
Created March 18, 2013 23:36
make a directory, put this file in it, npm install socket.io, node van.js
'use strict';
var http = require('http');
var sio = require('socket.io');
var app = http.createServer(function (req, res) {
if (req.url === '/') {
res.writeHead(200, {
'Content-Type': 'text/html'
});
var key_file = fs.readFileSync(path.resolve(__dirname, '..', 'ssl', 'non_ev_domains.key'));
var cert_file = fs.readFileSync(path.resolve(__dirname, '..', 'ssl', 'non_ev_domains.crt'));
var ca_files = [
fs.readFileSync(path.resolve(__dirname, '..', 'ssl', 'COMODORSADomainValidationSecureServerCA.crt')),
fs.readFileSync(path.resolve(__dirname, '..', 'ssl', 'COMODORSAAddTrustCA.crt'))
];
var credentials = {
key: key_file,
cert: cert_file,
ca: ca_files

Keybase proof

I hereby claim:

  • I am chad3814 on github.
  • I am chad3814 (https://keybase.io/chad3814) on keybase.
  • I have a public key ASCCzcAKbW362pseb1Cjk3ZscwaGyBPJPwXemS2N-NN7gQo

To claim this, I am signing this object:

@chad3814
chad3814 / binding.gyp
Created June 19, 2018 00:54
async worker/emitter example
{
"targets": [
{
"target_name": "AsyncEmitter",
"sources": [ "emitter.cc" ],
"include_dirs": [],
"dependencies": [],
"cflags!": [ "-fno-exceptions" ],
"cflags_cc!": [ "-fno-exceptions" ],
@chad3814
chad3814 / StatesColoring.js
Last active August 13, 2018 21:29
States coloring problem
'use strict';
class Color {
constructor (name, multiplier) {
this.name = name;
this.multiplier = multiplier;
}
}
let colors = [
@chad3814
chad3814 / bools.js
Last active October 22, 2021 20:15 — forked from sjl/list-out-of-lambda.js
fixed jslint errors, spacing a bit
'use strict';
var not = function (x) {
if (x) {
return false;
}
return true;
};
var and = function (a, b) {
@chad3814
chad3814 / foo.js
Last active November 23, 2021 03:31
waiting for content to be loaded in jsdom
'use strict';
var path = require('path');
var jsdom = require('jsdom');
var dumpBody = function (document) {
console.log('contents of the document:');
console.log(document.body.innerHTML);
};
@chad3814
chad3814 / listener-pipe.mjs
Last active March 14, 2022 19:29
example node 16 short body closed socket bug
import fs from 'fs';
import http from 'http';
import stream from 'stream';
class CountingStream extends stream.PassThrough {
constructor(options) {
super(options);
this._bytes_in = 0;
this._bytes_out = 0;
}