Skip to content

Instantly share code, notes, and snippets.

View cheng-kang's full-sized avatar
🐢
Don't know how to drive.

Kang Cheng · 程康 cheng-kang

🐢
Don't know how to drive.
View GitHub Profile
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@cheng-kang
cheng-kang / index.html
Created October 5, 2019 22:46
Rubber stamp effect by Pete Blatchford (https://codepen.io/555/pen/pdwvBP)
<span class="stamp">proposal</span>
<span class="stamp is-nope">Declined</span>
<span class="stamp is-approved">Approved</span>
<span class="stamp is-draft">Draft</span>
@cheng-kang
cheng-kang / copyTypeDef.js
Created September 4, 2019 00:52
Script to copy all d.ts files
// Copied & pasted and maybe modified from `material-ui`
/* eslint-disable no-console */
const path = require("path");
const fse = require("fs-extra");
const glob = require("glob");
const packagePath = process.cwd();
const buildPath = path.join(packagePath, "./lib");
const srcPath = path.join(packagePath, "./src");
@cheng-kang
cheng-kang / index.js
Last active February 21, 2019 11:35
Hook version of query-hoc.
import useQuery from "./useQuery";
export default useQuery;
@cheng-kang
cheng-kang / git-gone.sh
Created January 11, 2019 19:56
Remove local branches that are gone on remote.
git fetch -p && for branch in `git branch -v | egrep '^\S*\s*\S*\s*\[gone\]' | awk '{print $1}'`; do git branch -D $branch; done;
@cheng-kang
cheng-kang / index.html
Created July 8, 2018 17:29
Transfer DOM from iframe to parent.document
<!DOCTYPE html>
<html>
<head>
<title>iFrame srcdoc test</title>
</head>
<body>
<div id="target">Hi.</div>
<iframe srcdoc="<!DOCTYPE html>
<html>
<head>
path /users {
read() { true }
// `.isAdmin` is not writable by any users including admin user.
index() { ['email'] }
/{uid} {
write() { (isCreate(this) || isCurrentUser(uid) || isAdmin()) && (this.isAdmin == null && prior(this).isAdmin == null) }
}
}
{
"rules": {
"users": {
"$uid": {
".write": "(data.val() == null || auth != null && auth.uid == $uid || root.child('users').child(auth.uid).child('isAdmin').val() == true) && newData.child('isAdmin').val() == null && data.child('isAdmin').val() == null"
},
".read": true,
".indexOn": [
"email"
]