Skip to content

Instantly share code, notes, and snippets.

View kylehill's full-sized avatar

Kyle Hill kylehill

  • Skylight Digital
  • Washington, DC
View GitHub Profile
@kylehill
kylehill / README.md
Last active March 2, 2018 16:47
JS Conf Iceland 2018 Talk Summaries

JS Conf Iceland 2018 Talk Summaries

Hello! I'm at JS Conf Iceland and taking notes on all the talks I go to. They're mostly for my own reference, but you're welcome to use them.

If you're here, say hi -- I'm wearing a blue checked shirt.

If you're on Twitter, I'm @kylehill.

@kylehill
kylehill / body.js
Last active November 27, 2016 17:47
Check Body ScrollHeight on a loop
var currentHeight = 0;
var checkHeight = function() {
if (document.body.currentHeight !== currentHeight) {
executeSomeFunctionHereToApplyLinks()
currentHeight = document.body.currentHeight
}
setTimeout(500, checkHeight) // execute this again 500ms later
}

##A Bluffer’s Guide to Big-O Notation

What is it? Big-O Notation is a way to roughly estimate the growth in runtime for a given operation as the input it operates on increases in complexity. You’ll often hear it referred to like, “this function has a runtime of O(n log n).”

Can you explain that simpler? Sure. Let’s imagine a function that takes in a single array (of indeterminate length) as a parameter, does something with its contents, and returns some kind of value. What Big-O is intended to convey is how dramatically the time it takes to execute the function increases as the size of the input array increases.

Let’s make this real! In our imaginary world, the environment that’s running our code takes exactly 1 millisecond to check the value of any variable or at any index of an array, and another 1 millisecond to the set the value of any variable or at any index of an array. (This is artificial, but it at least allows us to count things.)

If we have a function that takes in an ar

@kylehill
kylehill / keybase.md
Created July 27, 2016 18:02
keybase.md

Keybase proof

I hereby claim:

  • I am kylehill on github.
  • I am kylehill (https://keybase.io/kylehill) on keybase.
  • I have a public key whose fingerprint is 74B0 DA65 A3EE 7E76 4395 51D0 FBC3 F2AC 5DA9 9F34

To claim this, I am signing this object:

// Defining this variable before the function you want to be run once is executed
// Also setting the value to something other than what you're checking it for
var thisHasAlreadyRun = false
var someFunction = function() {
// First time through, the variable is defined and the value isn't true,
// so it skips the short-circuit return
if (thisHasAlreadyRun === true) {
return
}
var phomene = "na"

var fruit = "ba" + phomene.repeat(2)

var superhero = phomene.repeat(16) + ", Batman"

var videoGame = `${phomene.repeat(2)}, ${phomene.repeat(3)}-${phomene.repeat(4)}, Katamari Damacy`
"use strict"
const _bossHealth = 71
const _bossDamage = 10
const _playerHealth = 50
const _playerMana = 500
let msgs = {}
const log = (msg) => {
"use strict"
const _bossHealth = 71
const _bossDamage = 10
const _playerHealth = 50
const _playerMana = 500
let msgs = {}
const log = (msg) => {
export PATH="/usr/local/bin:$PATH"
export LSCOLORS=GxFxCxDxBxegedabagaced
export CLICOLOR=1
bind "set completion-ignore-case on"
. /usr/local/etc/profile.d/z.sh
alias s="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl ."
alias psql="'/Applications/Postgres.app/Contents/Versions/9.4/bin'/psql -p5432"
@kylehill
kylehill / closures.js
Created April 23, 2015 16:44
Closures
/*
A "closure" is created whenever
- a function is executed and variables are scoped inside of it, either as params or with var
- that function returns an executable function, either by itself or as part of an object/array
The locally-scoped variables are then "closed over." Like any other variables defined inside of a function,
they are not accessible outside of that scope, but in the special case of a closure they are still accessible
by the **returned function**.
*/