Skip to content

Instantly share code, notes, and snippets.

View procchio6's full-sized avatar

Pat Rocchio procchio6

View GitHub Profile
@procchio6
procchio6 / machine.js
Last active May 4, 2020 20:47
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@procchio6
procchio6 / StyledComponent.js
Last active July 23, 2017 21:48
Example of styling React components with style-components
import React, {Component} from 'react'
import styled from 'styled-components'
const Title = styled.h1`
color: red;
text-decoration: underline;
text-decoration-color: black;
`
// Extend styling //
const BiggerTitle = Title.extend`
@procchio6
procchio6 / BFS.js
Created July 3, 2017 02:40
Breadth First Search
Tree.prototype.findBFS = function (node) {
let queue = [this.root]
while (queue.length > 0) {
let currentNode = queue.shift()
if (currentNode.value == node) {
return currentNode
}
@procchio6
procchio6 / DFS.js
Last active July 3, 2017 02:33
Breadth First Search
Tree.prototype.findDFS = function (node) {
let stack = [this.root]
while (stack.length > 0) {
let currentNode = stack.pop()
if (currentNode.value == node) {
return currentNode
}
@procchio6
procchio6 / tree.js
Created July 3, 2017 02:26
Node and Tree
function Node (value) {
this.value = value
this.parent = null
this.children = []
}
function Tree() {
this.root = null
}