Skip to content

Instantly share code, notes, and snippets.

View chee's full-sized avatar
🍕
partying

chee chee

🍕
partying
View GitHub Profile
@chee
chee / project
Last active April 29, 2017 10:46
print project root directory (takes an optional relative or absolute path, defaults to pwd)
#!/bin/bash
if [ "${1:0:1}" == '/' ]; then
dir="$(dirname $1)"
else
dir="$(pwd)/$1"
fi
project_root_files=".git .hg .project"
while [ "$dir" != '/' ] && [ -z "$project_root" ]; do
for file in $project_root_files; do
function curry(fn) {
return function curried(...args) {
if (args.length >= fn.length) {
return fn(...args)
} else {
return (...nextArgs) => curried(...args, ...nextArgs)
}
}
}
@chee
chee / curry-golf.js
Last active September 14, 2018 15:17
curry
l='length';c=f=>function c(...a){return a[l]>=f[l]?f(...a):(...n)=>c(...a,...n)}
#!/bin/sh
name="$1"
mkdir $name
cd $name
yarn init -y
yarn add --dev babel-preset-react-app babel-plugin-transform-es2015-modules-commonjs
yarn add react react-dom
cat <<LOL > .babelrc
data = require('./data.json')
escape = char => `\\${char}`
special = new RegExp(
'[' +
'( ) { } [ ] | \\ ^ $ * + ? .'
.split``
.map(escape)
.join('|') +
data = require('./data.json')
escape = char => `\\${char}`
special = new RegExp(
'[' +
'( ) { } [ ] | \\ ^ $ * + ? .'
.split``
.map(escape)
.join('|') +
data = require('./data.json')
escape = char => `\\${char}`
special = new RegExp(
'[' +
'( ) { } [ ] | \\ ^ $ * + ? .'
.split``
.map(escape)
.join('|') +
@chee
chee / bigify.js
Last active August 14, 2018 13:36 — forked from rowanmanning/bigify.js
Bigify
#!/usr/bin/env node
charactermap = new Proxy({
' ': 'blank',
'?': 'question',
'!': 'exclamation'
}, {
get: (object, key) =>
key in object
? object[key]
@chee
chee / lol.json
Last active September 6, 2018 16:04
{
"lol": "hi",
"array": ["a", "b", "c"]
}
@chee
chee / number-words.js
Last active September 15, 2018 16:34
function deconstructor({words, number, base}) {
const which = Math.log(number) / Math.log(base) | 0
const amount = Math.pow(base, which)
const prefix = number / amount | 0
const round = amount * prefix
return {
number: prefix,
remainder: number - round,
word: words[which]
}