View count_downloads_pypi.py
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 requests | |
from bs4 import BeautifulSoup | |
def get_downloads_count(package_name: str): | |
badge_url = f"https://static.pepy.tech/badge/{package_name}" | |
response = requests.get(badge_url) | |
download_count = int( | |
BeautifulSoup(response.text, 'html.parser') | |
.find_all('text')[-1].text.replace('k', '000').replace('m', '000000') |
View online_mean_std.py
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 numpy as np | |
# online computation of the mean and the variance. | |
class RollingMean: | |
def __init__(self): | |
self.st = 0.0 | |
self.n = 0 |
View golden_ratio.cfg
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
// y-cruncher Configuration File | |
// Version: 0.7.8 Build 9507 | |
// | |
// Load this from y-cruncher or run directly: | |
// y-cruncher config filename.cfg | |
// | |
// If you're copying Windows file paths into here, be sure to replace | |
// all backslashes "\" with forward slashes "/". Backslash is an | |
// escape character. | |
// |
View find_k_largest_elements_in_2d_array.py
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 numpy as np | |
# FIND LARGEST K ELEMENTS IN A 2D ARRAY IN NUMPY | |
def find_k_largest_elements_in_2d_array(arr: np.array, k=1): | |
assert len(arr.shape) == 2 | |
h, w = arr.shape | |
top_indices = np.flip(arr.flatten().argsort()[-k:]) | |
return np.divmod(top_indices, w) |
View sample.py
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 matplotlib | |
import matplotlib.pyplot as plt | |
import numpy as np | |
matplotlib.use('MACOSX') | |
img_h, img_w = 250, 500 | |
img = np.zeros((img_h, img_w)) |
View keras_multi_gpu.py
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 tensorflow as tf | |
from tensorflow import keras | |
from tensorflow.keras.applications import Xception | |
import numpy as np | |
num_samples = 1000 | |
height = 224 | |
width = 224 | |
num_classes = 1000 |
View selenium_download_file.py
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 new_chrome_browser(headless=True, download_path=os.path.dirname(os.path.abspath(__file__))): | |
"""Helper function that creates a new Selenium browser""" | |
options = webdriver.ChromeOptions() | |
user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.50 Safari/537.36' | |
if headless: | |
options.add_argument('headless') | |
options.add_argument('--window-size=1280x1024') | |
options.add_argument('--disable-gpu') | |
# options.add_argument(f'user-agent={user_agent}') | |
if download_path is not None: |
View get_tinder_token.py
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 json | |
import requests | |
CODE_REQUEST_URL = "https://graph.accountkit.com/v1.2/start_login?access_token=AA%7C464891386855067%7Cd1891abb4b0bcdfa0580d9b839f4a522&credentials_type=phone_number&fb_app_events_enabled=1&fields=privacy_policy%2Cterms_of_service&locale=fr_FR&phone_number=#placeholder&response_type=token&sdk=ios" | |
CODE_VALIDATE_URL = "https://graph.accountkit.com/v1.2/confirm_login?access_token=AA%7C464891386855067%7Cd1891abb4b0bcdfa0580d9b839f4a522&confirmation_code=#confirmation_code&credentials_type=phone_number&fb_app_events_enabled=1&fields=privacy_policy%2Cterms_of_service&locale=fr_FR&login_request_code=#request_code&phone_number=#phone_number&response_type=token&sdk=ios" | |
TOKEN_URL = "https://api.gotinder.com/v2/auth/login/accountkit" | |
HEADERS = { |
View r-deps.sh
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
set -e | |
PACKAGES="$(find . -type f -iname "*.R" -exec cat {} + | grep "^library" | sed 's/library(//g' | cut -d ')' -f 1 | sed -e 's/^"//' -e 's/"$//' | sort -u | xargs)" | |
for package in $PACKAGES; | |
do | |
echo "Installing package: ${package}..." | |
rscript -e "install.packages('${package}', repos='https://cran.rstudio.com')" | |
done |
View extract.sh
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
# On Mac OSX | |
# Will run AIRODUMP scan of all BSSIDs | |
# sudo airport -s | |
# Will run AIRODUMP sniff on channel 11 | |
# sudo airport en0 sniff 11 | |
# Atm, I can't find how to sniff on all channels at the same time. | |
if [ $# -eq 0 ] |
NewerOlder