Skip to content

Instantly share code, notes, and snippets.

View svetlyak40wt's full-sized avatar
💭
Making Ultralisp.org

Alexander Artemenko svetlyak40wt

💭
Making Ultralisp.org
View GitHub Profile
@svetlyak40wt
svetlyak40wt / lighttpd_gunicorn_https.cfg
Created January 24, 2012 13:23
lighttpd_gunicorn_https.cfg
$HTTP["url"] !~ "^/(?:media|ping.html|hna).*" {
$HTTP["scheme"] == "https" {
setenv.add-request-header = ("X-FORWARDED-PROTOCOL" => "ssl", "X-FORWARDED-SSL" => "on")
}
proxy.server = (
"/" => ((
"host" => "127.0.0.1",
"port" => 8302,
))
)
@svetlyak40wt
svetlyak40wt / add-obstack-source.diff
Created April 13, 2012 11:23
Adds obstack.(c|h) files to anacron
diff -ruN anacron-2.3/Makefile /tmp/anacron-2.3/Makefile
--- anacron-2.3/Makefile 2000-06-23 02:26:11.000000000 +0400
+++ /tmp/anacron-2.3/Makefile 2012-04-13 13:49:08.000000000 +0400
@@ -22,7 +22,7 @@
PREFIX =
BINDIR = $(PREFIX)/usr/sbin
MANDIR = $(PREFIX)/usr/man
-CFLAGS = -Wall -pedantic -O2
+CFLAGS = -Wall -pedantic -O2 -I.
#CFLAGS = -Wall -O2 -g -DDEBUG
@svetlyak40wt
svetlyak40wt / fix-const-isleap-error.diff
Created April 13, 2012 11:29
Fixes error, related to isleap variable's constantness, in anacron.
diff -ru anacron-2.3/gregor.c /tmp/anacron-2.3/gregor.c
--- anacron-2.3/gregor.c 2000-06-23 02:50:40.000000000 +0400
+++ /tmp/anacron-2.3/gregor.c 2012-04-13 11:23:24.000000000 +0400
@@ -65,7 +65,6 @@
{
int dn;
int i;
- const int isleap; /* save three calls to leap() */
/* Some validity checks */
@svetlyak40wt
svetlyak40wt / aggregate_filestat.py
Created April 23, 2012 09:17 — forked from SaveTheRbtz/aggregate_filestat.py
Linux per-file IO statistics
#!/usr/bin/env python
import logging as log
from fileinput import input
from collections import namedtuple, defaultdict
from pprint import pprint
if __debug__:
log_level = log.DEBUG
else:
@svetlyak40wt
svetlyak40wt / flask_mongodb_dbshell.py
Created June 26, 2012 07:02
./manage.py dbshell for Flask + MongoDB
import subprocess
import myproject
from flaskext.script import Manager
manager = Manager(app)
@manager.command
def dbshell():
db = myproject.get_db()
@svetlyak40wt
svetlyak40wt / gist:3117976
Created July 15, 2012 18:13
How to upgrade guest additions for the Virtual Box.
sudo apt-get install make linux-headers-`uname -r`
cd /tmp
wget 'http://download.virtualbox.org/virtualbox/4.1.18/VBoxGuestAdditions_4.1.18.iso'
sudo mount VBoxGuestAdditions_4.1.18.iso -o loop /mnt
sudo sh /mnt/VBoxLinuxAdditions.run --nox11
@svetlyak40wt
svetlyak40wt / part_of_nginx.conf
Created July 30, 2012 13:11
How to pass POST uploads into FastCGI, using files.
client_body_in_file_only clean; # предзакачивать POST на диск и чистить после ответа
client_body_temp_path /tmp/nginx/body/; # папка с постами
fastcgi_pass_request_body off; # не прокачивать тело POSTа в fastcgi напряму
fastcgi_param REQUEST_BODY_FILE $request_body_file; # прокинуть в ENV путь к телу POSTа
@svetlyak40wt
svetlyak40wt / django-trace.py
Created September 3, 2012 06:34
Django trace for superuser
# source: http://blog.lalf.ru/2012/01/django-traceback-production.html#more
from django.views.debug import technical_500_response
import sys
class UserBasedExceptionMiddleware(object):
def process_exception(self, request, exception):
if request.user.is_superuser:
return technical_500_response(request, *sys.exc_info())
@svetlyak40wt
svetlyak40wt / russian.vim
Created September 19, 2012 07:43
A part of Vim config to switch between Russian and English keymaps.
nnoremap <Leader>r :set keymap=russian-jcuken<CR>
nnoremap <Leader>e :set keymap=<CR>
inoremap <Leader>r <ESC>:set keymap=russian-jcuken<CR>a
inoremap <Leader>e <ESC>:set keymap=<CR>a
@svetlyak40wt
svetlyak40wt / mongo_lock.py
Created December 13, 2012 14:15
Mongo lock
now = datetime.utcnow()
then = now + timedelta(seconds=LOCK_TIME)
if db.locks.find_and_modify({'type': command, 'time': {'$lt': now}},
{'type': command, 'time': then},
new=True,
upsert=(not bool(mongo.dbtaxi.locks.find({'type': command}).count()))):
do_stuff()