Skip to content

Instantly share code, notes, and snippets.

from __future__ import division
import requests
from urlparse import urlparse
from celery import task
from celery.contrib.batches import Batches
from celery import current_app
from six.moves import zip
wot_api_target = "https://api.mywot.com/0.4/public_link_json"
$ ./manage.py celery worker -P eventlet -c 1000 --loglevel=info
-------------- celery@MS-7681-ubu v3.0.12 (Chiastic Slide)
---- **** -----
--- * *** * -- [Configuration]
-- * - **** --- . broker: amqp://guest@localhost:5672//
- ** ---------- . app: default:0x1aebad0 (djcelery.loaders.DjangoLoader)
- ** ---------- . concurrency: 1000 (eventlet)
- ** ---------- . events: OFF (enable -E to monitor this worker)
- ** ----------
class Tree(object):
def __init__(self, cargo, left=None, right=None):
self.cargo = cargo
self.left = left
self.right = right
def __str__(self):
return str(self.cargo)
#Traversing through the tree
from multiprocessing import Pool, cpu_count
import time
from random import randint
def roll(dice=1, sides=6):
try:
return [randint(1, sides) for i in range(dice)]
except:
return []
class Foo
def handle(obj)
yield obj
end
end
class Bar < Foo
def handle(obj)
super { | a | yield a.downcase }
end
REQUEST_SESSIONS = {
"api": requests.Session(),
"probe": requests.Session()
}
REQUEST_SESSIONS["api"].headers["User-Agent"] += " +http://git.io/cso_malucrawl"
use Bio::DB::Sam;
# high level API
my $sam = Bio::DB::Sam->new(-bam =>"data/ex1.bam",
-fasta=>"data/ex1.fa",
);
my @targets = $sam->seq_ids;
my @alignments = $sam->get_features_by_location(-seq_id => 'seq2',
-start => 500,
<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
<!ENTITY owl "http://www.w3.org/2002/07/owl#" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY bo "http://graingert.co.uk/broadcast-ontology/" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
]>
@graingert
graingert / foo.tex
Last active December 17, 2015 21:28
These fully centralized systems have a simple design and implementation however, there are some key issues that affect the users of the system - both merchants and customers - two of which are discussed here.
The first issue is that the trusted entity has a legal responsibility to handle ``charge-backs'' or reverse transactions, the cost for this escrow service - in which the central authority acts as an arbiter in disputes - is placed on the customer as a transfer fee or to the merchant as a fine, or worse\cite{violin}\footnote{\url{http://www.guardian.co.uk/world/2012/jan/04/paypal-buyer-destroys-violin}}.
The second major disadvantage of a centralized system is that it allows for a single point of failure resulting in a lack of reliability from the perspective of the user. The central authority has complete control over the status of the users' account - that authority can freeze the funds of that account at their discretion according to their own terms of service, this can include pressure from legal
from uuid import uuid1
from time import time
def main():
test = dict()
limit = 10 ** 10
while limit:
limit -= 1
x = {n:uuid1().hex for n in range(15)}
if len(set(x.values())) != len(x.keys()):