Skip to content

Instantly share code, notes, and snippets.

View DanielFGray's full-sized avatar

Daniel Gray DanielFGray

View GitHub Profile
#!/usr/bin/env node
var modes = ['Ionian', 'Dorian', 'Phrygian', 'Lydian', 'Mixolydian', 'Aeolian', 'Locrian'];
var steps = [2, 2, 1, 2, 2, 2, 1];
var notes = ['C', 'C#/Db', 'D', 'D#/Eb', 'E', 'F', 'F#/Gb', 'G', 'G#/Ab', 'A', 'A#/Bb', 'B'];
var noteRoots = ['C', 'D', 'E', 'F', 'G', 'A', 'B'];
function getNotes(scale, mode) {
if(mode === 'Major') {
mode = 'Ionian';
@DanielFGray
DanielFGray / v
Created May 28, 2015 03:49
create a new vim server or interact with an existing one - http://a.pomf.se/sefqyu.webm
#!/usr/bin/env bash
usage() {
cat <<'HELP'
v [OPTIONS] [FILES]
create a new vim server or interact with an existing one
-h show this help
-d disable focusing on vim
-s associate tmux pane in vim
"use strict";
var gulp = require("gulp"),
sourcemaps = require("gulp-sourcemaps"),
babel = require("gulp-babel"),
concat = require("gulp-concat"),
uglify = require("gulp-uglify"),
rename = require("gulp-rename"),
del = require("del");
@DanielFGray
DanielFGray / fv
Last active August 29, 2015 14:24
#!/usr/bin/env bash
usage() {
cat <<'HELP'
-s string to search
-t list only text files
-c command to execute [defaults to vim]
HELP
}
function! PromptQuit()
echo 'close current buffer?'
if nr2char(getchar())=~'y'
silent execute "normal \<esc>:Sayonara!\<cr>"
elseif nr2char(getchar())=~'Y'
silent execute "normal \<esc>:Sayonara\<cr>"
endif
silent! redraw!
endfunction
nnoremap <silent> Q <Esc>:call PromptQuit()<CR>
#!/usr/bin/env bash
has() {
command -v $1 &> /dev/null
}
err() {
echo -e "\e[31m$1\e[0m" >&2
}
#!/usr/bin/env bash
declare file="$(date +%F-%s).webm"
declare window=false
declare region=false
declare duration
declare delay=0
declare verbose
declare -A dimensions
@DanielFGray
DanielFGray / collatz.js
Last active February 26, 2016 05:49
collatz conjecture
#!/usr/bin/env node
'use strict';
const range = function(start, stop) {
return Array.apply(null, { length: 1 + stop - start })
.map((v, i) => start + i);
};
const collatz = function(n, len) {
let steps = [];
@DanielFGray
DanielFGray / pkgsearch.sh
Last active December 6, 2018 15:57
package searching and installing with https://github.com/junegunn/fzf
#!/usr/bin/env bash
declare esc=$(printf '\033')
declare c_reset="${esc}[0m"
declare c_red="${esc}[31m"
declare c_green="${esc}[32m"
declare c_blue="${esc}[34m"
err() {
echo -e "${c_red}$@${c_reset}" >&2
#!/usr/bin/env node
'use strict';
const runlength = {};
runlength.decode = function(str) {
return str.match(/\d*\w/g)
.reduce((prev, curr) =>
prev + (curr.length > 1
? curr.slice(-1)