Skip to content

Instantly share code, notes, and snippets.

@sebm
sebm / tidbits.js
Created September 12, 2016 17:16
tidbits
// iterate over a NamedNodeMap
Array.prototype.map.call(attributes, attr => `${attr.nodeName} = ${attr.nodeValue}` )
object Sequence {
def main(args: Array[String]): Unit = {
val REFRESH = 100
val ROCKET = "\uD83D\uDE80"
val EARTH = "\uD83C\uDF0E"
val BOOM = "\uD83D\uDD25"
val MAX_TICKS = 20
while (true) {
var ticks = 0
@sebm
sebm / slate
Created October 30, 2015 05:43
My .slate config file
config defaultToCurrentScreen true
config nudgePercentOf screenSize
config resizePercentOf screenSize
bind space:shift;cmd grid 0:3,1
@sebm
sebm / proxy.js
Created July 9, 2013 19:01
A local HTTPS proxy. Prereq: `npm install http-proxy`; `openssl req -new -x509 -keyout key.pem -out cert.pem -days 365 -nodes`
var fs = require('fs'),
http = require('http'),
https = require('https'),
httpProxy = require('http-proxy');
var options = {
https: {
key: fs.readFileSync('key.pem', 'utf8'),
cert: fs.readFileSync('cert.pem', 'utf8')
}
@sebm
sebm / git-tree
Created May 17, 2013 19:19
git-tree. my preferred way to see my git…tree… put it in ur ~/.bin or whatever
git log --oneline --decorate --all --graph
@sebm
sebm / .zshrc
Created April 1, 2013 21:50 — forked from SlexAxton/.zshrc
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else
@sebm
sebm / .bash_profile.excerpt
Created October 26, 2012 19:34
some bash stuff
set_prompt_style () {
local bldpur='\e[1;35m' # Purple
local bldblu='\e[1;34m' # Blue
local bldblk='\e[1;30m' # Black - Bold
local bldred='\e[1;31m' # Red
local txtrst='\e[0m' # Text Reset
# local bashuser="\[$bldpur\]\u@\[$txtrst\]" # username
local bashhost="\[$bldpur\]\h\[$txtrst\]" # hostname
local bashdir="\[$bldblu\]\w\[$txtrst\]" # directory
local bashprompt="\[$bldblk\]: \[$txtrst\]" # prompt symbol
@sebm
sebm / processing.altered.js
Created June 25, 2012 02:30
Processing.js v1.3.6 but with subpixel points
(function(window, document, Math, undef) {
var nop = function(){};
var debug = (function() {
if ("console" in window) {
return function(msg) {
window.console.log('Processing.js: ' + msg);
};
@sebm
sebm / 1.js
Created May 23, 2012 08:28
JS snippets for my blog post
var wrapper = document.createElement('div');
var outer = document.getElementById('whatever')
var nodes = outer.childNodes;
var elementsWidth = 0;
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].nodeType === Node.ELEMENT_NODE
&& nodes[i].tagName === 'IMG'
) {
elementsWidth += nodes[i].width;
@sebm
sebm / pinmarklet.deobfuscated.js
Created April 12, 2012 17:59
Deobfuscated Pinterest "pin it" button
// deobfuscated from http://assets.pinterest.com/js/pinmarklet.js using http://jsbeautifier.org/
(function (k, m, n, l) {
var a = k[l.k] = {
w: k,
d: m,
n: n,
a: l,
s: {},
f: function () {