Skip to content

Instantly share code, notes, and snippets.

# File a.py
import sys
sys.modules['d'] = __import__("c")
sys.modules['e.e'] = __import__("c")
import b
print b.d # works
print b.e.e # ImportError: No module named e.e
@balrok
balrok / gist:5542806
Last active December 17, 2015 03:19
configure flags for php
# where everything gets installed to
# notice that the php.ini directory will be /root/php5/opt/lib and the php.ini won't be autocreated
--prefix=/root/php5/opt/ \
# first I disable every module to be as minimal as possible
--disable-all \
# required for php-fpm (see my last post)
--enable-fpm \
# the new zend opcache (requires php.ini support)
--enable-opcache \
# Those are all required for pear
@balrok
balrok / gist:5542773
Last active December 17, 2015 03:19
my minimal php configuration
#!/bin/bash
./configure \
--prefix=/root/php5/opt/ \
--disable-all \
--enable-fpm \
--enable-opcache \
--enable-xml \
--enable-libxml \
--with-pear \
from ghost import Ghost
from functools import wraps
def fix_redirect(func):
@wraps(func)
def wrapper(self, *args, **kwargs):
page, resources = func(self, *args, **kwargs)
if resources and 300 <= resources[0].http_status <= 399:
nextUrl = resources[0].headers['Location']
page, resources = self.open(nextUrl)
@balrok
balrok / a.js
Created February 27, 2013 11:09
function parse(url, html) {
var urlLocation = getLocation(url)
if (urlLocation.hostname == 'wohnungsmarkt24.de' || urlLocation.hostname == 'www.wohnungsmarkt24.de')
return parseWohnungsmarkt24(url, html);
else if (urlLocation.hostname == 'immobilienscout24.de' || urlLocation.hostname == 'www.immobilienscout24.de')
return parseImmobilienscout24(url, html);
else
console.log("no parser for this one");
return {};
}
var yql = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent('select * from html where url="' + site + '"') + '&format=xml';
$.ajax({
dataType: "jsonp",
url: yql,
success: function (data) {
...
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
user = mysql
user balrok balrok;
worker_processes 1;
error_log /var/log/nginx/error_log info;
events {
worker_connections 512;
use epoll;
}
@balrok
balrok / gist:4051486
Created November 10, 2012 16:02
Coverage2
include "coverage.php";
$reader = new Coverage\Reader('/path/for/output/');
$filter = new Coverage\Filter();
$filter->excludeFileRegex = '/\/yii\/.*\/framework\//';
$merger = new Coverage\Merger();
$converter = new Coverage\Converter();
foreach ($reader as $k=>$data)
{
$data = $filter->filterData($data);
$merger->mergeData($data);
@balrok
balrok / gist:4051477
Created November 10, 2012 15:59
Coverage1
include coverage.php;
$wrapper = new Coverage\Wrapper();
$wrapper->dir = '/path/for/output/';
$wrapper->start();
// here comes your code..
$wrapper->stop();