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 / 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 February 5, 2024 10:18
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
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 '+/' '-_'
}
import os
import urllib.request
import shutil
import json
import sys
# variables
servers_url = "https://api.nordvpn.com/v1/servers?filters\[servers_technologies\]\[identifier\]=wireguard_udp&limit=999999"
folder_dir = 'wireguard_configs/'