This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mod10(number): | |
digits = [] | |
even = False | |
for digit in reversed(number): | |
digit = ord(digit) - ord('0') | |
if even: | |
digit = digit * 2 | |
if digit >= 10: | |
digit = digit % 10 + digit / 10 | |
digits.append(digit) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#python3 | |
def hook(t): | |
def inner(bytes_amount): | |
t.update(bytes_amount) | |
return inner | |
BUCKET_NAME = 'your_s3_bucket_name' | |
FILE_NAME = 'your_s3_file_name' | |
s3 = boto3.resource('s3') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import numpy | |
import redis | |
# a 2D array to serialize | |
A = 10 * numpy.random.randn(10000).reshape(1000, 10) | |
# flatten the 2D NumPy array and save it as a binary string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(jd@XXX) /home/jd/shovel> time ./shovel.py jd_test | |
got 901 messages | |
real 0m1.617s | |
user 0m0.558s | |
sys 0m0.044s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(jd@XXX) /home/jd/shovel> time ./shovel.py jd_test | |
got 901 messages | |
real 0m1.617s | |
user 0m0.558s | |
sys 0m0.044s |