This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from json import loads, dumps, JSONEncoder | |
from decimal import Decimal | |
import datetime | |
class Encoder(JSONEncoder): | |
def default(self, obj): | |
if isinstance(obj, Decimal): | |
return '__decimal__' + str(obj) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def echo_public(): | |
def nested(): | |
print public_ | |
public_ = 5 | |
nested() | |
echo_public() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
roomrate | |
======== | |
{ | |
'city': 'Berlin', | |
'hotel': 'Hilton', | |
'date': '2013-08-09' | |
'room_type': 'single', | |
'occupancy': 2, | |
'avail_count': 13, | |
'booked_count': 4, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_inside(polygon, point): | |
"""Determine if a point is inside a given polygon or not | |
Polygon is a list of (x,y) points. | |
Uses the 'Ray Casting' algorithm""" | |
x, y = point | |
n = len(polygon) | |
inside = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from subprocess import check_output | |
EMPTY = tuple() | |
def get_pkgs(): | |
"""Query local packages""" | |
tmp = check_output(["pacman", "-Qi"]) | |
li = tmp.strip().split("\n\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
"""Create custom `mudrecot` meme""" | |
import PIL | |
from PIL import ImageFont | |
from PIL import Image | |
from PIL import ImageDraw | |
font_path = "/usr/share/fonts/TTF/LiberationSans-Bold.ttf" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get name and image of mps from sobranie.mk and put them in `PATH` | |
import requests as rq | |
from lxml.html import fromstring | |
PATH = 'target' | |
base = 'http://www.sobranie.mk/' | |
start = base+'?ItemID=C5223B907BD9D247A9245C0C30C2E6AE' | |
def main(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### MATPLOTLIBRC FORMAT | |
# This is a sample matplotlib configuration file - you can find a copy | |
# of it on your system in | |
# site-packages/matplotlib/mpl-data/matplotlibrc. If you edit it | |
# there, please note that it will be overridden in your next install. | |
# If you want to keep a permanent local copy that will not be | |
# over-written, place it in HOME/.matplotlib/matplotlibrc (unix/linux | |
# like systems) and C:\Documents and Settings\yourname\.matplotlib | |
# (win32 systems). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import locale | |
default_locale = locale.getlocale(locale.LC_COLLATE) | |
def sort_strings(strings, locale_=None): | |
if locale_ is None: | |
return sorted(strings) | |
locale.setlocale(locale.LC_COLLATE, locale_) | |
sorted_strings = sorted(strings, cmp=locale.strcoll) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from time import sleep | |
from simplejson import loads, dumps | |
from datetime import datetime | |
BASE = 'http://irc.softver.org.mk/api/_changes' | |
DEFAULT_PARAMS = {'feed':'longpoll', 'heartbeat':'30000', 'include_docs':'true', | |
'filter':'log/channel', 'channel':'lugola'} |