Skip to content

Instantly share code, notes, and snippets.

@psxcode
psxcode / cps_hof_compose.md
Last active July 23, 2018 14:10
CPS vs HOF vs Compose

CPS vs HOF vs Compose

CPS

Continuation Passing Style Node async API style

function doWork(p0, p1, done) {
  var results = p0 + p1
  done(null, results)
}
@psxcode
psxcode / gtor-outlines.md
Last active January 2, 2019 13:54
GTOR outlines

Value

  • singular
  • spacial
  • sync

Getter / Setter

  • singular
  • sync
  • unicast
@psxcode
psxcode / cmake.md
Last active July 24, 2018 15:57
CMake

CMake

Organization

  • Directories contain CMakeLists.txt, add by add_subdirectory
  • Scripts are <script>.cmake files that can be executed with cmake -P <script>.cmake. Not all commands are supported
  • Modules are <script>.cmake files located in CMAKE_MODULES_PATH directory. Can be loaded with include() command

Generator expressions

target_compile_definition(foo
@psxcode
psxcode / ts-tips.ts
Last active August 8, 2018 13:04
ts-tips
/**
* Make all properties in T optional
*/
type Partial<T> = {
[P in keyof T]?: T[P];
};
/**
* Make all properties in T required
*/
@psxcode
psxcode / canvas.ts
Created August 10, 2018 22:04
canvas draw snippets
export interface ICanvas {
width: number;
height: number;
halfWidth: number;
halfHeight: number;
ctx: CanvasRenderingContext2D;
image: ImageData;
buffer: ArrayBuffer;
buffer8: Uint8ClampedArray;
buffer32: Uint32Array;
@psxcode
psxcode / index.js
Created August 30, 2018 20:01
rasterize test
'use strict'
var data
var width
var height
var scale = 6
var cred = (255 << 24) | 255
var credd = (255 << 24) | 100
var cgreen = (255 << 24) | (255 << 8) | 100
@psxcode
psxcode / .babelrc
Last active February 11, 2019 08:42
js setup
{
"env": {
"production": {
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "8"
},
@psxcode
psxcode / .gitconfig
Last active June 1, 2020 14:08
Git config
[color]
ui = auto
[user]
name = psxcode
email = psxcode@gmail.com
[credential]
helper = osxkeychain
[alias]
st = status
co = checkout
@psxcode
psxcode / git.md
Last active January 30, 2019 13:54
git commands

Diff

  • git diff HEAD^^ HEAD main.c
  • git diff HEAD^^..HEAD -- main.c
  • git diff revision_1:file_1 revision_2:file_2

Diff Tool

  • git difftool --tool=meld HEAD~..HEAD

Show

  • git show
@psxcode
psxcode / cloudserver.sh
Created June 4, 2019 19:41
Cloudserver use case snippets
[local]
aws_access_key_id = accessKey1
aws_secret_access_key = verySecretKey1
docker run --name srv -d -p 8000:8000 -e REMOTE_MANAGEMENT_DISABLE=1 -e S3BACKEND=mem zenko/cloudserver
aws --profile local --endpoint-url http://127.0.0.1:8000/ s3 ls
aws --profile local --endpoint-url http://127.0.0.1:8000/ s3 mb 123