Skip to content

Instantly share code, notes, and snippets.

@tomislater
tomislater / do_gist_json
Last active December 17, 2015 10:29
Script for uploads code on gitst. For BPython.
#!/usr/bin/env python
import sys
import json
import requests
def do_gist_json(s):
""" Use json to post to github. """
gist_url = 'https://api.github.com/gists'
@tomislater
tomislater / sample.py
Created May 16, 2013 21:53
Gist from BPython
>>> wow = "wow"
>>> udalo_sie = "^_^"
>>>
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import timeit
from memcache import Client
mc = Client(['127.0.0.1:11211'], debug=0)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import timeit
from umemcache import Client
umc = Client('127.0.0.1:11211')
umc.connect()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import timeit
from memcache import Client
from multiprocessing import Process
def worker(x, y):
mc = Client(['127.0.0.1:11211'], debug=0)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import timeit
from umemcache import Client
from multiprocessing import Process
def worker(x, y):
umc = Client('127.0.0.1:11211')
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import timeit
from pylibmc import Client
mc = Client(['127.0.0.1'])
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import timeit
from pylibmc import Client
from multiprocessing import Process
def worker(x, y):
mc = Client(['127.0.0.1'])
>>> from random import randint
>>> from collections import Counter
>>> l = [randint(0, 333) for x in xrange(100)]
>>> c = Counter(l)
>>> c.most_common(5)
[(286, 3), (314, 3), (133, 2), (139, 2), (142, 2)]
>>> c[286]
3
>>> from collections import deque
>>> l = deque([])
>>> for x in xrange(15):
>>> l.appendleft(x)
>>> l.append(x)
>>> print l
deque([14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])