Skip to content

Instantly share code, notes, and snippets.

Rank Popularity Followers Friends Name (@twitter)
1 12476 13377 0 Hacker News 20 (@newsyc20)
2 5266 3781036 872 TechCrunch (@TechCrunch)
3 4600 17099119 165 Bill Gates (@BillGates)
4 3921 8836866 411 A Googler (@google)
5 3890 3115526 72 WIRED (@WIRED)
6 3562 31793932 131 Twitter (@twitter)
7 3488 4289712 2773 Mashable (@mashable)
8 3410 151838 2197 The Hacker News (@TheHackersNews)
@ducu
ducu / redis.config
Last active April 19, 2017 08:40 — forked from yustam/redis.config
packages:
yum:
gcc-c++: []
make: []
sources:
/home/ec2-user: http://download.redis.io/releases/redis-2.8.4.tar.gz
commands:
redis_build:
command: make
cwd: /home/ec2-user/redis-2.8.4
@ducu
ducu / twitter.py
Created December 2, 2014 19:07
Tweepy wrapper
"""
Twitter API wrapper based on Tweepy using the RateLimitHandler
with multiple access tokens (see https://github.com/svven/tweepy).
It also handles API method cursors and splits input param lists in
chunks if neccessary.
"""
from tweepy import API, Cursor, RateLimitHandler
from tweepy.error import TweepError
import os, sys, psutil
import requests
from contextlib import closing
def request(url):
with closing(requests.get(url, stream=True, timeout=10)) as response:
response.raise_for_status()
# content = response.content
chunk = response.iter_content(512)
@ducu
ducu / _test_rq_requests.py
Last active August 29, 2015 14:13
test_rq_requests.py
from redis import Redis
from rq import Queue, Connection, Worker
def enqueue_urls(urls=[]):
if len(urls) == 0: # load from file
with open('urls.txt', 'r') as file:
for url in file:
urls.append(url.strip())
with Connection():
q = Queue('test')
@ducu
ducu / test.py
Last active June 18, 2016 07:23 — forked from josiahcarlson/zunion_range_score.py
ZUNIONRANGESCORE
import redis
r = redis.StrictRedis()
r.zadd('k1', 1, 'a', 2, 'b', 3, 'c')
r.zadd('k2', 2, 'a', 3, 'b', 4, 'c')
r.zadd('k3', 3, 'a', 4, 'b', 5, 'c')
from zunion_range_score import zunion_range_score as zunionrangescore
@ducu
ducu / most_followed_by_newsycombinator_followers.md
Last active August 29, 2015 14:17
Top most followed by @newsycombinator's followers
Rank Popularity Followers Friends Name (@twitter)
1 90708 96859 1 Hacker News (@newsycombinator)
2 44661 4817719 669 TechCrunch (@TechCrunch)
3 37817 20816944 166 Bill Gates (@BillGates)
4 32030 10456263 437 Google (@google)
5 31453 4214811 194 WIRED (@WIRED)
6 30744 1797099 44 Elon Musk (@elonmusk)
7 29658 5110615 2799 Mashable (@mashable)
8 28987 232056 139 Paul Graham (@paulg)
@ducu
ducu / top_100_newsycombinator.md
Last active August 29, 2015 14:24
Top 100 most followed by @newsycombinator followers

Top most followed by @newsycombinator's followers

Rank Popularity Followers Friends Name (@twitter)
1 98020 105062 2 Hacker News (@newsycombinator)
2 48503 5350899 683 TechCrunch (@TechCrunch)
3 41285 23286724 166 Bill Gates (@BillGates)
4 35720 2334285 48 Elon Musk (@elonmusk)
5 34611 11758308 448 Google (@google)
6 34424 4816092 217 WIRED (@WIRED)
@ducu
ducu / show_tweet.html
Last active September 1, 2015 18:34
Show tweet in popover
<html>
<head>
<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="//platform.twitter.com/widgets.js"></script>
</head>
<body>
Show tweet in popover
---------------------
@ducu
ducu / main.py
Created January 13, 2016 21:35
Progress
import sys, time
def chunks(l, n):
c = len(l)
for i in xrange(0, c, n):
sys.stdout.write("\r%d%%" % (min(i+n,c)*100/c,))
sys.stdout.flush()
yield l[i:i+n]
for chunk in chunks(range(100), 10):