Skip to content

Instantly share code, notes, and snippets.

View andreif's full-sized avatar
👾
invading spaces

Andrei Fokau andreif

👾
invading spaces
View GitHub Profile
[tox]
envlist = py24-django{ 12, 13 },
py25-django{ 12, 13, 14 },
py26-django{ 13, 14, 15, 16 },
py27-django{ 14, 15, 16, 17, 18, 19, 110, 111 },
py32-django{ 15, 16, 17, 18 },
py33-django{ 15, 16, 17, 18 },
py34-django{ 17, 18, 19, 110, 111, 20 },
py35-django{ 18, 19, 110, 111, 20 },
py36-django{ 111, 20 }
<!DOCTYPE HTML>
<html>
<head>
<script>
var currency = 'EUR';
window.onload = function () {
function fetch(coin, period, chart) {
var url = 'https://www.coinbase.com/api/v2/prices/' + coin + '-' + currency + '/historic?period=' + period;
chart.options.backgroundColor = 'transparent';
chart.options.axisY2.includeZero = false;
import pkg_resources
__version__ = {p._key: p._version for p in pkg_resources.working_set}.get('telethon', None)
@andreif
andreif / mtproto.py
Last active September 6, 2022 12:31
"""
0000 | 00 00 00 00 00 00 00 00 4A 96 70 27 C4 7A E5 51
0010 | 14 00 00 00 78 97 46 60 3E 05 49 82 8C CA 27 E9
0020 | 66 B3 01 A4 8F EC E2 FC
"""
import re
msg = re.sub('\d{4} \| ', '', __doc__)
msg = re.sub('\s+', '', msg)
msg = bytes.fromhex(msg)
import pkg_resources
installed_dists = {dist.project_name: dist
for dist in pkg_resources.working_set}
def get_installed(project_name):
for dist in pkg_resources.working_set:
if project_name.lower() == dist.project_name.lower():
return dist
import cgi
import http
import mimetypes
import os
import shutil
import urllib.parse
STORAGE_PATH = os.environ.get('STORAGE_PATH') or \
os.path.dirname(__file__) + '/storage'
import base64
import datetime
import hashlib
import hmac
import io
import json
import mimetypes
import os
import uuid
from urllib.error import HTTPError, URLError
#!/usr/bin/env python3
import mimetypes
import uuid
import io
import os
class FormData(object):
def __init__(self, data=None, files=None):
self.boundary = uuid.uuid4().hex
"""
list_filter = (('article__product', SearchableFilter),
('article', SearchableFilter))
def lookup_allowed(self, lookup, value):
return lookup in [
'article__id__exact',
'article__product__id__exact',
] or super(LicenseAdmin, self).lookup_allowed(lookup, value)
"""
@andreif
andreif / recover_source_code.md
Created March 12, 2017 20:59 — forked from simonw/recover_source_code.md
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb