Skip to content

Instantly share code, notes, and snippets.

@dansimau
dansimau / README.md
Last active December 19, 2015 07:19
Python module for accessing data structures using JSON-like notation.
@dansimau
dansimau / tsv-to-excelcsv.py
Created November 22, 2013 14:25
Convert TSV to CSV.
import sys
import csv
tsvin = csv.reader(sys.stdin, dialect=csv.excel_tab)
csvout = csv.writer(sys.stdout, dialect=csv.excel)
for row in tsvin:
# Force all fields to be string-based (Excel specific)
for i, val in enumerate(row):
row[i] = '="%s"' % val
csvout.writerow(row)
#!/bin/bash
# Get last argument as the base filename
file=${!#}
if [ "$file" == "--version" ]; then
python --version
exit $?
fi
class DirtyBase(object):
def __init__(self, *a, **k):
super(DirtyBase, self).__init__(*a, **k)
self.dirty = False
def __setitem__(self, *a, **k):
self.mark_dirty()
super(DirtyBase, self).__setitem__(*a, **k)
@dansimau
dansimau / git-mc.sh
Created February 6, 2014 10:37
git helper script to quickly edit and resolve merge conflicts. See usage: https://gist.github.com/dansimau/8841861#comment-1000517
#!/bin/bash
#
# Helper script to quickly fix merge conflicts.
#
# dan@dans.im
# 2014-02-05
#
#
@dansimau
dansimau / LICENSE
Last active March 11, 2016 13:25 — forked from jamesarosen/git-merge-button.md
GitHub's Merge Button™ from the command line
Copyright (c) 2016 Daniel Simmons
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
@dansimau
dansimau / foo.go
Created April 11, 2016 14:31
mockery generation test
package foo
type FooInterface interface {
FooFunc()
}
@dansimau
dansimau / go-get-version.sh
Last active November 14, 2016 17:54
Like `go get`, but specify a commit ref in the package spec
#!/bin/bash
#
# Same as `go get` but you can specify a git commit ref.
#
set -e
#
# Resolve the path to the Go workspace from GOPATH.
#
_go_workspace() {
@dansimau
dansimau / colourpicker.scpt
Created August 5, 2012 15:40
A colour picker app for Mac OS X
set the RGB16bit_list to (choose color)
-- convert choosen color to HEX
set the formatedColor to my RBG_to_HEX(RGB16bit_list)
set the clipboard to formatedColor
display dialog "HEX colour value (" & formatedColor & ") has been copied to the clipboard." with icon 1 buttons {"Dismiss"} default button {"Dismiss"} giving up after 10
on RBG_to_HEX(RGB_values)
-- this subroutine was taken from "http://www.apple.com/applescript/sbrt/sbrt-04.html"
set the hex_list to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
@dansimau
dansimau / go-test-pretty.sh
Created April 10, 2017 07:49
Run `go test`, only displaying error output, plus print counts of all tests passed/failed/etc.
#!/bin/bash
#
# Runs `go test -v`, parses the output and only displays errors. Also displays
# a summary of tests passed/failed/skipped/etc.
#
set -o pipefail
declare buffer=
declare test_error=false