Skip to content

Instantly share code, notes, and snippets.

View smt's full-sized avatar

Stephen Tudor smt

View GitHub Profile
@smt
smt / javascript.snippets
Created August 19, 2015 21:36
Dynamic filename-based names in JS snippets (using UltiSnips)
# Use the basename (of the file in which the snippet is invoked) as a sensible
# default for module names. Supports JSX files as well.
global !p
def module_name(name=None):
name = name or 'ModuleName'
s1 = re.sub('\.js(x?)$', '', name)
return ''.join(x.title() for x in re.sub('([A-Z])', r'_\1', s1).split('_'))
endglobal
# Usage:
@smt
smt / bootstrap.sh
Created August 20, 2015 13:23
PTHIELE
#!/bin/bash
SRC_DIRECTORY="$HOME/Developer"
SSH_DIRECTORY="$HOME/.ssh"
ANSIBLE_DIRECTORY="$SRC_DIRECTORY/ansible"
ANSIBLE_CONFIGURATION_DIRECTORY="$HOME/.anthrobasebox"
function pause(){
read -p "$*"
}
@smt
smt / dict_merge.py
Last active May 17, 2016 12:41 — forked from angstwad/dict_merge.py
Recursive dictionary merge in Python
def dict_merge(dct, merge_dct):
""" Recursive dict merge. Inspired by :meth:``dict.update()``, instead of
updating only top-level keys, dict_merge recurses down into dicts nested
to an arbitrary depth, updating keys. The ``merge_dct`` is merged into
``dct``.
:param dct: dict onto which the merge is executed
:param merge_dct: dct merged into dct
:return: None
"""
#!/bin/zsh
# Search for, select, and execute command from history DB using FZF
# Inspired by http://junegunn.kr/2015/04/browsing-chrome-history-with-fzf/
h(){
local sep query
sep='{::}'
query="SELECT cmd, count(*) as frequency
FROM hist
GROUP BY cmd
@smt
smt / gh-whitespace-bookmarklet.txt
Last active May 17, 2024 04:34
GitHub magic query params
javascript:(function(w)%7Bvar%20W%3D1%2CTS%3D4%2Cl%3Dw.location%2Cqs%3Bif(l.search)%7Bqs%3Dl.search.split(\'%3F\')%5B1%5D.split(\'%26\').reduce(function(acc%2Cp)%7Bvar%20kv%3Dp.split(\'%3D\')%3Bacc%5Bkv%5B0%5D%5D%3Dkv%5B1%5D%3Breturn%20acc%7D%2C%7B%7D)%3Bqs.w%3DW%3Bqs.ts%3DTS%3Bl.search%3D\'%3F\'%2B(Object.keys(qs).reduce(function(acc%2Ck)%7Bacc.push(k%2B\'%3D\'%2Bqs%5Bk%5D)%3Breturn%20acc%7D%2C%5B%5D).join(\'%26\'))%7Delse%7Bl.search%3D\'%3Fw%3D\'%2BW%2B\'%26ts%3D\'%2BTS%7D%7D)(window)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""" AUTOCMD """"""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if has('autocmd')
augroup general_buffer
au!
au BufReadPost setlocal nobomb
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
@smt
smt / keybase.md
Created September 13, 2017 19:44

Keybase proof

I hereby claim:

  • I am smt on github.
  • I am smt (https://keybase.io/smt) on keybase.
  • I have a public key ASBHa5U4G25UDGVadQDviLAzjoGWuYApwfodUDkw_F2N8Qo

To claim this, I am signing this object:

@smt
smt / twtxt.txt
Last active May 17, 2024 04:28
twtxt.txt
2017-09-24T02:00:46.000000Z So there I was, minding my own business, when a friend told me of twtxt and I just had to give it a try at least this once.
@smt
smt / beat.sh
Last active May 17, 2024 04:28
#!/bin/sh
# Output the current time in Swatch Internet Time "beats"
# See: https://en.wikipedia.org/wiki/Swatch_Internet_Time
# Example output:
# @811
# Helper conversion function
# @param naive time as HH:MM:SS string
# @param [-c] to include "centibeats"
@smt
smt / checksum.js
Created December 4, 2017 15:22
AoC 2017 - Day 2
function prepare(data) {
return data
.split('\n')
.map(x => x
.split('\t')
.map(Number)
);
}
function findMinMax(nums) {