Skip to content

Instantly share code, notes, and snippets.

@tumb1er
tumb1er / curl_request.py
Created March 14, 2018 13:39 — forked from kaka19ace/curl_request.py
using pycurl request (support multi request)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# @file curl_request.py
# @author kaka_ace <xiang.ace@gmail.com>
# @date Jan 10 2015
# @breif learn from human_curl
# @refrences:
# http://pycurl.sourceforge.net/doc/curlmultiobject.html
# http://curl.haxx.se/libcurl/c/curl_multi_info_read.html
tumbler@stikhonov:/tmp$ virtualenv --python=python3.6 test
Running virtualenv with interpreter /usr/bin/python3.6
Using base prefix '/usr'
New python executable in /tmp/test/bin/python3.6
Also creating executable in /tmp/test/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
tumbler@stikhonov:/tmp$ . test/bin/activate
(test) tumbler@stikhonov:/tmp$ pip install pycryptodomex==3.4.6 --no-cache-dir
Collecting pycryptodomex==3.4.6
Downloading pycryptodomex-3.4.6.tar.gz (6.5MB)
class substitute(object):
DEBUG = False
special = [True, False, None, 0, 1]
stub = object()
def __init__(self, field_map):
self.field_map = field_map
@substitute({
('play_qualityrule_rightholders', u'rightholder_id', 'exact'): 'rightholder',
('play_qualityrule_rightholders', 'rightholder_id', 'isnull'): True,
('play_qualityrule_user_agents', u'useragent_id', 'isnull'): True,
('play_qualityrule_user_agents', u'useragent_id', 'exact'): 'useragent',
('play_qualityrule_groups', u'group_id', 'isnull'): True,
('play_qualityrule_groups', u'group_id', 'in'): 'group',
('play_qualityrule', 'alternative_purchase', 'isnull'): True,
('play_qualityrule', 'alternative_purchase', 'exact'): lambda **kw: bool(kw['alternative_sales_rule']),
('play_qualityrule_alternative_sales_rule', u'alternativesalesrule_id', 'isnull'): True,
class prepare(object):
special = [True, False, None, 0, 1]
stub = object()
DEBUG = False
def __init__(self, mapper=None):
self.func = None
@tumb1er
tumb1er / add_new_files.py
Created May 10, 2017 07:00
Add new files to filesystem_config.txt for LineageOS compilation
import os
import random
import sys
from collections import namedtuple
CAPABILITIES = 'capabilities=0x0'
SELABEL = 'selabel=u:object_r:system_file:s0'
@tumb1er
tumb1er / strategies.py
Last active January 16, 2017 07:21
strategies example
# coding: utf-8
import abc
class StrategyMeta(abc.ABCMeta):
strategies = []
@staticmethod
@tumb1er
tumb1er / dropshot.py
Created July 5, 2016 06:04 — forked from grieve/dropshot.py
Simple hack to use gnome-screenshot and dropbox to upload quick public screenshots - required libnotify-bin for notifications
#!/usr/bin/python
import gtk
import simplejson
import urllib2
import subprocess
import datetime
import string
import random
import time
try:
video = Video.objects.get(track_id=track.id)
# Если были ошибки удаления
if (video.is_deleted == old_is_deleted
and video.action_reason == old_action_reason):
video.action_reason = action_reason
video.is_deleted = is_deleted
video.save()
@tumb1er
tumb1er / gunicorn.py
Created January 17, 2015 15:15
aiohttp.web over gunicorn
import functools
from aiohttp import web
from gunicorn.workers import gaiohttp
class GunicornWorker(gaiohttp.AiohttpWorker):
def web_factory(self, handler):
proto = handler()