Skip to content

Instantly share code, notes, and snippets.

View nealalan's full-sized avatar

nealalan nealalan

View GitHub Profile
@nealalan
nealalan / keybase.io
Created November 29, 2017 03:46
Keybase
### Keybase proof
I hereby claim:
* I am nealalan on github.
* I am nealalan (https://keybase.io/nealalan) on keybase.
* I have a public key whose fingerprint is 0FCD DA82 34C1 BB84 EAA8 5C9C 46A1 0498 3B7C E79A
To claim this, I am signing this object:
@nealalan
nealalan / 20180830_174423-IMG_1126-4032x3024.JPG
Last active December 29, 2018 06:00
Flower closeup w/ iPhone X 2018-08-30, Denver, CO
20180830_174423-IMG_1126-4032x3024.JPG
@nealalan
nealalan / 20180831_182138-P1010229-4592x3448.JPG
Last active December 29, 2018 20:41
Nebraska Clouds taken 2018-08-31
20180831_182138-P1010229-4592x3448.JPG
@nealalan
nealalan / json.md
Created August 5, 2019 23:25
JSON: JavaScript Object Notation Example

JSON: JavaScript Object Notation

  • JSON.stringify and JSON.parse
let string = JSON.stringify({squirrel: false,
                             events: ["weekend"]});
console.log(string);
// → {"squirrel":false,"events":["weekend"]}
console.log(JSON.parse(string).events);
@nealalan
nealalan / jsmath.md
Created August 5, 2019 23:29
JavaScript Match Function

MATH FUNCTION

  • Math.max (maximum)
  • Math.min (minimum)
  • Math.sqrt (square root)
  • Math.PI
  • Math.random (decimal)
  • Math.floor (rounds down to the nearest whole number)
console.log(Math.floor(Math.random() * 10));
// → 2
@nealalan
nealalan / jscorrelation.md
Created August 5, 2019 23:29
JavaScript Computing Correlation
  • function that computes the ϕ coefficient from such an array:
function phi(table) {
  return (table[3] * table[0] - table[2] * table[1]) /
    Math.sqrt((table[2] + table[3]) *
              (table[0] + table[1]) *
              (table[1] + table[3]) *
              (table[0] + table[2]));
}
@nealalan
nealalan / jsarrays.md
Last active August 5, 2019 23:34
JavaScript Notes on Arrays
@nealalan
nealalan / js-transpiling.md
Created August 6, 2019 00:05
JavaScript Transpiling

TRANSPILING

  • use a tool that converts your newer code into older code equivalent
  • ES6 adds a feature called "default parameter values." Transpiling will modify/add the code to work with ES5
  • Example:
// IN ES6, USE A DEFAULT VALUE
function foo(a = 2) {
	console.log( a );
}
// PRE ES6 EXPLICITLY CHECK FOR A DEFAULT VALUE AND DEFINE IT
@nealalan
nealalan / js-polyfilling.md
Created August 6, 2019 00:06
JavaScript Polyfilling

POLYFILLING

  • taking the definition of a newer feature and producing a piece of code that's equivalent to the behavior, but is able to run in older JS environments.
if (!Number.isNaN) {
	Number.isNaN = function isNaN(x) { return x !== x; };
}
  • Use a vetted set of polyfills that you can trust, such as those provided by ES5-Shim and ES6-Shim
@nealalan
nealalan / better-cli-prompt.md
Last active June 10, 2020 05:06
Make the command line better!!!

This is the prompt I am currently using. (Add to ~/.bashrc file.)

#######################################################################################################################
# BEAUTIFY THE COMMAND PROMPT WITH GIT
#######################################################################################################################
# get current branch in git repo
function parse_git_branch() {
 BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`