Skip to content

Instantly share code, notes, and snippets.

View munhitsu's full-sized avatar

Mateusz Łapsa-Malawski munhitsu

  • cr3.io
  • London, UK
View GitHub Profile
@munhitsu
munhitsu / gist:c0d0bff53ad5219818cd
Created March 4, 2016 17:55
wait for postgresql (i.e. within docker container)
until nc -z ${POSTGRES_PORT_5432_TCP_ADDR} ${POSTGRES_PORT_5432_TCP_PORT}; do
echo "$(date) - waiting for postgres..."
sleep 1
done
brew install swig
env LDFLAGS="-L$(brew --prefix openssl)/lib" \
CFLAGS="-I$(brew --prefix openssl)/include" \
SWIG_FEATURES="-cpperraswarn -includeall -I$(brew --prefix openssl)/include" \
pip install m2crypto
@munhitsu
munhitsu / gist:a5fb0fa2b49897884987
Last active January 22, 2016 15:48
where to go in Poland
Kraków - university city - ex-capital - where I lived for 13 years
a trip to Auschwitz - difficult but worth
a trip to Wieliczka - picturesque salt mine with loads of salt sculptures, and underground salt church
restaurant - Jarema - for properly made traditional food
Wrocław - smaller, just charming - plenty of German architecture influences
beautiful walks over riverbanks
Gdańsk - the oldest, and the most important port city - go to the old town - german/danish, influence
#check logs
curl http://localhost:9200/_cluster/health?pretty
curl http://localhost:9200/_cat/indices?v
curl http://localhost:9200/_cat/nodes?v
curl http://localhost:9200/_cat/shards?v
curl localhost:9200/_nodes/process?pretty
@munhitsu
munhitsu / gist:5153686
Created March 13, 2013 16:14
How to confirm if gevent monkey patch works
from gevent import socket as g_socket
assert g_socket.timeout == socket.timeout
print "gevent monkey patch for socket confirmed"
@munhitsu
munhitsu / gist:5118993
Last active December 14, 2015 16:59
slightly crazy universal base encoder (number to alphabet)
BASE_ALPHABET = "123456789abcdefghijkmnopqrstuvwxyz"
def encode_base_x(n):
base = len(BASE_ALPHABET)
def chars(num):
while num >= base:
num, mod = divmod(num, base)
yield BASE_ALPHABET[mod]
@munhitsu
munhitsu / gist:5089739
Created March 5, 2013 11:42
virtualbox mount shared host folder
mkdir -p /mnt/shared
mount -t vboxsf -o uid=1000,gid=1000 shared /mnt/shared
@munhitsu
munhitsu / gist:5064293
Created March 1, 2013 12:22
class SchrodingerUser :)
class SchrodingerUser(AnonymousUser):
"""
Imagine that you are making the experiment and want to measure your results.
But Greenpeace has just came to the office and claims that 50% of cats life
is better for the cat than certain life or death.
Returned on DB access error.
"""
pass
@munhitsu
munhitsu / gist:5056212
Created February 28, 2013 11:50
demo of context manager and loop break/continue behaviour
class DebugContext(object):
def __init__(self):
print self.__class__, "init"
def __enter__(self):
print self.__class__, "enter"
def __exit__(self, type, value, traceback):
@munhitsu
munhitsu / gist:c74b3f627066392a1fb4
Last active October 29, 2015 12:32
NTP debugging/config aws context
# recommended ntp pool (/etc/ntp.conf)
server 0.amazon.pool.ntp.org iburst
server 1.amazon.pool.ntp.org iburst
server 2.amazon.pool.ntp.org iburst
server 3.amazon.pool.ntp.org iburst
ntpq
> peers
check for connection prefixed with *
> as