Skip to content

Instantly share code, notes, and snippets.

@shamrin
shamrin / gist:5438127
Created April 22, 2013 20:16
Short extract from my CoffeeScript code
for k, v of changes when (a = v?.attrs)?
@$("##{k}").toggle(a.visible) if a.visible?
@$("##{k}").val(a.value) if a.value?
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
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
@shamrin
shamrin / supertee
Last active December 25, 2015 12:39
#!/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
@shamrin
shamrin / log
Last active December 26, 2015 07:59
$ 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

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)

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

Geolocation accuracy

Summary of the API major platforms provide regarding geolocation and its accuracy.

Platform Coordinates accuracy Altitude accuracy Confidence interval Invalid value
Web Coordinates.accuracy Coordinates.altitudeAccuracy 95% null (but coordinates accuracy is always available)
Android getAccuracy() no 68% 0.0
iOS horizontalAccuracy verticalAccuracy not defined < 0
@shamrin
shamrin / gist:249628d867d955133987
Created January 21, 2016 10:35
twitter-text.js size
$ curl -s https://raw.githubusercontent.com/twitter/twitter-text/master/js/twitter-text.js | uglifyjs | gzip | wc -c
14988
$ curl -s https://raw.githubusercontent.com/twitter/twitter-text/master/js/twitter-text.js | uglifyjs | wc -c
40295
$ curl -s https://raw.githubusercontent.com/twitter/twitter-text/master/js/twitter-text.js | gzip | wc -c
19747
$ curl -s https://raw.githubusercontent.com/twitter/twitter-text/master/js/twitter-text.js | wc -c
62616
@shamrin
shamrin / SuperTimer.elm
Last active February 14, 2016 16:12
Restartable timer
module SuperTimer where
import Html exposing (..)
import Html.Events exposing (onClick)
import Time exposing (Time)
import Signal exposing (Address)
type Action = Tick Time | Toggle Bool
type alias Model = { running: Bool, count: Float}