Skip to content

Instantly share code, notes, and snippets.

View JoeKarlsson's full-sized avatar
🏠
Working from home

Joe Karlsson JoeKarlsson

🏠
Working from home
View GitHub Profile
@JoeKarlsson
JoeKarlsson / funArrays.js
Created February 11, 2017 19:36
Solutions for fun arrays
var dataset = require('./dataset.json');
/*
create an array with accounts from bankBalances that are
greater than 100000.00
assign the resulting array to `hundredThousandairs`
*/
var hundredThousandairs = dataset.bankBalances.filter(function(bank) {
return parseInt(bank.amount) > 100000;
});
### Keybase proof
I hereby claim:
* I am joekarlsson on github.
* I am joekarlsson (https://keybase.io/joekarlsson) on keybase.
* I have a public key whose fingerprint is E626 4B25 7B52 A96C 71D3 8B69 E050 65C4 A621 9367
To claim this, I am signing this object:
@JoeKarlsson
JoeKarlsson / immutable_demo.js
Last active October 29, 2016 20:20
Immutable JS demo
const Immutable = require('immutable');
const data = Immutable.Map({
people: Immutable.List(['Joe', 'Ray', 'Nigel']),
test: 'Hello World'
})
const data2 = data.updateIn(['people'], ((people) => {
return people.set(0, 'Russel');
}));
@JoeKarlsson
JoeKarlsson / server.js
Created October 6, 2016 19:19
Live Coding Demo for the HTTP Node Module
'use strict'
const http = require('http');
const PORT = 3000;
http.createServer(( request, response ) => {
console.log('request: ', request.url);
console.log('request: ', request.method);
@JoeKarlsson
JoeKarlsson / Missile.js
Last active September 14, 2016 02:23
ES6 OOP Example
'use strict'
const Rocket = require('./Rocket.js');
module.exports = class Missle extends Rocket {
constructor( speed, year ) {
super('Mach 10', 'North Korea', year)
this._speed = speed;
}
@JoeKarlsson
JoeKarlsson / posthoisting.js
Created September 8, 2016 18:55
Hoisting live coding demo
function tres(){
var foo = 4
return 3;
}
var uno;
var dos;
const quatro;
@JoeKarlsson
JoeKarlsson / closure.js
Created September 8, 2016 00:10
Live Coding Closure Examples
var money = 55.50;
var coffeeCost = 8.50;
var drinkCoffee = (function(){
var cupsDrunk = 0;
return function(){
if( money >= coffeeCost ){
money -= coffeeCost;
cupsDrunk++;
}
@JoeKarlsson
JoeKarlsson / User.js
Last active August 16, 2016 21:25
working demo of sequelize and graphql
module.exports = function(sequelize, DataTypes) {
var User = sequelize.define("User", {
username: DataTypes.STRING
});
return User;
};
@JoeKarlsson
JoeKarlsson / recursion.js
Last active June 23, 2016 19:14
Live Coding on recursion examples.
var recursify = function(num){
//base case
if(num === 0){
return;
}
console.log(num);
recursify(--num);
};
recursify(10); // 10 9 8 7 6 5 4 3 2 1
var express = require('express');
var app = express();
// Passport's sole purpose is to authenticate requests, which it does through an extensible set of plugins known as strategies. Passport does not mount routes or assume any particular database schema, which maximizes flexibility and allows application-level decisions to be made by the developer.
var passport = require('passport');
// This module lets you authenticate HTTP requests using the standard basic and digest schemes in your Node.js applications.
var BasicStrategy = require('passport-http').BasicStrategy; // Want to use Basic Authentication Strategy
// Other middleware