Skip to content

Instantly share code, notes, and snippets.

View LouisAmon's full-sized avatar

Louis Amon LouisAmon

View GitHub Profile
@LouisAmon
LouisAmon / mod10.py
Created May 18, 2021 14:35 — forked from emesik/mod10.py
python mod10 checker
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)
@LouisAmon
LouisAmon / s3_download_file_progress_bar.py
Created October 19, 2018 10:57 — forked from wy193777/s3_download_file_progress_bar.py
Show AWS s3 download_file Progress using tqdm
#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')
@LouisAmon
LouisAmon / serialize-numpy-array.py
Last active November 16, 2017 10:03 — forked from alexland/serialize-numpy-array.py
serialize, persist, retrieve, and de-serialize a NumPy array as a binary string (any dimension, any dtype); exemplary use case: a web app calculates some result--eg, from a Machine Learning algorithm, using NumPy and the result is a NumPy array; it is efficient to just return that result to rather than persist the array then retrieve it via query
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
@LouisAmon
LouisAmon / shovel.py
Created July 5, 2017 05:06 — forked from jdmaturen/shovel.py
SQS + Boto + Eventlet, re http://gist.github.com/434053
(jd@XXX) /home/jd/shovel> time ./shovel.py jd_test
got 901 messages
real 0m1.617s
user 0m0.558s
sys 0m0.044s
@LouisAmon
LouisAmon / shovel.py
Created July 5, 2017 05:05 — forked from jdmaturen/shovel.py
SQS + Boto + Eventlet, re http://gist.github.com/434053
(jd@XXX) /home/jd/shovel> time ./shovel.py jd_test
got 901 messages
real 0m1.617s
user 0m0.558s
sys 0m0.044s