Skip to content

Instantly share code, notes, and snippets.

Santiago Basulto santiagobasulto

Block or report user

Report or block santiagobasulto

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View who_is_hiring.py
# !pip install python-hn
import itertools
from hn import search_by_date
results = search_by_date('Who is hiring?', ask_hn=True, author='whoishiring', hits_per_page=1000)
who_is_hiring = (r for r in results if 'ask hn: who is hiring?' in r['title'].lower())
for elem in itertools.islice(who_is_hiring, 10):
print(elem['title'])
View who_is_hiring.py
# !pip install python-hn
import itertools
from hn import search_by_date
results = search_by_date('Who is hiring?', ask_hn=True, author='whoishiring', hits_per_page=1000)
who_is_hiring = (r for r in results if 'ask hn: who is hiring?' in r['title'].lower())
for elem in itertools.islice(who_is_hiring, 10):
print(elem['title'])
View Hawking.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View general.json
{
"category_name": "General",
"todos": [
{
"task": "My TODO Task",
"due_on": null,
"status": "pending",
"description": null
},
{
@santiagobasulto
santiagobasulto / README.md
Last active Jul 6, 2019
Download HumbleBundle books in batch with a simple Python script.
View README.md

Download HumbleBundle books

This is a quick Python script I wrote to download HumbleBundle books in batch. I bought the amazing Machine Learning by O'Reilly bundle. There were 15 books to download, with 3 different file formats per book. So I scratched a quick script to download all of them in batch.

(Final Result: books downloaded)

@santiagobasulto
santiagobasulto / failure.py
Created Aug 11, 2018
Pickle limitations for class based decorators.
View failure.py
from concurrent.futures import ProcessPoolExecutor
class CheckOnlyIntegers:
def __init__(self, fn):
self.fn = fn
def __call__(self, *args):
if not all([type(arg) == int for arg in args]):
raise ValueError("Invalid param is not an integer")
View decorator_process_executor.py
import functools
from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor
def check_only_integers(fn):
"""Very simple decorator that prevents other than integers to be passed
to the decorated function. Just for demonstration purposes.
"""
@functools.wraps(fn)
def wrapped(*args):
@santiagobasulto
santiagobasulto / parallel_generators.py
Last active Jul 16, 2018
Despite multiple efforts, I couldn't figure out how to evaluate generators in parallel. Ideas are welcome.
View parallel_generators.py
def get_repo_stars(org, repo):
url = 'https://api.github.com/repos/{org}/{repo}'.format(
org=org, repo=repo)
print("GET ", url)
resp = requests.get(url)
return resp.json()['stargazers_count']
params = [
('requests', 'requests'),
('requests', 'httpbin'),
View executor_test_1.py
"""
This one "Doesn't" work. Seems like `map` doesn't play well with
`as_completed`.
"""
import time
import random
from concurrent.futures import ThreadPoolExecutor, as_completed
def my_sleep(n=1000):
View pusher_django_strategy.py
from django.http import HttpResponseForbidden
from django.http import JsonResponse
from pusher import Pusher
class PusherAuthStrategy:
def __init__(self, namespace):
self.namespace = namespace
You can’t perform that action at this time.