Skip to content

Instantly share code, notes, and snippets.

View lelandbatey's full-sized avatar

Leland Batey lelandbatey

View GitHub Profile
@adamryman
adamryman / ag-replace.sh
Created October 31, 2016 23:02
`ag -Qs "THIS"`, I want to replace all occurrences of "THIS" with "THAT". `Just do ag-replace "THIS" THAT"`
#!/bin/bash
usage() {
echo "Usage: $(basename $0) \"THIS\" \"THAT\"";
echo "Outputs files modified"
exit 1;
}
replace() {
@yosifkit
yosifkit / git-diff-process-substitution.patch
Last active February 17, 2022 19:20
dev-vcs/git-2.4.10 patch for git diff to work for process substitution: `$ git diff --color-words <(echo a b c) <(echo a d c)`
diff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt
index bbab35f..f4ca476 100644
--- a/Documentation/git-diff.txt
+++ b/Documentation/git-diff.txt
@@ -99,10 +99,17 @@ include::diff-options.txt[]
<path>...::
The <paths> parameters, when given, are used to limit
the diff to the named paths (you can give directory
names and get diff for all files under them).
@simonw
simonw / gist:7000493
Created October 15, 2013 23:53
How to use custom Python JSON serializers and deserializers to automatically roundtrip complex types.
import json, datetime
class RoundTripEncoder(json.JSONEncoder):
DATE_FORMAT = "%Y-%m-%d"
TIME_FORMAT = "%H:%M:%S"
def default(self, obj):
if isinstance(obj, datetime.datetime):
return {
"_type": "datetime",
"value": obj.strftime("%s %s" % (