Skip to content

Instantly share code, notes, and snippets.

@alexboots
alexboots / .hello
Created July 29, 2021 23:33
Book of shaders notes
Getting started
--------------------------------
GLSL stands for openGL Shading Language
- Each pipe of thread has to be independant of each other
- Threads are blind to what each other is doing
- DATA MUST FLOW IN THE SAME DIRECTION
From docs:
“Any function inside a component, including event handlers and effects, “sees” the props and state from the render it was created in.”
so stale closures exist - you have to do like setCount(count => count + 1) to access the 'latest actual state'
if you do like setCount(count + 1) it wont increase because you're using the 'count' from the origional render
from here: https://overreacted.io/a-complete-guide-to-useeffect/
“Effects always “see” props and state from the render they were defined in. That helps prevent bugs but in some cases can be annoying. For those cases, you can explicitly maintain some value in a mutable ref.”

Keybase proof

I hereby claim:

  • I am alexboots on github.
  • I am alexboots (https://keybase.io/alexboots) on keybase.
  • I have a public key ASBarHKUpcZIFw1_DTXUzuy4jEiwdKUtwZnnu200DC3CiQo

To claim this, I am signing this object:

All from here: https://microsoft.github.io/TypeScript-New-Handbook/chapters
run with --strict to catch more stuff
number[] = array of numbers,
also Array<number>
string[] = array of string
any = typescript wont yell at you for anything
let obj: any = { x: 0 };
// country-by-continent.js
export const NORTH_AMERICA = 'North America'
export const EUROPE = 'Europe'
export const ASIA = 'Asia'
export const AUSTRALIA = 'Australia'
export const SOUTH_AMERICA = 'South America'
export const AFRICA = 'Africa'
export const ANTARCTICA = 'Antarctica'
export const UNCATEGORIZED = 'Uncategorized'
// until 768px
@include mobile {
div {
background: pink;
}
}
// from 769px
@include tablet {
import React, { createContext } from "react";
const SocketContext = createContext({
queueLength: 0,
positionInLine: 0,
});
export default SocketContext;
@alexboots
alexboots / States-v3.md
Created September 22, 2016 20:15 — forked from andymatuschak/States-v3.md
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

```
import React from 'react'
import ampersandMixin from 'ampersand-react-mixin'
export default React.createClass({
mixins: [ampersandMixin],
displayName: 'Label',
getInitialState () {
routes: {
'login': 'login',
'logout': 'logout',
'auth/callback?:query': 'authCallback' // :query syntax passes whatever str is passed back to authCallback
},
//////////
//////////
//////////