Skip to content

Instantly share code, notes, and snippets.

@byelipk
byelipk / selector-complexity.html
Last active August 14, 2017 19:40
Reduce selector complexity and reduce number of affected elements
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="author" content="" />
<meta name="viewport" content="width=device-width">
<title>Box Style Change</title>
@byelipk
byelipk / the-big-o.md
Last active September 9, 2017 03:17
the-big-o

Random access to a given element in a collection is always O(1), or constant tine.

The notion of constant time means that the operation will always complete in one compute cycle no matter how large the data structure grows to be.

const array = [1,2,3,4,5]
const theLastElemenet = array[array.length - 1] // O(1)

const hashMap = {hello: "world"}
@byelipk
byelipk / .tags
Created October 11, 2017 16:08
CTAGS
--exclude=.git
--exclude=.hg
--exclude=log
--exclude=tmp
--exclude=node_modules
--exclude=bower_components
--exclude=dist
--languages=-javascript

What are the 4 things that happen when we use the new in front of a function call?

  1. It creates a brand new object.
  2. The new object gets linked to the function's prototype.
  3. The new object gets passed into the function call as this.
  4. The function call returns this.

What is a constructor call?

It is a function call with the new keyword in front of it.

@byelipk
byelipk / flipcards.coffee
Last active November 24, 2017 13:04
Framer card flipping
# Flip Cards
cards = Container.children.filter (child) ->
child.name == "Card1" ||
child.name == "Card2" ||
child.name == "Card3" ||
child.name == "Card4"
for card in cards
```
lsof -n -i PORT
```
@byelipk
byelipk / statereducer.jsx
Last active November 6, 2018 21:09
Example of a state reducer pattern in React. Consumer has pretty much full control over UI and state management.
import React from "react";
const callAll = (...fns) => (...args) => fns.forEach(fn => fn && fn(...args));
class Chat extends React.Component {
static defaultProps = {
handleClick: () => console.log("Let's Chat"),
stateReducer: (state, changes) => changes
};
initialMood = "Curious";