Skip to content

Instantly share code, notes, and snippets.

View bnoguchi's full-sized avatar

Brian Noguchi bnoguchi

View GitHub Profile

Keybase proof

I hereby claim:

  • I am bnoguchi on github.
  • I am bnoguchi (https://keybase.io/bnoguchi) on keybase.
  • I have a public key whose fingerprint is BB2A 8AA0 7790 946A 3382 BB62 E6F3 DD87 0D8D 89D0

To claim this, I am signing this object:

@bnoguchi
bnoguchi / x.coffee
Created May 5, 2012 22:32
phishApi html destructuring
destructure = (s) -> s.split("</a>").map (x) -> title: x[x.lastIndexOf('>')+1..], url: x.match(/href="([^"]+)"/)?[1]
reduceCb = (mem, curr) -> mem[curr[0...curr.indexOf ':']] = destructure curr; mem
dataBySetNumber = json.setlistdata.split(/<span[^>]+>Set /)[1..].reduce reduceCb, {}
// This code doesn't accept a URL of /auth/twitter or /auth/github
var express = require('express')
, routes = require('./routes')
, util = require('util')
, everyauth = require('everyauth');
var app = module.exports = express.createServer();
@bnoguchi
bnoguchi / example.coffee
Created March 11, 2012 20:42
EveryAuth issue #208 (CoffeeScript)
bootstrapAuthentication()
application = express.createServer()
application.configure ->
bootstrap(application)
application.listen(2536)
bootstrapAuthentication = () ->
everyauth.twitter
@bnoguchi
bnoguchi / example.js
Created March 11, 2012 06:10
Example everyauth ajax password response
everyauth.password
.respondToLoginSucceed( function (res, user) {
if (user) { /* Then the login was successful */
res.json({ success: true }, 200);
}
})
.respondToLoginFail( function (req, res, errors, login) {
if (!errors || !errors.length) return;
return res.json({ success: false, errors: errors });
});
@bnoguchi
bnoguchi / conf.js
Created November 28, 2011 00:53
Everyauth GH-113
module.exports = {
fb: {
appId: 'your fb app id',
appSecret: 'your fb app secret'
}
};
@bnoguchi
bnoguchi / gist:1154982
Created August 18, 2011 19:46
findOrCreateUser
findOrCreateUser: function (sess, accessTok, accessTokExtra, fbUser) {
var promise = this.Promise()
, User = this.User()();
if(sess.auth == null || sess.auth.userId == null) {
User.findOne({'fb.id': fbUser.id}, function (err, foundUser) {
if (foundUser) {
if( foundUser.confirmed ) {
return promise.fulfill(foundUser);
} else {
assignFbDataToUser(foundUser, accessTok, accessTokExtra, fbUser);
@bnoguchi
bnoguchi / connect-zip.GH-2.js
Created July 21, 2011 02:32
Gist for connect-zip Issue GH-2
var assert = require('assert'),
express = require('express'),
gzip = require('connect-gzip');
var app = express.createServer();
app.set('view engine', 'jade');
app.use(gzip.gzip());
app.use(express.bodyParser());
@bnoguchi
bnoguchi / mongoose.GH.341.js
Created July 1, 2011 23:52
mongoose GH-341.js - Response to sebm
var mongoose = require('mongoose')
mongoose.connect('mongodb://localhost/sebtest');
var Schema = mongoose.Schema;
var StackItemSchema = new Schema({
blob: Number
});
var StackSchema = new Schema({
@bnoguchi
bnoguchi / GH-386.js
Created June 20, 2011 22:42
Example showing that mongoose GH-386 can't be re-produced
var mongoose = require('mongoose')
, Schema = mongoose.Schema ;
mongoose.connect('mongodb://localhost/test');
var NewsModelSchema = new Schema({
name: String
, title: String
});