Skip to content

Instantly share code, notes, and snippets.

Avatar

David Peek dpeek

View GitHub Profile
@dpeek
dpeek / theme.ts
Created Jul 13, 2021
Radix Color Scale Mapper
View theme.ts
import { createCss } from '@stitches/react';
import { mint } from '@radix-ui/colors';
type ScaleNum = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
type ScaleKey<Name extends string> = `${Name}${ScaleNum}`;
type ColorScale<Name extends string> = { [K in ScaleKey<Name>]: string };
function mapColorScale<FromName extends string, ToName extends string>(
fromScale: ColorScale<FromName>,
fromName: FromName,
View 05.js
const opcode = op => {
const str = String(op);
return parseInt(str.substr(str.length - 2));
};
const mode = (op, pos) => {
const str = String(op);
if (pos + 2 > str.length) return 0;
return parseInt(str.substr(str.length - (2 + pos), 1));
};
View gist:b3183357f904bc61cb21f1dd22a1af00
## dgraph query
{
person(func: uid(0x41d)) {
__typename
uid
name: Person.name
partner: Person.partner {
__typename
uid
name: Person.name
@dpeek
dpeek / clean.sh
Created Feb 11, 2019
Ensure consistent line-endings within files (both CRLF and LF)
View clean.sh
# Require Swiss File Knife (sfk) (available from homebrew on macOS)
# find all files detected as CRLF and force CRLF
find . -not -path "./.git*" -type f | xargs file | grep "CRLF" | awk -F ':' '{ print $1 }' | xargs sfk addcr
# find all files detected as LF and force LF
find . -not -path "./.git*" -type f | xargs file | grep -v "CRLF" | awk -F ':' '{ print $1 }' | xargs sfk remcr
@dpeek
dpeek / bif.js
Created Feb 28, 2018
BIF Parser
View bif.js
function Buffer(a) {
this.buffer = a;
this.position = 0;
}
Buffer.prototype = {
seek: function(a) {
this.position = a;
},
skip: function(a) {
this.position += a;
@dpeek
dpeek / docker-compose.yml
Created Dec 17, 2017
Docker Compose Dgraph
View docker-compose.yml
version: '3'
services:
data:
image: dgraph/dgraph:master
volumes:
- dgraph:/dgraph
zero:
image: dgraph/dgraph:master
command: dgraph zero --port_offset -2000 --my=zero:5080
View gist:a9e3f690527d6c4bbdc7d5053cbb49f0
///////////////////////////////////////////////////// TAKE 1
http://localhost:8080/mutate
{ set {
_:node <__typename> "Person" .
_:node <name> "Tim" .
_:node <children> _:node0 .
_:node0 <parents> _:node .
_:node0 <__typename> "Person" .
_:node0 <name> "Jerry" .
@dpeek
dpeek / dgraph.sh
Last active Dec 10, 2018
Install Go and Dgraph on AWS ubuntu AMI and run as service
View dgraph.sh
#!/bin/bash
# install dgraph
sudo apt-get update -y
sudo apt-get install -y gcc
curl https://get.dgraph.io -sSf | bash
# create dgraph.service
sudo bash -c 'cat << EOF > /etc/systemd/system/dgraph.service
[Unit]
View gist:a9bb8231c4c64451cef119f67d21bdb1
/* @flow */
type ErrorResponse = {
code: 'Error',
message: string
}
type ResultResponse = {}
function test (): Promise<ResultResponse | ErrorResponse> {
View Error.hx
package haxe;
typedef Error =
#if !native_error
String;
#elseif js
js.Error;
#elseif flash
flash.errors.Error;
#elseif java