Skip to content

Instantly share code, notes, and snippets.

Avatar
🙃
wat

Ionel Cristian Mărieș ionelmc

🙃
wat
View GitHub Profile
View INSTRUCTIONS.rst

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
View autosync.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 Jan 14, 2013 — forked from piscisaureus/pr.md
Git(hub) origin with all the pull requests
View pr.md

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 Jan 31, 2013
billiard.common.restart_state _run_silenced monkey patch
View patch.py
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 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
ionelmc / dumb-daemonizer.py
Created Feb 26, 2013
Very simple daemonization code (double-fork, fds close, in/out/err reopen)
View dumb-daemonizer.py
#!/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 Dec 14, 2015
__retry decorator
View client_with_retry.py
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 Mar 8, 2013
those damn ubuntu vms (disable lightdm and disable graphical console that never works properly on hyper-v)
View fixup-vm.sh
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 Mar 11, 2013
disable framebuffer in vm
View ubuntu-10.04-rm.rst

Install options:

vga16fb.modeset=0

After install:

echo blacklist vga16fb | sudo tee -a /etc/modprobe.d/blacklist-framebuffer.conf
View watch-sys-block-stat.sh
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
You can’t perform that action at this time.