Skip to content

Instantly share code, notes, and snippets.

nealalan nealalan

Block or report user

Report or block nealalan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nealalan
nealalan / js-polyfilling.md
Created Aug 6, 2019
JavaScript Polyfilling
View js-polyfilling.md

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 / js-transpiling.md
Created Aug 6, 2019
JavaScript Transpiling
View js-transpiling.md

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 / jsarrays.md
Last active Aug 5, 2019
JavaScript Notes on Arrays
View jsarrays.md
@nealalan
nealalan / jscorrelation.md
Created Aug 5, 2019
JavaScript Computing Correlation
View jscorrelation.md
  • 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 / jsmath.md
Created Aug 5, 2019
JavaScript Match Function
View jsmath.md

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 / json.md
Created Aug 5, 2019
JSON: JavaScript Object Notation Example
View json.md

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 / photos.md
Last active Sep 9, 2019
Processing photos
View photos.md

By: Neal Dreher 2019-07-02

Processing Photos: Phone -> Library

Each time I pull photos from my phone (or camera memory card), I go through a process to pull, transform and store photos, followed by sorting, deleting and importing photos into old Google Picasa 3.9. The last version was released in Oct 2015. With 81,000 photos in Picasa, I fear the day I can no longer find a machine that I can run Picasa on.

Slowly I have been thinking about how I will sort my pictures and store them online. I don't really desire to store all in Google Photos, but it maybe the best free option. Right now, Google Photos doesn't have the options built out that Picasa does.

For example:

  • Selecting an area and tagging a face manually is possible in Picasa, not in photos.
  • Editing a location on a map is only possible in Picasa. You can use exiftool, to manually add GPS coords.
@nealalan
nealalan / better-cli-prompt.md
Last active Aug 8, 2019
Make the command line better!!!
View better-cli-prompt.md

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

BWHITE='\[\033[01;37m\]'
BGREEN='\[\033[01;32m\]'
GREEN='\[\033[00;32m\]'
TEAL='\[\033[01;36m\]'
RED='\[\033[01;31m\]'
YELLOW='\[\033[01;33m\]'
You can’t perform that action at this time.