assumption: your format.pretty
begins with %h
, eg. format:%h %s (%an, %ad)
.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rows_all = document.getElementsByTagName("table")[4].children[0].children | |
var rows = Array.prototype.slice.call(rows_all, 2) | |
var rows_data = rows.map(function(row) { return Array.prototype.map.call(row.children, function(c, i) { var v = c.innerText; return i===2 ? v.replace("\n"," ") : v }) }) | |
// poor man's csv - doesn't handle values with the delimiter itself! | |
console.log(rows_data.map(function(c) { return c.join(",") }).join("\n")) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# produce lines like | |
# | |
# mv "./IMG_8869.jpg" "2015-03-29_19-08-01_IMG_8869.jpg" | |
# | |
find \( -name 'DSC_*' -or -name 'IMG_*' -or -name 'GOPR*' \) -and -iname '*.jpg'\ | |
| while read x; do\ | |
echo mv \"$x\" \"$(exif --tag='Date and Time (Original)' -m "$x" | sed -e 's/:/-/g' -e 's/ /_/')_${x#./}\"; done >foo | |
# try one line first | |
awk NR==1 foo | sh -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LocalsTracker(object): | |
def __enter__(self): | |
self._locals = locals() | |
def __exit__(self): | |
locals_now = locals() | |
# compute diff between locals_now and self.locals... | |
def foo(): | |
a = 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
// Reads JSON from stdin, and runs a JSONPath expression from the command-line on it. | |
// | |
// eg. | |
// $ npm install # install dependencies | |
// $ echo '{"store": {"book":[{"category":"fiction"}]}}' | node jsonpath.js '$.store.book[0].category' | |
// fiction | |
var stdin = process.stdin, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var browserify = require('browserify'); | |
var JSONStream = require('JSONStream'); | |
var through = require('through2'); | |
var b = browserify({basedir: __dirname, entries: ['./main.js']}) | |
b.deps({}) | |
.pipe(through({objectMode: true}, function(chunk, enc, cb) { | |
// poor man's _.omit() | |
var o = {}; | |
for (var prop in chunk) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(["lib/play-manager"], function(a) { | |
// via http://stackoverflow.com/a/6274381 | |
//+ Jonas Raoni Soares Silva | |
//@ http://jsfromhell.com/array/shuffle [v1.0] | |
function shuf(o) { for(var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x); } | |
shuf(a.source.models); | |
var c = a.getCurrentSound(), p = c ? c.isPaused() : false; | |
a.playNext(); a.playPrev(); // poor man's refresh of current playing song | |
if (p) a.pause(c); // preserve first-run state |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import soundcloud | |
import random | |
import socket | |
import subprocess | |
SOUNDCLOUD_API_KEY = '00000000000000000000000000000000' | |
PLAYLIST_URL = 'https://soundcloud.com/nervomusic/sets/nervomusic-com' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let (|>) v f = f v;; | |
let string_of_char_list (ls : char list) : string = | |
let s = String.make (List.length ls) '0' in | |
List.fold_left (fun i c -> s.[i] <- c; i+1) 0 ls; | |
s;; | |
let append_string (xs : string list) (ls : char list) : string list = | |
let s = string_of_char_list ls in | |
if String.length s = 0 then xs else (xs @ [s]);; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node(object): | |
prev = None | |
next = None | |
value = None | |
def __init__(self, prev, value): | |
self.value = value | |
self.appendTo(prev) | |
def unlink(self): |