Skip to content

Instantly share code, notes, and snippets.

@DannyDelott
DannyDelott / jsbin.js
Last active December 8, 2017 22:30
map.setStyle instead of addLayer/addSource
/****************************************************************
* Setting root-level styles *
* See: https://www.mapbox.com/mapbox-gl-js/style-spec/#root *
* JSBIN: https://jsbin.com/qazosufoge/1/edit?js,console,output *
****************************************************************/
mapboxgl.accessToken = 'pk.eyJ1IjoiaGVsbG8tY2EiLCJhIjoiY2lyaTdmdjNwMDF5eWc2bnJzM29rajAycyJ9.V-d5lBQ8iQ_n-vpvJ_RSIA';
var statesSource = {
'type': 'geojson',
#!/bin/bash
red=$'\e[1;31m'
grn=$'\e[1;32m'
yel=$'\e[1;33m'
blu=$'\e[1;34m'
mag=$'\e[1;35m'
cyn=$'\e[1;36m'
end=$'\e[0m'
var sum = 0;
var add5Async = () => {
return setTimeoutAsync(1000)
.then(add5.bind(null, sum)) // pure function, bind global variable as input
.then(setSum); // side-effect at the end
};
asyncReduce([ add5Async, add5Async, add5Async ])
.then(() => { console.log('sum:', sum); })
@DannyDelott
DannyDelott / pre-commit.sh
Last active April 12, 2016 21:22
Pre-commit hook
#!/bin/sh
for staged_file in $(git diff --cached --name-only)
do
if [[ "$staged_file" == *\.js$* ]] && [ -f "$staged_file" ]; then
./node_modules/jscs/bin/jscs "$staged_file"
if [[ "$?" != "0" ]]; then
exit 1
fi
fi
@DannyDelott
DannyDelott / tmux.config
Last active February 3, 2016 16:56
usr/local/etc/tmux.config -> `tmux source usr/local/etc/tmux.config`
# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %
@DannyDelott
DannyDelott / .gitconfig
Created January 30, 2016 01:33
prettty_git-hist
#Add to ~/.gitconfig
[alias]
hist = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
@DannyDelott
DannyDelott / comparesemvar.sh
Last active January 21, 2016 18:17
compare semvar bash
#!/bin/bash
vercomp () {
if [[ $1 == $2 ]]
then
return 0
fi
local IFS=.
local i ver1=($1) ver2=($2)
# fill empty fields in ver1 with zeros
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
@DannyDelott
DannyDelott / gist:5767e3083fd0cdce7226
Created January 1, 2016 03:29
how to ignore tracked files
Source: http://stackoverflow.com/questions/10879783/git-doesnt-ignore-2-specifically-named-files/10881296#comment14178464_10879783
What you want to is to ignore changes on tracked files. This cannot achieved (as Charles Bailey says) correctly, neither with .gitignore nor with .git/info/exclude.
You'll need to use git update-index:
git update-index --assume-unchanged build/conf/a.conf
git update-index --assume-unchanged build/conf/b.conf
will achieve what you want: the files are always assumed unchanged.
@DannyDelott
DannyDelott / .vimrc
Last active June 15, 2016 22:45
Should work out of the box, just install Vundle (except for YCM)
set nocompatible " be iMproved
au FocusGained,BufEnter * :silent! !
au FocusLost,WinLeave * :silent! w
" so $HOME/.vim/plugin/vundle.vim
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Auto load changes to vimrc to vim
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
augroup myvimrc
@DannyDelott
DannyDelott / server.js
Created May 29, 2015 07:26
Simple node server
/* *****************
* Require Imports *
* *****************/
var express = require('express');
var path = require('path');
/* ***********************
* Initialize Middleware *
* **********************/