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:1034897
Created June 19, 2011 23:25
10.6: Completely Disable Virtual Memory in Snow Leopard
#source: http://hints.macworld.com/article.php?story=201106020948369
#disable
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist
#enable
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist
@munhitsu
munhitsu / gist:1276768
Created October 10, 2011 22:29
buildout.cfg for gevent & libevent
[buildout]
extensions = buildout.dumppickedversions
parts =
libevent
gevent
[gevent]
recipe = zc.recipe.egg:custom
include-dirs = ${libevent:location}/include
library-dirs = ${libevent:location}/lib
@munhitsu
munhitsu / buildout-haystack.cfg
Created October 31, 2011 22:22
django-haystack xapian buildout recipe
[django-haystack]
location = django-haystack
recipe = zerokspot.recipe.git
repository = https://github.com/toastdriven/django-haystack.git
[xapian-haystack]
location = xapian-haystack
recipe = zerokspot.recipe.git
repository = https://github.com/notanumber/xapian-haystack.git
@munhitsu
munhitsu / wsgi_simple_server_post.py
Created January 12, 2012 15:48
Simple WSGI application that handles POST - for testing/debuging of PROXY
from wsgiref.util import setup_testing_defaults, FileWrapper
from wsgiref.simple_server import make_server
import sys
from pprint import pprint
# A relatively simple WSGI application. It's going to print out the
# environment dictionary after being updated by setup_testing_defaults
def simple_app(environ, start_response):
setup_testing_defaults(environ)
@munhitsu
munhitsu / gist:2417488
Created April 19, 2012 00:14
osm-bright-mac-quickstart
# extended version of
#
# http://mapbox.com/tilemill/docs/guides/osm-bright-mac-quickstart/
#
# install PostgreSQL (fresh)
brew install postgresql
initdb /usr/local/var/postgres
mkdir -p ~/Library/LaunchAgents
@munhitsu
munhitsu / gist:17b24825a1f383d6b6b9
Created October 5, 2015 09:59
high kworker CPU usage / high system CPU usage
kworker is accounts for all kernel threads so you will also see high system CPU usage
In my case I've had nearly filled up BTRFS partition, so kernel was constantly searching for space.
tracing kernel - raw
```
# echo l > /proc/sysrq-trigger
# dmesg
```
@munhitsu
munhitsu / gist:4153696
Created November 27, 2012 11:13
to dump Xvfb buffer to png file
setup DISPLAY accordingly i.e.
export DISPLAY=:0
import -window root file.png
@munhitsu
munhitsu / gist:4162619
Created November 28, 2012 17:15
ipython within lettuce context
# from: http://matelakat.blogspot.co.uk/2012/03/lettuce-and-ipython-interactive-shell.html
#
@step(u'And give me IPython')
def and_continue_here(step):
import IPython
import sys
shell = IPython.InteractiveShell()
ip = IPython.core.ipapi.get()
p = IPython.core.debugger.Pdb(ip.colors)
p.reset()
@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
@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):