Skip to content

Instantly share code, notes, and snippets.

View FloPinguin's full-sized avatar

FloPinguin FloPinguin

View GitHub Profile
@FloPinguin
FloPinguin / internet-archive-account-size.py
Created December 30, 2021 16:41
Prints the total size of all items from specified internet archive accounts
import subprocess
import io
import math
import json
accounts = ["<Mail address of the IA account>"]
def convert_size(size_bytes):
if size_bytes == 0:
return "0B"
@FloPinguin
FloPinguin / wordpress-com.py
Created December 30, 2021 16:29
How to update wordpress.com posts via API
import requests
# https://stackoverflow.com/questions/48589954/can-i-use-the-rest-api-for-a-site-hosted-on-wordpress-com
# https://developer.wordpress.com/docs/oauth2/
# https://developer.wordpress.com/apps/
access_token = requests.post("https://public-api.wordpress.com/oauth2/token", data={
'client_id': <Redacted>,
'client_secret': '<Redacted>',
'grant_type': 'password',
'username': '<Redacted>',
def send_telegram(msg, log=False):
r = None
try:
token = ""
if log:
token = ""
for start in range(0, len(msg), 4000):
data = {'chat_id': 123456789, 'text': msg[start:start+4000]}
r = requests.post("https://api.telegram.org/bot" + token + "/sendMessage", timeout=30, data=data)
r.raise_for_status()
@FloPinguin
FloPinguin / wait-for-network-share.py
Created February 5, 2020 16:37
Wait for network share in python
import os
import time
share = 'U:'
while True:
print("Checking share availability")
if os.path.isdir(share):
print ("Available!")
raise SystemExit
@FloPinguin
FloPinguin / check-internet-connection.py
Created February 2, 2020 13:54
Wait for internet connection in python
import socket
import time
def is_connected():
try:
socket.create_connection(("www.google.com", 80))
return True
except OSError:
pass
return False
@FloPinguin
FloPinguin / index.html
Created January 27, 2020 17:48
Hashtag Mixer (Very simple webapp)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Hashtag Mixer</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
@FloPinguin
FloPinguin / check-internet.bat
Created January 27, 2020 17:35
Only run .bat after a internet connection is established
:ping
timeout 15
set target=www.google.com
ping %target% -n 1 | find "TTL="
if errorlevel==1 goto ping
DO SOMETHING
@FloPinguin
FloPinguin / dl-youtube-comments.py
Created January 27, 2020 17:32
In a directory structure full of .info.json files (Generated by youtube-dl), get the comments of youtube videos and save them as .comments files (https://github.com/philbot9/youtube-comment-scraper-cli must be installed)
import os
import sys
import json
import subprocess
import datetime
rootdir = 'U:/Hoard'
def log(msg):
sys.stdout.buffer.write((msg + "\n").encode('utf8'))
@FloPinguin
FloPinguin / check-youtube-online.py
Created January 27, 2020 17:28
In a directory structure full of .info.json files (Generated by youtube-dl), check which youtube videos are no longer online (And write them to a file).
import os
import sys
import json
import subprocess
import requests
import datetime
def log(msg):
sys.stdout.buffer.write((msg + "\n").encode('utf8'))
@FloPinguin
FloPinguin / ia-youtube-archive-get-size.py
Created January 27, 2020 17:10
Get the video count and size in GB of a internet archive item which contains mp4s. ia (https://github.com/jjjake/internetarchive) must be installed.
import subprocess
import io
out = subprocess.check_output("ia list " + input() + " -c size -g *.mp4", shell=True)
string = io.StringIO(out.decode("utf-8"))
count = 0
total_bytes = 0
for line in string:
count += 1