Skip to content

Instantly share code, notes, and snippets.

View DanielFGray's full-sized avatar

Daniel Gray DanielFGray

View GitHub Profile
'use strict';
function validISBN10(isbn) {
if(! /\d{9}[X0-9]/.test(isbn)) return false;
return isbn.split('').reduce((p, c, i) => {
return p + ((c == 'X') ? 10 : parseInt(c)) * ++i;
}, 0) % 11 == 0;
}
(function (func, cases, invert) {
#!/usr/bin/env bash
# DanielFGray 2016
# https://gist.github.com/d47925487840bb445296
err() {
local c_red="${esc}[31m"
echo -e "${c_red}$1${c_reset}" >&2
}
#!/usr/bin/env node
'use strict';
// http://www.codewars.com/kata/53db4acb1f1a7dd68700040a/train/javascript
function canReach(from, to, movements) {
//FIXME: attempt in multiple moves
const offset = [ Math.abs(from[0] - to[0]), Math.abs(from[1] - to[1]) ];
const valid_offsets = [ [1, 2], [2, 1] ];
return valid_offsets.some(o => {
@DanielFGray
DanielFGray / discover.vim
Last active April 19, 2016 00:04
[really] poor proof-of-concept [spac]emacs which-key port to vim | demo https://upload.teknik.io/8olPd.webm
" If you want to test this, save it somewhere, open in vim, `:so %`.
" Slowly type <leader>g andand g-commands should happen in the other buffer.
" In the demo webm above, I just slowly typed `<leader>gJ`
" I only added descriptions for a few commands but others should work
" Needs massive re-working to actually be maintainable
" WHY:
" Vim is an amazing tool, but one of it's few weaknesses is discoverability.
" While it's great to have a tool that you can continually learn new things about,
" learning those things would ideally happen sooner than later. Spacemacs ships with "which-key"
module.exports = {
files: {
javascripts: {
joinTo: {
'vendor.js': /^(?!app)/,
'app.js': /^app/
}
},
stylesheets: {joinTo: 'app.css'}
},
@DanielFGray
DanielFGray / workspaces.sh
Last active August 19, 2016 19:50
wm agnostic workspace indicator
#!/usr/bin/env bash
declare activeWorkspace="*%s"
declare inactiveWorkspace=" %s"
declare separator=" │ "
xprop -spy -root |
awk -v inactiveWorkspace="$inactiveWorkspace" \
-v activeWorkspace="$activeWorkspace" \
-v separator="$separator" -F' = ' '
#!/usr/bin/env bash
cleanup() {
tput cnorm > /dev/tty
stty "$_stty" <> /dev/tty
}
_stty=$(stty -g < /dev/tty)
trap cleanup exit SIGTERM SIGQUIT
menu() {

Keybase proof

I hereby claim:

  • I am danielfgray on github.
  • I am danielfgray (https://keybase.io/danielfgray) on keybase.
  • I have a public key ASCGfXdCDEBGUKknNv9tGvObZXRnhwelTsPy_7dQGr5K-Ao

To claim this, I am signing this object:

@DanielFGray
DanielFGray / index.php
Created March 20, 2017 19:34
scratchpad thing
<!DOCTYPE html>
<html lang="en">
<head>
<title>scratchpad</title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link type="text/css" rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css" media="all" />
<link type="text/css" rel="stylesheet" href="style.css" media="all" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="marked.min.js"></script>
@DanielFGray
DanielFGray / webpack.config.js
Last active March 29, 2017 21:39
webpack.config.js
/* eslint-disable import/no-extraneous-dependencies */
const path = require('path')
const webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const babelOpts = {
test: /\.jsx?$/,
exclude: /node_modules/,
use: [