Skip to content

Instantly share code, notes, and snippets.

View philipperemy's full-sized avatar
🇨🇵
Solving AI together.

Philippe Rémy philipperemy

🇨🇵
Solving AI together.
View GitHub Profile
@philipperemy
philipperemy / count_downloads_pypi.py
Created November 6, 2023 03:26
Count the total downloads of your packages on PyPi
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')
import numpy as np
# online computation of the mean and the variance.
class RollingMean:
def __init__(self):
self.st = 0.0
self.n = 0
// 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.
//
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)
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))
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
@philipperemy
philipperemy / selenium_download_file.py
Created April 9, 2020 10:45
Chromedriver headless download file
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:
@philipperemy
philipperemy / get_tinder_token.py
Created October 18, 2019 01:56
Get tinder token
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 = {
@philipperemy
philipperemy / r-deps.sh
Created October 15, 2019 13:00
R package manager (kind of) - Find and install all dependencies of your R project.
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
@philipperemy
philipperemy / extract.sh
Last active May 21, 2024 10:46
Mac OS - extract handshakes from CAP files of airport command
# 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 ]