Skip to content

Instantly share code, notes, and snippets.

View wannadrunk's full-sized avatar

WannaDrunk wannadrunk

  • Earth
View GitHub Profile
@wannadrunk
wannadrunk / scbam-nav.gs
Last active January 11, 2025 10:09
Get the SCBAM fund nav to Google Sheet.
function getSCBAMNAV() {
var url = 'https://';
var options = {
'method': 'get',
'contentType': 'application/json'
};
var today = Utilities.formatDate(new Date(), Session.getScriptTimeZone(), 'yyyy-MM-dd HH:mm');
var response = UrlFetchApp.fetch(url, options);
var tableNAV = JSON.parse(response.getContentText());
@wannadrunk
wannadrunk / cf_ddns.py
Created December 13, 2024 16:36
Python script to check the IP and update the DNS on Cloudflare.
#!/usr/bin/python3
import requests
from sendnotify import send_telegram_message
cfToken = 'API Token'
cfEmail = 'email@address'
cfZoneID = 'Zone ID'
cfRecordID = 'Record ID'
cfRecordName = 'domain name'
header = {"X-Auth-Email": cfEmail, "X-Auth-Key": cfToken, "Content-Type": "application/json"}
@wannadrunk
wannadrunk / mt-nt-pri-pub
Last active November 18, 2024 14:02
Mikrotik script to reconnect the pppoe when get the private/nat IP from ISP, keep trying to get a public ip.
# Don't forget to change the "wanInterface" value below to your PPPoE interface
:global reconnectCount;
:local wanInterface "pppoe-out1";
:if ($"local-address" in 100.64 .0.0/10) do={
:if ($reconnectCount < 10) do={
:set reconnectCount ($reconnectCount+1);
:log warning ("$wanInterface: Got Private IP ".$"local-address"." Reconnecting the interface...");
@wannadrunk
wannadrunk / mt-nt-pub-cf-ddns.src
Last active September 14, 2023 11:53
MikroTik script to loop the pppoe connection until it get the public IP, not NAT IP. And then update the DNS A record on CloudFlare Name Server.
# Mikrotik Script for loop until get the public IP from NT
# and then set DNS A record to that public IP.
#
# Update WANIF to match your interface name. And all CloudFlare required key and info.
#
# Put this into the ppp profile UP script and assign to pppoe connection
#
:local WANIF "pppoe-1";
@wannadrunk
wannadrunk / reconnectnatip.src
Last active September 14, 2023 14:32
Mikrotik Script to reconnect the pppoe that get the NAT IP. Some ISP provide both public and NAT IP to subscriber. Create a ppp profile and put this script in On Up section. Update the wanInterface according to yours.
:global reconnectCount;
:local wanInterface "pppoe-out1";
:while ( $"local-address" in 100.64.0.0/10 ) do={
:log warning ("$wanInterface: Got Private IP ".$"local-address"." Reconnecting the interface...");
/interface pppoe-client disable $wanInterface;
:delay 10s;
/interface pppoe-client enable $wanInterface;
};
:log info ("$wanInterface: Got IP ".$"local-address");
@wannadrunk
wannadrunk / UnifiController.txt
Created May 2, 2023 11:43
UniFi Controller on Debian based.
#=== Unifi Controller ===
# Add this line to apt source list
deb http://archive.raspbian.org/raspbian stretch main contrib non-free rpi
# add key
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9165938D90FDDD2E
# download installer
wget https://dl.ui.com/unifi/7.3.83/unifi_sysvinit_all.deb
@wannadrunk
wannadrunk / rcln-bak.sh
Last active December 10, 2022 08:31
Bash script to send a notification to Telegram when the rclone COPY/SYNC finish. Script requires `Telegrame Key` and `Chat id`.
#!/bin/bash
### Date: December 2022
### Description: Script to send a notification to Telegram about the RCLONE status.
### Version:
#### 0.1 - initial release
#
# Import global variable
#
@wannadrunk
wannadrunk / loop-test.sh
Created November 18, 2022 05:58
bash script to display the ASCII Art text file. Source of ASCII Art from https://www.asciiart.eu/
#!/bin/bash
clear
while :
do
cat cowfile | cowsay
inxi -F
sleep 3
for TXTFILE in *.txt; do
cat $TXTFILE
@wannadrunk
wannadrunk / db.py
Created March 17, 2022 03:18
SAMPLE SQLAlchemy connect to existing DB/Tables
from sqlalchemy.orm import sessionmaker
from sqlalchemy import create_engine, MetaData, Table
# Using SQLAlchemy reflection example
engine = create_engine('connectionstringhere')
table1meta = MetaData(engine)
table1 = Table('Table_I_Want_to_Interact', table1meta, autoload=True)
DBSession = sessionmaker(bind=engine)
session = DBSession()
results = session.query(table1).filter(table1.columns.TimeStamp>="2019-02-26 18:00:00.000")
@wannadrunk
wannadrunk / syslog-mikrotik.conf
Last active February 24, 2022 15:26
Mikrotik log to syslog-ng - Line 4, update the IP address of your Mikrotik.
# MikroTik – Syslog
source s_mikrotik { udp(port(514)); };
destination d_mikrotik { file("/var/log/mikrotik.log"); };
filter f_mikrotik { host("192.168.88.1"); };
log { source(s_mikrotik); destination(d_mikrotik); filter(f_mikrotik); };