Skip to content

Instantly share code, notes, and snippets.

@tripleee
tripleee / jqs.sh
Created August 11, 2016 07:28
Transform JSONS (one JSON fragment per line) to serialized JSON, somewhat like jq -s
# Add to your .bash_profile or similar
jqs () { sed '1s/^/[/;$!s/$/,/;$s/$/]/' "${@--}"; }
.net
accessibility-api
actionscript
actionscript-3
ajax
alljoyn
applescript
android
android-ndk
android-sdk* # android-sdk-2.1 android-sdk-2.2 android-sdk-2.3 android-sdk-tools
// Consecutive, leave early on validation failure
// ... assuming abort(); leaves the current block (function, or even program)
if (function1(param) == 1)
abort();
// else
dostuff1();
if (function2(param) == 2)
abort();
// else
@tripleee
tripleee / gist:2a4dc7781621d135ef987e53801da162
Created April 21, 2016 05:49
Python regex Unicode equivalents
# http://stackoverflow.com/questions/36715487/finding-%C3%BC-u-with-umlaut-using-regular-expressions/36716670#comment61099969_36716670
>>> import re, regex
>>> print re.__version__
2.2.1
>>> print regex.__version__
2.4.94
>>> pair = (u'f\u00fcr', u'fu\u0308r')
>>> for s in [re, regex]:
... for i,j in [(0, 1), (1, 0), (0,0), (1,1)]:
... if s.match(pair[i], pair[j], s.UNICODE):
@tripleee
tripleee / days.bash
Created December 18, 2015 09:33
days.bash
# Put this in your .bashrc or similar
# Requires GNU date for -d @epoch and +%F/+%s
days () {
local now=$(date +%s);
local d;
for ((d=$(date -d "$1" +%s); d < now; d += 24*60*60)); do
date -d @"$d" +%F;
done ;
}
@tripleee
tripleee / dygraphs.md
Last active December 17, 2015 10:31
dygraphs devel notes
@tripleee
tripleee / printable.el
Created December 2, 2015 06:32
Convert control and high-bit characters to printable (^A; \234)
(while (search-forward-regexp "[\000-\011\013-\037\200-\377]" nil t)
(let ((c (string-to-char (match-string 0))))
(backward-delete-char 1)
(insert
(if (< c 128)
(concat "^" (char-to-string (+ 64 c)))
(format "\\%03o" c) )) ))
@tripleee
tripleee / aquamacs.el
Last active November 6, 2015 12:05
Customizations for Aquamacs
;(tool-bar-mode -1) ;; Not just Aquamacs -- everywhere, always
(tabbar-mode -1)
;; http://www.emacswiki.org/emacs/AquamacsFAQ#toc19
(one-buffer-one-frame-mode -1)
;; http://www.emacswiki.org/emacs/AquamacsEmacsCompatibilitySettings
(setq special-display-regexps nil
ns-alternate-modifier nil) ;; Don't use Alt for Meta
;; Add MELPA for magit, and probably others in the future
(eval-after-load "package"
'(add-to-list 'package-archives
@tripleee
tripleee / ansi-term-select-or-create.el
Created August 27, 2015 12:17
ansi-term wrapper to make it behave like regular M-x shell when invoking
(defun ansi-term-select-or-create ()
"Switch to the `*ansi-term*' buffer if it already exists; if not, create it
first."
(interactive)
(switch-to-buffer (or (get-buffer "*ansi-term*") (ansi-term "/bin/bash"))))
@tripleee
tripleee / dotfiles.sh
Last active August 29, 2015 14:26
Download dotfiles from gists
#!/bin/sh
case $1 in -v) set -- -nv ;; *) set -- -q ;; esac
u=https://gist.githubusercontent.com/tripleee
while read dest id source; do
destname=${dest#dot.}
case $destname in "$dest") ;; *) destname=.$destname;; esac
wget -O "$destname" $1 -p "$u/$id/raw/"
done <<'____HERE'