Skip to content

Instantly share code, notes, and snippets.

@nduhamel
nduhamel / readonlydict.py
Created December 20, 2010 20:48
Simple Read-only dict python
import UserDict
class ReadOnlyDict(UserDict.IterableUserDict):
def __setitem__(self, key, item): raise TypeError
def __delitem__(self, key): raise TypeError
def clear(self): raise TypeError
def pop(self, key, *args): raise TypeError
def popitem(self): raise TypeError
def update(self, dict=None):
@masak
masak / explanation.md
Last active June 19, 2025 13:01
How is git commit sha1 formed

Ok, I geeked out, and this is probably more information than you need. But it completely answers the question. Sorry. ☺

Locally, I'm at this commit:

$ git show
commit d6cd1e2bd19e03a81132a23b2025920577f84e37
Author: jnthn <[email protected]>
Date:   Sun Apr 15 16:35:03 2012 +0200

When I added FIRST/NEXT/LAST, it was idiomatic but not quite so fast. This makes it faster. Another little bit of masak++'s program.

@dmitshur
dmitshur / gist:6927554
Last active December 29, 2024 12:06
[Legacy GOPATH mode] How to `go get` private repos using SSH key auth instead of password auth.
@Kartones
Kartones / postgres-cheatsheet.md
Last active July 17, 2025 06:54
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@marians
marians / CouchDB_Python.md
Last active June 14, 2025 02:00
The missing Python couchdb tutorial

This is an unofficial manual for the couchdb Python module I wish I had had.

Installation

pip install couchdb

Importing the module

@olih
olih / jq-cheetsheet.md
Last active July 14, 2025 03:46
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq

@xiongchiamiov
xiongchiamiov / why.sh
Last active March 14, 2023 04:19
Use this when Amazon gives you an "Encoded authorization failure message" and you need to turn it into something readable. If you only get a request id... you're out of luck.
function decode-authorization-failure-message {
if [ $# -ne 1 ] || [ "$1" = -h ] || [ "$1" = --help ]; then
cat <<'EOT'
Usage: decode-authorization-failure-message <message>
Use this when Amazon gives you an "Encoded authorization failure message" and
you need to turn it into something readable.
EOT
return 1
fi
@meresmclr
meresmclr / setup_gnuparallel.sh
Last active August 29, 2024 23:10
Install GNU Parallel on any system including Cygwin
#!/bin/bash
# useful for platforms such as Cygwin that don't currently have GNU Parallel in their repo.
# prerequisite: make
(
wd=$(mktemp -d)
wget -nc -P $wd ftp://ftp.gnu.org/gnu/parallel/parallel-latest.tar.bz2
cd $wd
@gr1ev0us
gr1ev0us / find.sh
Last active April 22, 2025 05:25
Cheatsheet for find linux
# List of cheatsheet for linux find.
# Taken from here http://alvinalexander.com/unix/edu/examples/find.shtml
# basic 'find file' commands
# --------------------------
find / -name foo.txt -type f -print # full command
find / -name foo.txt -type f # -print isn't necessary
find / -name foo.txt # don't have to specify "type==file"
find . -name foo.txt # search under the current dir
find . -name "foo.*" # wildcard