| 3 Letter Shorthand | Instance |
|---|---|
arr |
Array |
bol |
Boolean |
cls |
class |
doc |
Document |
dte |
Date |
ele |
Element |
fun |
Function |
nod |
Node |
| import * as React from "react"; | |
| import { PropertyControls, ControlType } from "framer"; | |
| import { defineCustomElements } from "stencil-component/dist/loader"; | |
| const style: React.CSSProperties = { | |
| height: "100%", | |
| display: "flex", | |
| alignItems: "center", | |
| justifyContent: "center", | |
| textAlign: "center", |
| import produce from 'immer'; | |
| import {createStore} from 'redux'; | |
| const handleActions = (actionsMap, defaultState) => ( | |
| state = defaultState, | |
| {type, payload} | |
| ) => | |
| produce(state, draft => { | |
| const action = actionsMap[type]; | |
| action && action(draft, payload); |
A tiny (265 byte) utility to create state machine components using two pure functions.
The API is a single function that accepts 2 pure functions as arguments:
| const { Left, Right } = require('fantasy-eithers') | |
| const daggy = require('daggy') | |
| Function.prototype.map = function (f) { | |
| return x => f(this(x)) | |
| } | |
| //- Where everything changes... | |
| const login = user => | |
| user.name == 'Tom' |
| /** | |
| * FAST PACKING / UNPACKING JSON | |
| * | |
| * If all objects in a collection follows a similar schema, | |
| * then there is gain in changing the representation from a dictionary to a simple array. | |
| * | |
| * It is known results used in database, protocols, in v8 itself with shadow maps and IRL. | |
| * | |
| * In this example, we expect our final exchange to be equivalent to this literal representation: | |
| * [ |
| function flat(fn) { | |
| return function (...args) { | |
| return new Promise((resolve, reject) => { | |
| fn.call(this, {resolve, reject}, ...args); | |
| }); | |
| }; | |
| } |
https://gist.github.com/ljharb/58faf1cfcb4e6808f74aae4ef7944cff
While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.
JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it mu
| ## Commonly used PSADT env variables | |
| $envCommonDesktop # C:\Users\Public\Desktop | |
| $envCommonStartMenuPrograms # C:\ProgramData\Microsoft\Windows\Start Menu\Programs | |
| $envProgramFiles # C:\Program Files | |
| $envProgramFilesX86 # C:\Program Files (x86) | |
| $envProgramData # c:\ProgramData | |
| $envUserDesktop # c:\Users\{user currently logged in}\Desktop | |
| $envUserStartMenuPrograms # c:\Users\{user currently logged in}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs | |
| $envSystemDrive # c: | |
| $envWinDir # c:\windows |