Skip to content

Instantly share code, notes, and snippets.

@essamalsaloum
essamalsaloum / user.sql
Created September 15, 2017 15:40 — forked from rts-rob/user.sql
User and Type example showing foreign key constraints and builtin uuid() function for generating id
CREATE TABLE userType (
id int NOT NULL,
description varchar(255) NOT NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE user (
id char(32) NOT NULL, -- use uuid() on INSERT
username varchar(24) NOT NULL, -- rob
passwordHash char(40) NOT NULL, -- c8fed00eb2e87f1cee8e90ebbe870c190ac3848c
@essamalsaloum
essamalsaloum / archetype.js
Created September 15, 2017 15:39 — forked from rts-rob/archetype.js
Basic archetype of every express function ever
function archetype (request, response) {
// Get Data out of the request
// Process that data
// Build and send the response
response.setHeaders();
response.write();
response.end();
}
@essamalsaloum
essamalsaloum / authentication.js
Created September 15, 2017 15:38 — forked from rts-rob/authentication.js
Basic psuedocode example of a signup/login flow with salt and hash
function signup (email, password) {
const salt = uuid();
const hashedPassword = hash(`${salt}${password}`);
// this stores everything in the DB
createUser(email, salt, hashedPassword);
}
function login (request, response) {
// get the salt - SELECT salt FROM users
// WHERE email = ?, [email]
@essamalsaloum
essamalsaloum / index.js
Created July 13, 2017 00:26 — forked from jasongwartz/index.js
HYF Class 8 - Node Homework (Week 1)
// To run this file: node index.js
// Then in your browser: http://localhost:8080
var http = require('http');
var port = 8080;
var server = http.createServer();
// Start the HTTP server, start listening for requests
server.listen(port, function(error) {
@essamalsaloum
essamalsaloum / 0.md
Created June 15, 2017 11:35 — forked from max-mapper/0.md
JS hoisting by example

JavaScript function hoisting by example

Below are many examples of function hoisting behavior in JavaScript. Ones marked as works successfuly print 'hi!' without errors.

To play around with these examples (recommended) clone them with git and execute them with e.g. node a.js

Notes on hoisting

(I may be using incorrect terms below, please forgive me)