Skip to content

Instantly share code, notes, and snippets.

View SamadiPour's full-sized avatar
❤️
Love Coding

Amir Hossein SamadiPour

❤️
Love Coding
View GitHub Profile
@SamadiPour
SamadiPour / aria2_retry.sh
Created August 17, 2024 19:52
A bash script for retrying the failed tasks in Aria2
#!/bin/bash
ARIA_URL="http://127.0.0.1:6800/jsonrpc"
SECRET="secret"
# Step 1: Retrieve GIDs of failed downloads
response=$(curl -s -X POST $ARIA_URL \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
@SamadiPour
SamadiPour / script.sh
Last active November 30, 2023 11:32
Localisation file sorting
# Sort first by Word Count and then Characters count - only if it's is <String, String>
jq 'to_entries | map({ key: .key, value: .value, word_count: (.value | split(" ") | length), char_count: (.value | length) }) | sort_by(.word_count, .char_count) | from_entries' en.json > sorted_en.json && mv sorted_en.json en.json
# Sort first by Word Count, then by Characters count, and then alphabetical - skips collections that are at end
jq '. | to_entries | reduce .[] as $entry ( {}; if $entry.value | type == "object" then .collections += [$entry] else .non_collections += [$entry] end ) | (.non_collections | map({ key: .key, value: .value, word_count: (.value | split("\n") | map(split(" ")) | map(length) | add), char_count: (.value | length) }) | sort_by(.word_count, .char_count, .key)) + .collections | from_entries' en.json > sorted_en.json && mv sorted_en.json en.json
@SamadiPour
SamadiPour / main.js
Last active May 27, 2024 07:23
ADSL TCI plan sorter
const planCards = document.querySelectorAll('#service-list .uk-card');
const cardDetails = [];
function convertPersianNumbersToEnglish(text) {
return text.replace(/[۰-۹]/g, (char) => String.fromCharCode(char.charCodeAt(0) - '۰'.charCodeAt(0) + '0'.charCodeAt(0)));
}
planCards.forEach(card => {
const title = convertPersianNumbersToEnglish(card.querySelector('.uk-card-title').textContent.trim());
const description = convertPersianNumbersToEnglish(card.querySelector('.uk-card-body p').textContent.trim());
@SamadiPour
SamadiPour / script.sh
Created February 19, 2023 14:50
Download the most recent release from GitHub using the checksum - only for releases that have a sha256 file in their release section.
#!/bin/bash
url="https://github.com/<owner>/<repo>/releases/latest/download/<file_name_with_extension>"
current_file="<filename>.<extension>"
if [ -f "$current_file" ]; then
new_checksum=$(curl -L "$url.sha256" | cut -d " " -f 1)
current_checksum=$(shasum -a 256 "$current_file" | cut -d " " -f 1)
# Compare the two checksums
@SamadiPour
SamadiPour / flight-checker.py
Last active April 24, 2023 17:56
Alibaba.ir - Check if flight is available and alert in telegram
import hashlib
import os
import requests
# ============== Variables ==============
url = "https://ws.alibaba.ir/api/v1/flights/domestic/available/"
telegram_token = "" # os.environ["TOKEN"]
chat_id = "" # os.environ["CHAT_ID"]
searches = [
@SamadiPour
SamadiPour / init.ipynb
Last active July 31, 2022 22:55
Deepnote selenium example
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SamadiPour
SamadiPour / main.py
Created July 31, 2022 22:30
Twitter user likes and retweets (BlockList)
import tweepy
import os
import json
client = tweepy.Client(
'TWITTER_KEY',
wait_on_rate_limit=True
)
user_response = client.get_user(username='TWITTER_USERNAME')
@SamadiPour
SamadiPour / bonbast.sh
Created July 8, 2022 21:21
Bonbast Raycast
#!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title bonbast
# @raycast.mode inline
# @raycast.refreshTime 3h
# Optional parameters:
# @raycast.icon 💰
@SamadiPour
SamadiPour / snappfood.js
Last active January 8, 2024 09:37
Snappfood Spent money
cookies = Object.fromEntries(document.cookie.split('; ').map(c => c.split('=')));
let UDID = cookies.UDID;
let jwt = cookies[['jwt-access_token']] ?? JSON.parse(window.localStorage.JWT ?? '{}').access_token;
var myHeaders = new Headers();
myHeaders.append("authority", "snappfood.ir");
myHeaders.append("accept", "application/json, text/plain, */*");
myHeaders.append("accept-language", "en-US,en;q=0.9,fa;q=0.8");
myHeaders.append("authorization", "Bearer " + jwt);
myHeaders.append("content-type", "application/x-www-form-urlencoded");
@SamadiPour
SamadiPour / create_token_bash.sh
Last active June 5, 2022 19:06
Flutter Automated iOS Deployment
#!/bin/bash
issuer_id="9f4xxxx-xxxx-xxxx-xxxx-xxxxxxxxx"
key_id="2F9XXXXXXX"
key_path="./private_keys/AuthKey_2F9XXXXXXX.p8"
expiration_time=$(date -v +60S +%s)
function base64_urlsafe {
base64 | tr -d '\r\n=' | tr '+/' '-_'
}