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;
});
# 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 / 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 / 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 / step-1-promises.js
Last active February 26, 2019 20:38
Async Await Demo
const resolveAfter2Seconds = () => {
console.log("starting slow promise");
return new Promise(resolve => {
setTimeout(() => {
resolve(20);
console.log("slow promise is done");
}, 2000);
});
};
@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.

@JoeKarlsson
JoeKarlsson / README.md
Created July 27, 2016 00:28
Lecture on password encryption, hashing, and bcrypt

How To Safely Store A Password

Use bcrypt. Use bcrypt. Use bcrypt. Use bcrypt. Use bcrypt. Use bcrypt. Use bcrypt. Use bcrypt. Use bcrypt. Use bcrypt.

Why Not {MD5, SHA1, SHA256, SHA512, SHA-3, etc}?

These are all general purpose hash functions, designed to calculate a digest of huge amounts of data in as short a time as possible. This means that they are fantastic for ensuring the integrity of data and utterly rubbish for storing passwords.

bcrypt Solves These Problems

How? Basically, it’s slow as hell. It uses a variant of the Blowfish encryption algorithm’s keying schedule, and introduces a work factor, which allows you to determine how expensive the hash function will be.

@JoeKarlsson
JoeKarlsson / sorting-algorithms.md
Last active June 15, 2020 01:21
Five popular sorting algorithms implemented manually and visualized with DOM manipulation
@JoeKarlsson
JoeKarlsson / 1proto.js
Last active June 15, 2020 01:22
Prototype Live Coding Examples
var o = {
a: 2,
m: function(b){
return this.a + 1;
}
};
// When calling o.m in this case, 'this' refers to o
console.log(o.m()); // 3
@JoeKarlsson
JoeKarlsson / moodlite.ino
Created March 25, 2019 23:12
Moodlite Arduino Backup: https://moodlite.co.uk/
/*
Name: Moodlite.ino
Created: 27.12.2018
Version: 2.0
AuthorS: Spigot (M.V.), Shiryou & Steve Wagg aka CdRsKuLL
License: This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License v3.0 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/gpl.html>
Support: Wether you use this project, have learned something from it, or just like it, please consider supporting us on our web site. :)