Skip to content

Instantly share code, notes, and snippets.

View musantro's full-sized avatar

Antonio Rodríguez musantro

View GitHub Profile
@musantro
musantro / async_get_distance.py
Created June 10, 2024 06:48
Get distance from two cities
import asyncio
import math
from typing import Any, Final
import aiohttp
earth_radius: Final[str] = 6_371 # km
host: str = "https://nominatim.openstreetmap.org/"
endpoint: str = "/search"
global_parameters: dict[str, Any] = {
@musantro
musantro / order_playlist_by_intensity.py
Last active October 26, 2023 18:46
How to be the nerdiest, coolest DJ at your party
# This script sorts your playlist into a new playlist by energy and danceability, two features given by Spotify.
# More info here https://developer.spotify.com/documentation/web-api/reference/get-several-audio-features
# STEP 0: pip install spotipy
# STEP 1: Create an Spotify Developer APP here https://developer.spotify.com/dashboard/create and create an API
# Input Variables - Fill these out and run
YOUR_APP_CLIENT_ID = "YOUR_APP_CLIENT_ID"
YOUR_APP_CLIENT_SECRET = "YOUR_APP_CLIENT_SECRET"
import requests
import json
import os
import time
# Constants for the Mega API endpoints and parameters
API_BASE_URL = "https://g.api.mega.co.nz/cs"
LS_ENDPOINT = "/fs/ls"
MKDIR_ENDPOINT = "/fs/mkdir"
MV_ENDPOINT = "/fs/mv"
@musantro
musantro / is-driving.py
Last active January 28, 2022 13:46
OBS Script to automatically change scene in iRacing
# Author: Antonio Rodríguez (@musantro)
# Date: 2022-01-28
# This code is licensed under the terms of the MIT license
import obspython as obs
import irsdk
interval = 3
on_track_scene_prop = ""
off_track_scene_prop = ""
@musantro
musantro / followAllGAIA.js
Last active May 4, 2017 20:35
Script to follow everyone on GAIA
// Copy all lines from this code, open a tab and go to GAIA You & Me Section and
// paste it into Console of Google Chrome (Press F12 to show the Console), and press ENTER.
// enjoy #Gaians :)
var i = 1; // set your counter to 1
function myLoop () { // create a loop function
setTimeout(function () { // call a 3s setTimeout when the loop is called
var element = document.querySelectorAll('.follow.ng-scope .follow-link');
element[0].click() // your code here
@musantro
musantro / engagementRatio.js
Last active January 13, 2017 15:42
Get Engagement Ratio of your Publications in Facebook
// Copy & Paste this into your console using F12 in this page:
// https://www.facebook.com/yourFacebookPage/insights/?section=navPosts
// It console.table you your best posts sorted by Engagement Ratio
const pubs = document.querySelectorAll('._5kn3.ellipsis');
const title = document.querySelectorAll("._5591");
const date = document.querySelectorAll('._5k4c > :first-child');
titles = [];
title.forEach(item => titles.push(item.innerText));
@musantro
musantro / cleanupFiles.bat
Last active August 1, 2016 09:55
This script deletes all files and folders older than 15 days fron an specific destination folder.
@echo off
:: set folder path
set dump_path=E:\musan\Downloads\Contenedor
:: set min age of files and folders to delete
set max_days=15
:: remove files from %dump_path%
forfiles -p %dump_path% -m *.* -d -%max_days% -c "cmd /c del /q @path"
@musantro
musantro / drop.js
Created November 18, 2015 16:23
Drop the elements of an array (first argument), starting from the front, until the predicate (second argument) returns true.
function drop(arr, func) {
// Drop them elements.
var length = arr.length;
for(i=0;i<=length;i++){
if(func(arr[0])){
return arr;
}
console.log(arr);
arr.shift();
if(arr.length === 0){
@musantro
musantro / smallestCommons.js
Created November 18, 2015 16:12
Small js file to find the smallest Commons between 2 numbers
function smallestCommons(arr) {
arr.sort();
var first = arr[0];
var last = arr[1];
var multiplier = 1;
var bool = [];
var multiple = 0;
while(bool.length < last){
bool = [];