Skip to content

Instantly share code, notes, and snippets.

💭
Available for JS/Node contract work

Jonathon Kresner jkresner

💭
Available for JS/Node contract work
  • airpair, inc.
  • San Francisco
Block or report user

Report or block jkresner

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View civilians.js
var operation = {
'Imperial shuttle': 5,
'Theta-class T-2c shuttle': 10,
'Sentinel-class landing craft': 2
};
// How many civilians can be transported in an emergency escape operation?
var civilians = 0;
for (var startship of starships)
if (starship.name in operation)
View datepicker.html
<div class="dropdown">
<a id="{{id}}" class="dropdown-toggle {{id}}"
role="button" data-toggle="dropdown" data-target="#" href="#">
<div class="input-group">
<input type="text" class="form-control" value="{{datetime.format(dateFormat)}}">
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
</div>
</a>
<ul ng-if="minView" class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<datetimepicker data-ng-model="datetime"
@jkresner
jkresner / viewsService.js
Created Jul 16, 2015
Aliasing anonymous to identified users
View viewsService.js
var ViewsCollection = require('../models/view').collection
var viewSvc = {
getByUserId(userId, cb)
{
if (logging) $log('views.getByUserId'.trace, userId)
ViewsCollection.find({userId}).sort({_id:-1}).toArray((e, r) => cb(r))
},
getByAnonymousId(anonymousId, cb)
@jkresner
jkresner / -bootstrap.js
Created Mar 24, 2015
es6 Bootstrap with traceur
View -bootstrap.js
'use strict';
var setup = require('./server/util/_setup')
var config = setup.initConfig(process.env.env || 'dev')
setup.initGlobals(config)
require('./index').run()
@jkresner
jkresner / repo.js
Created Feb 23, 2015
airpair-post-repo-creation
View repo.js
setupPostRepo(repo, githubOwner, post, readmeMD, user, cb){
// console.log(`setting up repo ${repo} for ${githubOwner}`)
var _this = this
this.createRepo(repo, function(err, result){
if (err){
var parsedError = JSON.parse(err.message);
var errors = parsedError.errors
if (errors && errors.length == 1 && errors[0].message === "name already exists on this account")
$log("repo already created");
@jkresner
jkresner / index.hbs
Last active Aug 29, 2015
Node.js Express Login with PayPal Integration (ES6)
View index.hbs
<h1>Paypal Login</h1>
<a href="{{paypalLoginUrl}}"><img src="https://www.paypalobjects.com/webstatic/en_US/developer/docs/lipp/loginwithpaypalbutton.png" /></a>
@jkresner
jkresner / braintree.js
Created Dec 2, 2014
ES6 Braintree Wrapper
View braintree.js
var util = require('../../../shared/util')
var braintree = require('braintree')
var {merchantId, publicKey, privateKey} = config.payments.braintree
var environment = braintree.Environment[config.payments.braintree.environment]
var gateway = braintree.connect({ environment, merchantId, publicKey, privateKey })
var logging = false
@jkresner
jkresner / model.js
Created Sep 18, 2014
Testing some model code
View model.js
var Author = {
userId: { required: true, type: ObjectId, ref: 'User', index: true },
name: { required: true, type: String },
avatar: { required: true, type: String },
username: { type: String }, // if they are an expert
tw: { type: String },
gh: { type: String },
in: { type: String },
gp: { type: String },
bio: { type: String }
@jkresner
jkresner / jq.js
Last active Dec 21, 2015
Add jQuery to any page via the browser console once it's loaded.
View jq.js
var _JQ = document.createElement('script');
_JQ.src = 'http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js';
_JQ.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(_JQ);
@jkresner
jkresner / test-passport.coffee
Created Jun 20, 2013
Passport.js user mocking version 2
View test-passport.coffee
users = require './../data/users'
data = users: []
data.users.anon = authenticated: false
data.users.admin = users[0]
data.users.jk = users[1]
data.users.artle = users[5]
data.users.beountain = users[4]
setSession = (userKey) ->
You can’t perform that action at this time.