Skip to content

Instantly share code, notes, and snippets.

View ionelmc's full-sized avatar
🙃
wat

Ionel Cristian Mărieș ionelmc

🙃
wat
View GitHub Profile
@ionelmc
ionelmc / INSTRUCTIONS.rst
Created December 11, 2012 16:24
celery bug 1118

In first terminal:

virtualenv ve
ve/bin/pip install -U -I https://github.com/celery/celery/archive/3.0.zip pymongo
MP_LOG=1 ve/bin/celeryd --events --purge --loglevel=DEBUG --concurrency 5

In second terminal:

ve/bin/python bug.py
import os
import sys
import time
import shutil
import win32con
import win32file
import winnt
try:
path_to_watch = os.path.abspath (sys.argv[1])
@ionelmc
ionelmc / pr.md
Created January 14, 2013 07:49 — forked from piscisaureus/pr.md
Git(hub) origin with all the pull requests

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@ionelmc
ionelmc / patch.py
Created January 31, 2013 17:41
billiard.common.restart_state _run_silenced monkey patch
from billiard.common import restart_state
def _run_silenced(self, func):
import logging
try:
return func(self)
except Exception:
logging.exception("Shit has hit the fan in %r", func)
restart_state.step = lambda self, func=restart_state.step: _run_silenced(self, func)
@ionelmc
ionelmc / apache.conf
Created February 20, 2013 16:31
Serve from static dir, if file not found forward request to modwsgi app
WSGIScriptAlias /wsgi /home/blabla/app.wsgi
RewriteEngine on
#RewriteLogLevel 9
#RewriteLog "/var/log/apache2/rewrite.log"
RewriteCond /home/blabla/www%{REQUEST_FILENAME} !-f
RewriteCond /home/blabla/www%{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(static|media)
RewriteRule ^(.*)$ /wsgi$1 [PT,L]
@ionelmc
ionelmc / dumb-daemonizer.py
Created February 26, 2013 12:33
Very simple daemonization code (double-fork, fds close, in/out/err reopen)
#!/usr/bin/python
# based on: http://code.activestate.com/recipes/278731-creating-a-daemon-the-python-way/
from subprocess import call
import os
import sys
import signal
import resource
@ionelmc
ionelmc / client_with_retry.py
Last active December 14, 2015 09:18
__retry decorator
class ApiClient(object):
default_retries = (1, 2, 5, 10, 20, 30)
def __retry(func):
@wraps(func)
def wrapper(self, *args, **kwargs):
retries = kwargs.pop('retries', self.default_retries)
try:
if kwargs.pop('reconnect', False):
self.__init__(self.ftp_uri, retries=())
@ionelmc
ionelmc / fixup-vm.sh
Created March 8, 2013 02:02
those damn ubuntu vms (disable lightdm and disable graphical console that never works properly on hyper-v)
echo 'manual' | sudo dd of=/etc/init/lightdm.override
echo GRUB_TERMINAL=console | sudo tee -a /etc/default/grub
sudo update-grub
@ionelmc
ionelmc / ubuntu-10.04-rm.rst
Created March 11, 2013 10:58
disable framebuffer in vm

Install options:

vga16fb.modeset=0

After install:

echo blacklist vga16fb | sudo tee -a /etc/modprobe.d/blacklist-framebuffer.conf 
watch --difference=cummulative --interval=1 '(echo device read_IOs read_merges read_sectors read_ticks write_IOs write_merges write_sectors write_ticks in_flight io_ticks time_in_queue; for file in /sys/block/*/stat; do echo -n $file; cat $file; done) | column -t'
# OUTPUTS:
#device read_IOs read_merges read_sectors read_ticks write_IOs write_merges write_sectors write_ticks in_flight io_ticks time_in_queue
#/sys/block/dm-0/stat 116962 0 2212746 314096 7705653 0 150218536 609670232 0 644428 610921004
#/sys/block/dm-1/stat 116479 0 2208882 313324 7686986 0 150218536 609676068 0 644616 611418072
#/sys/block/dm-2/stat 302 0 2416 780 0 0 0 0 0 148 780
#/sys/block/sda/stat 91181 26273 2217246 74876 7314854 388030 150261802 16954364