Skip to content

Instantly share code, notes, and snippets.

@os11k
os11k / Check followers, visitors and refresh token
Last active October 26, 2024 13:30
Check followers, visitors and refresh token
// Function to save the token to iCloud
async function saveAccessToken(token) {
let fileManager = FileManager.iCloud();
let filePath = fileManager.joinPath(fileManager.documentsDirectory(), "threads_token.txt");
// Save the token to iCloud
fileManager.writeString(filePath, token);
console.log("Access token saved to iCloud.");
}
@os11k
os11k / Check followers and refresh token
Created October 21, 2024 09:02
Check followers and refresh token
// Function to save the token to iCloud
async function saveAccessToken(token) {
let fileManager = FileManager.iCloud();
let filePath = fileManager.joinPath(fileManager.documentsDirectory(), "threads_token.txt");
// Save the token to iCloud
fileManager.writeString(filePath, token);
console.log("Access token saved to iCloud.");
}
@os11k
os11k / Save token to icloud
Created October 21, 2024 09:01
Save token to icloud
let token = "change_me"; // Replace with your actual access token
// Path to the token file in iCloud (Scriptable iCloud directory)
let filePath = FileManager.iCloud().joinPath(FileManager.iCloud().documentsDirectory(), "threads_token.txt");
// Save the token in the file
FileManager.iCloud().writeString(filePath, token);
console.log("Token saved to iCloud.");
@os11k
os11k / Retrieve views for last thread
Last active October 26, 2024 14:36
Retrieve views for last thread
// Define the API URLs and access token
const insightsApiUrlBase = "https://graph.threads.net/v1.0/";
// Function to get the access token from iCloud
async function getAccessToken() {
let fileManager = FileManager.iCloud();
let filePath = fileManager.joinPath(fileManager.documentsDirectory(), "threads_token.txt");
// Check if the file exists
if (!fileManager.fileExists(filePath)) {
#######!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!#######
# PLEASE MAKE SURE DURING BUILD TRANSACTION STEP YOU PUT YOUR OWN POOL ID after required-signer-hash!!!!!!!!!!!!!!!!
# PLEASE MAKE SURE DURING BUILD TRANSACTION STEP YOU PUT YOUR OWN POOL ID after required-signer-hash!!!!!!!!!!!!!!!!
# PLEASE MAKE SURE DURING BUILD TRANSACTION STEP YOU PUT YOUR OWN POOL ID after required-signer-hash!!!!!!!!!!!!!!!!
@os11k
os11k / wise.sh
Created May 17, 2022 18:41
GBPEUR from wise to prometheus
GBPEUR=$(curl -s "https://api.transferwise.com/v3/comparisons/?sourceCurrency=GBP&targetCurrency=EUR&sendAmount=8000" | jq .providers | jq '.[] | select( .alias == "wise" ).quotes' | jq .[].rate)
echo "gbpeur ${GBPEUR}" > /adapools/stats/wise.prom
@os11k
os11k / loki-dashboard-grafana
Created May 7, 2022 18:28
Grafana dashboard to search logs in Loki. Credits: https://grafana.com/grafana/dashboards/13639
{
"__inputs": [
{
"name": "DS_LOKI",
"label": "Loki",
"description": "",
"type": "datasource",
"pluginId": "loki",
"pluginName": "Loki"
}
@os11k
os11k / testnet-topology.json
Last active June 13, 2022 19:05
p2p testnet-topology.json example for relays, don't forget to enable p2p by "EnableP2P": true in testnet-config.json
{
"LocalRoots": {
"groups": [
{
"localRoots": {
"accessPoints": [
{
"address": "bp-host-name/ip",
"port": 3001
},
@os11k
os11k / price.sh
Last active December 25, 2021 15:53
Kraken prices to file, so we can grab them with node exporter
# script should be located under /adapools directory and statistic file in /adapools/stats directory
# mkdir -p /adapools/stats
# our crontab entry:
# * * * * * /adapools/price.sh
# node exporter should be reading /adapools/stats directory something like this:
# --collector.textfile.directory=/adapools/stats
# following metrics should be availlable in grafana, if you did everything right - adaeur, adausd, btcusd & ethusd
PRICES=$(curl -s https://api.kraken.com/0/public/Ticker?pair=ADAEUR,ADAUSD,XXBTZUSD,XETHZUSD)
echo $PRICES | jq .result.ADAEUR.c | jq .[0] | sed 's/"//g'| sed 's/^/adaeur /' > /adapools/stats/price.prom
echo $PRICES | jq .result.ADAUSD.c | jq .[0] | sed 's/"//g'| sed 's/^/adausd /' >> /adapools/stats/price.prom
@os11k
os11k / gist:17258d1d81f4f706b6496f8799a9471a
Last active November 24, 2024 17:42
Homer7 Lua script to change body of header user-agent in CANCEL method
-- With this Lua code we will substitute body of header "User-Agent" to cisco, if there are more then one User-Agent headers, then we will fix them all.
-- Just add this to your docker compose part for heplify-server:
-- volumes:
-- - ./lua:/lua
-- set variables:
-- - "HEPLIFYSERVER_SCRIPTENABLE=true"
-- - "HEPLIFYSERVER_SCRIPTFOLDER=/lua/"
-- put your script in ./lua directory and restart docker-container