Skip to content

Instantly share code, notes, and snippets.


  • Switzerland
Block or report user

Report or block miraculixx

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
miraculixx /
Last active Apr 11, 2019
a simple python based rule engine
(c) 2014 miraculixx at
from shrutil.dictobj import DictObject
class RuleContext(DictObject):
rule context to store values and attributes (or any object)
def __init__(self):
miraculixx / requirements.txt
Created Nov 28, 2018
Python multiprocess parallel selenium web scraping with improved performance
View requirements.txt
View gitdeploy
#!/usr/bin/env bash
# adopted from
# changes
# * deploy from current directory is possible
# * set options from either .deploy file or parameters
set -o errexit #abort if any command fails
miraculixx /
Created Mar 1, 2019
read a large csv file and subset on datetime column
from dateutil.parser import parse
with open('data.csv') as fin:
for line in csv.reader(fin):
date1 = parse(row[1])
date2 = - timedelta(days=3)
if date1 > date2:
process(row) # whatever your logic
miraculixx /
Last active Feb 27, 2019
Read arbitrary formatted file into pandas dataframe
import pandas as pd
text = """
Men super men size Energy (J) type num g
50 1 1 1.0234E+03 A abcd 12.1
20 7 4 5.0211E+02 A2 C agcd 14.1
10 2 3 -1.0347E+02 B2 abkd 72.1
miraculixx /
Created Feb 22, 2019
sodapy.Socrata extenion to page through results using a single call to get
from sodapy import Socrata
class SocrataPager(Socrata):
def get(self, dataset, *args, limit=None, offset=0, where=None, order=None, page_size=None, **kwargs):
""" get dataset by pages or within limit
uses Socrata.get to page through results until limit is reached. This adds the page_size parameter
which is passed as the limit kwarg to Socrata.get. limit is the total number of records to
return, across all pages. Note that the method is a generator.
miraculixx / github-add-user
Last active Jan 28, 2019
batch adding users to github accounts
View github-add-user
# Collaborator list, add, remove from a repository
# (c) 2015 miraculixx
# Author:
# MIT License, see below
function help {
echo "Add collaborators to one or more repositories on github"
echo ""
echo "Syntax: $0 -u user -p password [-l] [-D] -r repo1,repo2 <collaborator id>"
miraculixx /
Last active Jan 12, 2019
To enable CORS support in django-tastypie, use the following code snipet. Then create your tastypie resources as a subclass of BaseCorsResource.Basic code courtesy Daniel Conzalez of added documentation and the post_list method.
Add CORS headers for tastypie APIs
class MyModelResource(CORSModelResource):
class MyResource(CORSResource):
miraculixx /
Last active Nov 2, 2018
Tired of Python's UnicodeDeocodeError, ascii codec can't decode? Here's how to fix it, once and for all.
# Python ascii codec can't decode and unicode mess
# check this out
# and this
# The short of it is this
# 1. If you can, always set PYTHONIOENCODING=utf8 before you start your python programs.
# 2. If you can't or you can't ensure this, always use the following lambda _u to get unicode text
# whereever you convert to strings (str.format, str % etc.)
miraculixx / git-keep
Created Oct 4, 2014
create .keep files for empty directories currently ignored by git
View git-keep
# create .keep files for empty directories currently ignored by git
# run git clean -nd to see which directories are empty and therefore ignored by git currently
# run git keep to add these directories by adding a .keep file
# see this discussion
git clean -nd | awk '{ print $3 }' | xargs -L1 -I{} touch {}.keep
You can’t perform that action at this time.