Skip to content

Instantly share code, notes, and snippets.


Ionel Cristian Mărieș ionelmc

View GitHub Profile

In first terminal:

virtualenv ve
ve/bin/pip install -U -I pymongo
MP_LOG=1 ve/bin/celeryd --events --purge --loglevel=DEBUG --concurrency 5

In second terminal:

import os
import sys
import time
import shutil
import win32con
import win32file
import winnt
path_to_watch = os.path.abspath (sys.argv[1])
ionelmc /
Created Jan 14, 2013 — forked from piscisaureus/
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 =

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 /
Created Jan 31, 2013
billiard.common.restart_state _run_silenced monkey patch
from billiard.common import restart_state
def _run_silenced(self, func):
import logging
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 / apache.conf
Created Feb 20, 2013
Serve from static dir, if file not found forward request to modwsgi app
View apache.conf
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 /
Created Feb 26, 2013
Very simple daemonization code (double-fork, fds close, in/out/err reopen)
# based on:
from subprocess import call
import os
import sys
import signal
import resource
ionelmc /
Last active Dec 14, 2015
__retry decorator
class ApiClient(object):
default_retries = (1, 2, 5, 10, 20, 30)
def __retry(func):
def wrapper(self, *args, **kwargs):
retries = kwargs.pop('retries', self.default_retries)
if kwargs.pop('reconnect', False):
self.__init__(self.ftp_uri, retries=())
ionelmc /
Created Mar 8, 2013
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 / ubuntu-10.04-rm.rst
Created Mar 11, 2013
disable framebuffer in vm
View ubuntu-10.04-rm.rst

Install options:


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'
#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
You can’t perform that action at this time.