Skip to content

Instantly share code, notes, and snippets.

from django.conf import settings
from django.http import HttpResponse, HttpResponseNotFound
import os
import re
import clevercss
def serve_css(request, path):
css_fname = os.path.join(settings.MEDIA_ROOT, path)
ccss_fname = os.path.join(settings.MEDIA_ROOT, re.compile('\.css$').sub('.ccss', path))
css = ccss = None
from django.conf import settings
from django.http import HttpResponseNotFound
from django.views.static import serve as django_serve
import os
def _do_rec_sync(local_root, remote_path, local_path, update):
if os.path.exists(local_path) and (os.path.isdir(local_path) or not update):
return
parent_local_path = os.path.normpath(os.path.join(local_path, '..'))
@emesik
emesik / paybackpal.py
Created December 8, 2010 23:42
Anti-PayPal LOIC. For Julian!
import urllib
import urllib2
import random
import decimal
UAGENTS = [
'Mozilla/5.0 (Windows; U; MSIE 9.0; WIndows NT 9.0; en-US)',
'Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)',
'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; Media Center PC 6.0; InfoPath.3; MS-RTC LM 8; Zune 4.7)',
'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Zune 4.0; InfoPath.3; MS-RTC LM 8; .NET4.0C; .NET4.0E)',
@emesik
emesik / mod10.py
Created April 29, 2011 16:37
python mod10 checker
def mod10(number):
digits = []
even = False
for digit in reversed(number):
digit = ord(digit) - ord('0')
if even:
digit = digit * 2
if digit >= 10:
digit = digit % 10 + digit / 10
digits.append(digit)
from datetime import date
class PESEL(object):
"""Parses PESEL number, checks validity and extracts gender + DOB data."""
gender = None
birth_date = None
pesel = None
def __init__(self, pesel):
try:
#!/usr/bin/python
"""
Fetch and print current Monero mempool.
"""
from datetime import datetime
import json
import logging
import requests
class MemPool(object):
@emesik
emesik / resume-wacom-reload.service
Created October 22, 2017 13:37
Service file which reloads wacom module on suspend/resume. Makes touchscreen work. Arch Linux / Lenovo ThinkPad Yoga S3
[Unit]
Description=Reload wacom module (touchscreen)
After=suspend.target
[Service]
User=root
Type=oneshot
ExecStart=/usr/bin/rmmod wacom
ExecStop=/usr/bin/modprobe wacom
TimeoutSec=0
@emesik
emesik / intok.py
Created March 30, 2018 12:05
Encodes and decodes integers as short, easy to type tokens, using custom alphabet.
class Intok(object):
"""Encodes and decodes integers as short, easy to type tokens, using custom
alphabet.
The default alphabet consists of 29 digits and uppercase letters. It has
no vowels to eliminate accidental formation of words, and no glyphs that
could be confused (0 and O, I and 1).
"""
alphabet = 'BCDFGHJKLMNPQRSTVWXZ23456789'
case_sensitive = False
@emesik
emesik / monerodaemonchk.py
Created March 14, 2019 23:33
Checks if Monero daemon is up to date by comparing height to other nodes
import logging
from monero.daemon import Daemon
from monero.backends.jsonrpc import JSONRPCDaemon
import operator
import re
import sys
MY_DAEMON = '127.0.0.1:18081'
OTHER_DAEMONS = [
'node.moneroworld.com:18089',