Skip to content

Instantly share code, notes, and snippets.

View GoodNovember's full-sized avatar
🖍️
Why can't I write my code in Crayon?

Victor GoodNovember

🖍️
Why can't I write my code in Crayon?
  • 951 Gaspra
View GitHub Profile
@GoodNovember
GoodNovember / makeGetSet.js
Created August 8, 2019 22:32
Kinda useful getter setter and subscriber all in one.
export const makeGetSet = ({ initialValue, skipInitialCall = false }) => {
let value = initialValue
let subscribers = new Set()
const getValue = () => value
const setValue = newValue => {
value = newValue
subscribers.forEach(sub => { sub(newValue) })
}
const subscribe = callback => {
if (subscribers.has(callback) === false) {
@GoodNovember
GoodNovember / interface.md
Created August 18, 2019 15:40
LENS Thoughts

interface

a phone keyboard like interface. searchable. with the best carrot in town.

effortless to put where you want and every action performed is clearly understandable what happened and be easily undoable and redoable.

drag to reorder everything. every action is clear and distinct yet cohesive.

every action fits together like Legos.

@GoodNovember
GoodNovember / email.md
Created September 17, 2019 21:14
Junk Email: on behalf of Steven | RONTA <sales@XMRONTA.COM>

Dear Sir/Maddam, lawit

Wish you a nice day!

This is Steven from Ronta(Xiamen)Co.,Ltd.We are a professional manufacturer of bags located in Xiamen,China.

We can produce the following products for you:

Sports Bags Backbacks

@GoodNovember
GoodNovember / classify.js
Created September 27, 2019 19:15
Classify Stuff with filters.
const giveMeArrayOfArrays = count => {
const output = []
for (let i = 0; i < count; i++) {
output.push([])
}
return output
}
const classify = (inputArray, arrayOfFilters = []) => {
const getFilterResults = (value, index, array) => {
const differentiate = (targetArray, filterFunction) => targetArray.reduce(([truthAcc, falseAcc], item, index, arr) => {
if (filterFunction(item, index, arr)) {
truthAcc.push(item)
} else {
falseAcc.push(item)
}
return [truthAcc, falseAcc]
}, [[], []])
module.exports = { differentiate }
@GoodNovember
GoodNovember / example.js
Last active November 18, 2019 18:16
Some Handy React Hooks
const Range = ({ containerStyle, containerClassName, min, max, value, step, onChange }) => {
const animate = (timestamp, delta) => {
console.log('AnimationTick', {timestamp, delta})
}
const [startAnimation, stopAnimation, getIsAnimatingRef, getIsAnimatingState] = useAnimationFrame(animate, true)
useDocumentEvents({
'pointerup' (event) {
stopAnimation()
// useful for setting constraints.
export const bracket = ({ value, min, max }) => Math.min(Math.max(value, min), max)
@GoodNovember
GoodNovember / makeRange.js
Created October 10, 2019 19:43
Useful to get an array of integer values that start from one number and end in another one.
export const makeRange = ([ start, end ]) => {
const length = Math.abs(end - start)
const output = []
let cursor = start
if (start === end) {
return [start]
}
for (let i = 0; i <= length; i++) {
if (start < end) {
output.push(cursor++)
@GoodNovember
GoodNovember / Canvas.js
Created November 18, 2019 18:28
Generic Canvas2d React Element
import React, { useEffect, useRef } from 'react'
import { useRequestAnimationFrame } from '../hooks/useRequestAnimationFrame'
const getDPR = () => window.devicePixelRatio || 1.0
export const Canvas = ({
onRender,
contextType = '2d',
idealFPS = 60
}) => {
@GoodNovember
GoodNovember / about.md
Created December 11, 2019 23:40
Single Page Apps with ZEIT Now, Parcel and React

This is a nice Single Page App stack example config.

ingredients

  • now // easy peasy deploys
  • react // pleasurable coding
  • parcel-bundler //easy packaging.