Skip to content

Instantly share code, notes, and snippets.

View DanielFGray's full-sized avatar

Daniel Gray DanielFGray

View GitHub Profile
@DanielFGray
DanielFGray / .bashrc
Last active September 28, 2018 18:34
multiple () {
local l x y p c
c=0 p=0 l=()
while :; do
case $1 in
-p)
if [[ $2 = -* ]]; then
echo '-p requires an argument'
return
fi
@DanielFGray
DanielFGray / gulpfile.js
Last active September 9, 2018 00:34
webpack in gulp
/* eslint-disable no-console,import/no-dynamic-require,global-require */
const path = require('path')
const gulp = require('gulp')
const R = require('ramda')
const watch = require('gulp-watch')
const webpack = require('webpack')
const { terminal } = require('terminal-kit')
const { ProgressPlugin } = webpack
const webpackPath = './webpack.config.js'
@DanielFGray
DanielFGray / ternaryindent.md
Last active April 10, 2018 02:05
formatting of different branching styles

nested ternary conditional

const type = a => (
  a === null ? 'null'
  : a === undefined ? 'undefined'
  : Object.prototype.toString.call(a).slice(8, -1))

if/else

const search = curry((pattern, str) => $(
pattern,
match(/!?(".*?"|\S+)/g),
reject(test(/^\W*$/)),
map(replace(/"(.*)"/, '$1')),
partition(startsWith('!')),
over(lensIndex(0), ifElse(isEmpty, T, $(drop(1), map(includesI), complement(anyPass)))),
over(lensIndex(1), $(map(includesI), allPass)),
([n, p]) => and(n, p, str),
))
@DanielFGray
DanielFGray / rc.lua
Created March 30, 2018 05:13
rc.lua
-- Standard awesome library
gears = require('gears')
awful = require('awful')
require('awful.autofocus')
-- Widget and layout library
wibox = require('wibox')
-- Theme handling library
beautiful = require('beautiful')
-- Notification library
naughty = require('naughty')
@DanielFGray
DanielFGray / category-intro.md
Last active March 22, 2018 19:39
an attempt at explaining category theory
layout title category tags date
post
computers
programming
javascript
fp
2018/1/4

Introduction

const net = require('net')
const { Observable } = require('rxjs')
const R = require('ramda')
const {
T,
concat,
cond,
drop,
equals,
@DanielFGray
DanielFGray / cmd.js
Last active March 4, 2018 22:25
spawn child processes with a promise
const { spawn } = require('child_process')
const readToEnd = stream =>
new Promise(((resolve, reject) => {
const parts = []
stream.on('error', reject)
stream.on('data', part => parts.push(part))
stream.on('end', () => resolve(Buffer.concat(parts)))
}))
@DanielFGray
DanielFGray / index.js
Last active November 9, 2017 19:36
nodejs dzen bar script
#!/usr/bin/env node
const { spawn } = require('child_process')
const { Observable } = require('rxjs')
const {
curry,
head,
identity,
join,
map,
memoize,
@DanielFGray
DanielFGray / gitlog.sh
Last active September 18, 2017 19:24
fancy git-log stuff
git log --graph --oneline --decorate --all --color=always |
fzf --ansi +s --preview='git show --color=always {2}' \
--bind='pgdn:preview-page-down' \
--bind='pgup:preview-page-up' \
--bind='enter:execute:git show --color=always {2} | less -R' \
--bind='ctrl-x:execute:git checkout {2} .'