This file contains hidden or 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include "liblmdb/lmdb.h" | |
void | |
check_err(int err) | |
{ | |
if (err != 0) { | |
fprintf(stderr, "ERROR (%d): %s\n", err, mdb_strerror(err)); | |
exit(EXIT_FAILURE); |
This file contains hidden or 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 json | |
from concurrent.futures import ThreadPoolExecutor, as_completed | |
from urllib.parse import urlencode | |
from urllib.request import Request, urlopen | |
def get_latest_price_single(ticker): | |
url = f'https://query1.finance.yahoo.com/v8/finance/chart/{ticker}' | |
params = { | |
'region': 'US', |
This file contains hidden or 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
# Fatality rate of coronavirus outside China [1] | |
corona_fatal_rate = (3168 - 2945) / (92880 - 80152) | |
# Cases in USA [1] | |
corona_cases_usa = 118 | |
# Population of USA [2] | |
population_usa = 329346645 | |
# "Infection rate" of coronavirus in USA | |
corona_infect_rate = corona_cases_usa / population_usa | |
# Fatality rate of flu in USA [3] | |
# (average of 5 most recent seasons for which there's data 2012-2017) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 degrees_to_direction(degrees): | |
"""Convert degrees to a compass direction.""" | |
directions = [ | |
'N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', | |
'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW', | |
] | |
return directions[int(round(float(degrees) / 22.5)) % 16] |
This file contains hidden or 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 | |
from redis import StrictRedis, ConnectionError | |
channels = ['test'] | |
redis = StrictRedis() | |
pubsub = redis.pubsub() | |
pubsub.subscribe(channels) | |
while True: | |
try: | |
for item in pubsub.listen(): |
This file contains hidden or 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
sudo yum update | |
sudo yum install python27 | |
curl https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py | sudo /usr/bin/python27 | |
sudo easy_install pip | |
echo "alias python='python27'" >> ~/.bashrc | |
source ~/.bashrc |
This file contains hidden or 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 inspect | |
def privatemethod(func): | |
"""decorator for making an instance method private""" | |
def func_wrapper(*args, **kwargs): | |
"""decorator wrapper function""" | |
outer_frame = inspect.stack()[1][0] | |
if 'self' not in outer_frame.f_locals or outer_frame.f_locals['self'] is not args[0]: | |
raise Exception('%s.%s is a private method' % (args[0].__class__.__name__, func.__name__)) | |
func(*args, **kwargs) |
This file contains hidden or 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
try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } |
NewerOlder