Skip to content

Instantly share code, notes, and snippets.

View gist:5060209
import numpy
# source data
a = numpy.ones(4000000, dtype=numpy.uint8).reshape((2000,2000))
# make gray RGB image
g = numpy.empty((2000,2000,3))
g[...] = a[..., numpy.newaxis]
# make image width divisable by 4
@shamrin
shamrin / Makefile
Created Apr 3, 2013
Makefile parameters
View Makefile
test:
# Usage:
# $ make test TEST="grep pattern"
ifdef TEST
env TESTING=1 mocha --compilers coffee:coffee-script -u tdd -g "$(TEST)"
else
env TESTING=1 mocha --compilers coffee:coffee-script -u tdd
endif
@shamrin
shamrin / gist:5438127
Created Apr 22, 2013
Short extract from my CoffeeScript code
View gist:5438127
for k, v of changes when (a = v?.attrs)?
@$("##{k}").toggle(a.visible) if a.visible?
@$("##{k}").val(a.value) if a.value?
View reg_exp_matcher.py
def match(pattern,text):
if pattern[0] == '^':
return match_here(pattern[1:], text)
if match_here(pattern,text):
return 1
while text:
if match_here(pattern,text):
return 1
View gist:6905324
vagrant@precise64:~/eql$ docker ps -a
ID IMAGE COMMAND CREATED STATUS PORTS
5b18395ceac1 eqldata/debian:7.1 echo hi 2 seconds ago Exit 0
2a2ea0377136 86bda7d967b5 /bin/sh -c cd hellof 12 minutes ago Exit 0
0de396b19d2b 63efc39a7dc9 /bin/sh -c curl -L h 12 minutes ago Exit 0
225e55a69991 cb7f7c6e4fed /bin/sh -c DEBIAN_FR 13 minutes ago Exit 0
f4c6371b8ab6 e375ce73b4bd /bin/sh -c pip insta 14 minutes ago Exit 0
331dd5795693 a81178ba41a2 /bin/sh -c DEBIAN_FR 19 minutes ago Exit 0
cf10f5e776c6 6a73ebd3d20d /bin/sh -c DEBIAN_FR 20 minutes ago Exit 0
18c136903694 eqldata/debian:7.1 /bin/sh -c apt-get u 20 minutes ago Exit 0
View supertee
#!/usr/bin/env bash
NLINES=2
IFS='' # force `read line` to take whole lines
LOG_PREFIX=$1
if test X$LOG_PREFIX = X; then
echo usage: $0 "<log-prefix>"
exit 1
fi
View log
$ ansible-playbook test.yml -vvv
...
TASK: [test local_action] *****************************************************
<127.0.0.1> ESTABLISH CONNECTION FOR USER: root
<127.0.0.1> EXEC ['ssh', '-tt', '-q', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/Users/shamrin/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=22', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=root', '-o', 'ConnectTimeout=10', '127.0.0.1', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-1382536397.51-53312772033838 && chmod a+rx $HOME/.ansible/tmp/ansible-1382536397.51-53312772033838 && echo $HOME/.ansible/tmp/ansible-1382536397.51-53312772033838'"]
fatal: [146.185.147.233] => Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the remote directory. Consider changing the remote temp path in ansible.cfg to a path rooted
View error.markdown

For some reason docker rmi IMAGEID happily removed all my images:

vagrant@precise64:~$ docker tag my/debian:assembled_dev my/debian assembled-dev
vagrant@precise64:~$ docker images
REPOSITORY          TAG                       ID                  CREATED             SIZE
my/debian     assembled-dev             8d88e4d2c171        28 minutes ago      1.052 GB (virtual 2.171 GB)
my/debian     assembled_dev             8d88e4d2c171        28 minutes ago      1.052 GB (virtual 2.171 GB)
my/debian     assembled                 df810f2b0bfb        13 days ago         17.44 MB (virtual 2.501 GB)
my/debian     assembled-fix-DATA-perm   df810f2b0bfb        13 days ago         17.44 MB (virtual 2.501 GB)
View gist:7224865

I've deployed private Docker registry under reverse proxying nginx (with basic auth). But pushing to it doesn't work:

$ docker push my-server.com/repo
2013/10/29 23:58:08 Invalid Registry endpoint: This does not look like a Registry server ("X-Docker-Registry-Version" header not found in the response)

Testing the server with curl:

$ curl -i --user me:password my-server.com | grep X-Docker
X-Docker-Registry-Version: 0.6.2
X-Docker-Registry-Config: dev
View gist:9692625
#!/bin/sh
git filter-branch --env-filter '
an="$GIT_AUTHOR_NAME"
am="$GIT_AUTHOR_EMAIL"
cn="$GIT_COMMITTER_NAME"
cm="$GIT_COMMITTER_EMAIL"
if [ "$GIT_COMMITTER_EMAIL" = "root@ubuntu.(none)" ]