View primitive-reference-types-javascript.md

Primitive Types & Reference Types in JavaScript

An explanation of JavaScript's pass-by-value, which is unlike pass-by-reference from other languages.

Facts

  • JavaScript has 2 kinds of variable types: primitive and reference.
  • A fixed amount of memory is reserved after creation of every variable.
  • When a variable is copied, it's in-memory value is copied.
  • Passing a variable to a function via a call also creates a copy of that variable.

Primitive Types

View fp-generic.js
// Generic FP utils
const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)));
const map = fn => list => list.map(fn);
const filter = fn => list => list.filter(fn);
const lt = left => right => left < right;
const add = left => right => left + right;
const upper = str => str.toUpperCase();
const prop = key => obj => obj[key];
const assoc = key => val => obj => { obj[key] = val; return obj; };
View Carousel.js
View howto.md

macOS: Manage Multiple versions of Java

Setup tooling

brew update
brew install jenv
brew tap caskroom/cask
brew tap caskroom/versions
mkdir ~/.jenv/versions
View create-zip.js
const stat = require('fs').statSync;
const AdmZip = require('adm-zip');
/**
* Example usage
*/
newArchive(`test-${+new Date}.zip`, [
'index.js',
'package.json',
'node_modules'
View a-page.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Homepage</title>
<!-- If HTTP/1: Inline with <style>, remove this <link> -->
<!-- If HTTP/2: Server push this CSS file, and leave this <link> -->
<link rel="stylesheet" href="critical-homepage.css">
View lambda-img-to-webp.js
'use strict';
const whitelist = {
'/static/img/photo.jpg': '/static/img/photo.webp'
};
exports.handler = (event, context, callback) => {
// Grab HTTP request and it's headers
const request = event.Records[0].cf.request;
View app.js
const map = fn => list => list.map(fn);
const filter = fn => list => list.filter(fn);
const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)));
const tail = list => list.slice(1);
const fill = val => num => new Array(num).fill(val);
const getFileContents = file => require('fs').readFileSync(file, { encoding: 'utf8' });
const split = char => str => str.split(char);
const join = char => list => list.join(char);
View keybase.md

Keybase proof

I hereby claim:

  • I am branneman on github.
  • I am branneman (https://keybase.io/branneman) on keybase.
  • I have a public key ASBUXh5Xc1fnzeLViPT2_Wo268hlgsOINNiGJ7UzbkiVXQo

To claim this, I am signing this object:

View prefixEventListener.js
/**
* Capitalize
*/
const capitalize = string => {
return string.charAt(0).toUpperCase() + string.slice(1);
};
/**
* Prefix EventListener
*/