Skip to content

Instantly share code, notes, and snippets.

View x746e's full-sized avatar

Kirill Spitsyn x746e

View GitHub Profile
@x746e
x746e / and.devserver.diff
Created July 17, 2012 12:25
Make web2py show a traceback right away instead of creating a ticket and add a devserver with a reloader
diff --git a/gluon/main.py b/gluon/main.py
--- a/gluon/main.py
+++ b/gluon/main.py
@@ -796,6 +796,11 @@
log_filename,
profiler_filename) }
+ from werkzeug.serving import run_simple
+ app = app_info["wsgi_app"]
+ run_simple('localhost', 8000, app, use_reloader=True)
@x746e
x746e / run-dev-server.sh
Created July 17, 2012 13:30
web2py runserver
#!/bin/sh
WEB2PY_DIR=$HOME/work/web2py.dev
VENV=$HOME/work/venv
CODEDIR=$HOME/work/eas-hgsvn-full-trunk
EMEDIATE_GLOBAL_CONF=$HOME/work/devserver_global.conf
. $VENV/bin/activate
export EMEDIATE_GLOBAL_CONF
#!/bin/sh
WEB2PY_DIR=$HOME/work/web2py.dev
VENV=$HOME/work/venv
EMEDIATE_GLOBAL_CONF=$HOME/work/testing_global.conf
CODEDIR=$HOME/work/eas-hgsvn
CODEDIR_GUI=$CODEDIR/booking/gui
TESTS="$CODEDIR_GUI/applications/api $CODEDIR_GUI/applications/booking $CODEDIR_GUI/lib/w2p $CODEDIR/systest/support/tests.py"
@x746e
x746e / gist:4110129
Created November 19, 2012 11:03
Make web2py drop the habit of rewriting languages files
diff -r ff5196a8c552 gluon/languages.py
--- a/gluon/languages.py Wed Oct 24 14:14:55 2012 +0300
+++ b/gluon/languages.py Mon Nov 19 12:59:57 2012 +0200
@@ -283,6 +283,7 @@
def write_plural_dict(filename, contents):
+ return
if '__corrupted__' in contents:
return
@x746e
x746e / run-booking-tests.sh
Created December 19, 2012 09:32
run-booking-tests.sh
#!/bin/sh
WEB2PY_DIR=$HOME/work/web2py-dev
VENV=$HOME/work/venv
#EMEDIATE_GLOBAL_CONF=$HOME/work/global-unittests.conf
CODEDIR=$HOME/work/eas-hgsvn
CODEDIR_GUI=$CODEDIR/booking/gui
#TESTS="$CODEDIR_GUI/applications/api $CODEDIR_GUI/applications/booking $CODEDIR_GUI/lib/w2p $CODEDIR/systest/support/tests.py"
tn@tns ~/hz % USER_SITE=`python -c 'import site; print site.USER_SITE'`
tn@tns ~/hz % mkdir -p "$USER_SITE"
tn@tns ~/hz % echo 'import __builtin__; __builtin__.False = True' > "$USER_SITE/happy_debugging_motherfuckers.pth"
tn@tns ~/hz % python -c 'print True == False'
True
@x746e
x746e / gist:5612369
Last active December 17, 2015 12:49
better web2py devserver, with werkzeug debugger. and it doesn't rewrite translation!
diff --git a/gluon/languages.py b/gluon/languages.py
--- a/gluon/languages.py
+++ b/gluon/languages.py
@@ -283,6 +283,7 @@
def write_plural_dict(filename, contents):
+ return
if '__corrupted__' in contents:
return
def set_tracer(func):
from functools import wraps
@wraps(func)
def inner(*args, **kwargs):
import ipdb; ipdb.set_trace()
return func(*args, **kwargs)
return inner
def decorate_methods(decorator):
@x746e
x746e / task.py
Last active December 27, 2015 01:49
import unittest
class MaybeCls:
def __repr__(self):
return 'Maybe'
Maybe = MaybeCls()
def pour(wall):
@x746e
x746e / SimpleSemaphore.java
Last active August 29, 2015 14:02
Is using fair lock enough to make a fair semaphore?
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.Condition;
public class SimpleSemaphore {
private final ReentrantLock lock;
private final Condition permitsAvailable;
private int permits;
public SimpleSemaphore(int permits, boolean fair) {
this.lock = new ReentrantLock(fair);