Skip to content

Instantly share code, notes, and snippets.

@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";
```
lsof -n -i PORT
```
@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

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 / .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
@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 / 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 / tls-everywhere.md
Last active August 9, 2017 19:06
TLS Everywhere

The SSL protocol was implement by Netscape back in the day to facilitate commerce over the internet. E-commerce, as it became known as, required encryption to ensure that customer's personal information was kept safe, and the proper authentication and integrity guarentees were in place.

When SSL is used correctly, a third party cannot read or modify any of the actual data sent over the connection.

The TLS protocol is designed to provide three services to all applications running above it:

  1. Encryption
  2. Authentication
@byelipk
byelipk / congestion.md
Created August 8, 2017 13:42
TCP and the Congestion Avoidance Window

The Transmission Control Protocol (TCP) was designed to be courteous to the different traffic uses on a network. This notion is at the heart of what makes TCP so reliable, even in the face of competing demands for resources on the poorest of networks.

What makes TCP so reliable? Under the hood, TCP implements a concept called the congestion window. The congrstion window is the number of packets the sender can transmit over the wire until it receives an acknowledgment from the receiver. For example, if we set the congestion window to 1, the sender could send 1 packet to the reciever, then it would have to wait to recieve an acknowledgment. Only then could it send a second packet.

@byelipk
byelipk / csrf.md
Last active July 5, 2017 21:02
CSRF Study Notes

What is a CSRF?

This attack works by including malicous code, usually a link, in a website that accesses another site the user is believed to be authenticated with. If that user session is still authenticated, the attacker may execute unauthroized commands.

Most web applications store session data in a cookie. Browsers will automatically send the cookie on every request to a domain, if it can find the cookie for the domain. The catch is that if the request comes from a different domain, the browser will still send along the cookie.