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 / client.js
Created September 18, 2018 19:27
Intro to NodeJS - using the net module and building a client and server
const net = require('net');
const options = {
'port': 8080,
'host': '127.0.0.1'
};
// creates a socket connection to a server
const client = net.connect(options, () => {
console.log('Connected to Server!');
@JoeKarlsson
JoeKarlsson / hash.js
Created July 24, 2018 16:42
JS Hashing function
const hashAlgorithm = (data) => {
const FNV_PRIME_32 = 0x1000193;
const FNV_OFFSET_32 = 0x811C9DC5;
let hash = FNV_OFFSET_32;
const str = JSON.stringify(data);
for (let i = 0; i < str.length; i++) {
hash ^= str.charCodeAt(i);
hash *= FNV_PRIME_32;
@JoeKarlsson
JoeKarlsson / README.md
Created July 6, 2018 19:16
Express + Sequalize Migration Demo

Sequelize + Express Starter Guide

======================================================================

Based off of: http://docs.sequelizejs.com/en/1.7.0/articles/express/

Create your project director


Create and initialize your a directory for your Express application.

# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@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;
});
[user]
name = Joe Karlsson
email = joekarlsson1@gmail.com
github = joekarlsson1
[color]
branch = auto
diff = auto
status = auto
ui = auto
### 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 / 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;