Skip to content

Instantly share code, notes, and snippets.

View jasalt's full-sized avatar

Jarkko Saltiola jasalt

View GitHub Profile
@jasalt
jasalt / instapusher.py
Last active February 24, 2024 03:39
Instapusher - automatic instagram uploads from a directory
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Instapusher. Push images from a directory automatically to Instagram.
# Schedule script with cron eg:
# 0 18 * * * /path/to/instapusher --login <your_username> \
# --password <your_password> --random-delay 30 <dir>
@jasalt
jasalt / pdfplumber-tesseract.py
Created January 26, 2021 06:25
Extract tables from pdf using pdfplumber and pytesseract
# Extracting tabular data from pdf using Python pdfplumber together with Tesseract OCR
# Author Jarkko Saltiola 2021 (MIT License, Python 3.8.6)
# Pdfplumber, tabula, camelot and probably some other PDF parser utilities have hard
# time parsing tables that have column data overlapping over other columns, and
# probably on many other cases too.
# Pdfplumber gives a good level of control for splitting pdf into parts which can
# be read with it's methods or be passed for pytesseract as PIL image.
@jasalt
jasalt / ssh_ngrok
Created January 3, 2024 13:40
SSH straight to server behind dynamic NGROK address/port using new NGROK API
#!/usr/bin/env bash
# Connect to a dynamic NGROK endpoint that changes ofter after server restart etc.
# Works with single active tunnel (per account) on free tier.
# Provides persistent or dedicated endpoint like premium experience.
# Requires environment variable $NGROK_APIKEY
NGROK_ENDPOINT=$(curl -s https://api.ngrok.com/tunnels -H "authorization: Bearer $NGROK_APIKEY" -H "ngrok-version: 2" | jq -r '.tunnels[0].public_url')
NGROK_HOST=$(echo "$NGROK_ENDPOINT" | cut -d':' -f2 | cut -d'/' -f3)
@jasalt
jasalt / auto_audiocraft_plus.py
Last active December 3, 2023 22:41
Selenium audiocraft_plus batch process
# pip install selene
from selene import browser, by, be
from time import sleep
browser.config.base_url = 'http://127.0.0.1:7860'
browser.config.driver_name = 'firefox'
browser.open('/')
@jasalt
jasalt / thinkfan.conf
Last active November 26, 2023 15:30
Fan profile (/etc/thinkfan.conf) for keeping Skylake Thinkpads silent at work
# This fan config helps to keep Thinkpad silent at work
# With it eg. 200$ second-hand 2-core Skylake laptop T460 and onwards can encode 1440p 30fps h264/h265 with
# Intel QuickSync HW encoder via proprietary VA-API driver https://wiki.debian.org/HardwareVideoAcceleration,
# silently, and stream it via OBS (RTMP/SRT/NDI..) etc..
# To use this fan config on a single-fanned Thinkpad with Debian and systemd, run:
# sudo apt install thinkfan
# sudo echo "options thinkpad_acpi fan_control=1" > /etc/modprobe.d/thinkpad_acpi.conf
@jasalt
jasalt / clock.html
Created November 2, 2023 19:49
OBS Clock HTML Snippet (cheap timecode)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>A simple clock</title>
</head>
<body translate="no" >
# Convert srt file (from eg. pywhispercpp) into csv format with sub start location also in seconds to create Youtube time link.
# Could be useful for annotating livestream recordings from transcription in a spreadsheet.
# Deps (Python 3.11):
# pip install srt
import csv
import srt
def srt_to_csv(srt_file, youtube_link):
@jasalt
jasalt / gist:91ee171ba9b41aad0dbf2c6cd1eaf10f
Last active January 29, 2023 07:32
HTML / JS to embed Github starred repos on web site [WordPress Compatible]
<script src="https://code.jquery.com/jquery-3.6.0.js" integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script>
<div class="gh-starred-repos"></div>
<script>
var urlToGetLatestStarredRepos = "https://api.github.com/users/jasalt/starred?per_page=10";
jQuery(document).ready(function () {
jQuery.getJSON(urlToGetLatestStarredRepos, function (allRepos) {
jQuery.each(allRepos, function (i, repo) {
var repoUrl = jQuery('<a style="color:red;"></a>').text(repo.full_name).attr('href', repo.html_url).appendTo(".gh-starred-repos");
jQuery(".gh-starred-repos").append("<label> [" + repo.description + "]</label>" + " <i><strong>" + repo.language + "</strong> ⭐ " + repo.stargazers_count + " </i> ");
@jasalt
jasalt / hacklabjkl_kävijäseuranta.html
Last active August 4, 2022 08:46
jkl.hacklab.fi Wordpress kävijäseuranta Block rev220804
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>HTML 5 Boilerplate</title>
<!-- <link rel="stylesheet" href="style.css"> -->
<script src="https://code.jquery.com/jquery-3.6.0.js" integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script>
</head>
@jasalt
jasalt / deshortcut_path.py
Created May 31, 2022 17:02
Replace file shortcuts in given path with files they point to (on MacOS).
#!/usr/bin/env python
import glob
import os
import sys
def print_help():
print(''' Replaces file shortcuts in given path with files they represent (on MacOS).
Directory shortcuts are skipped. Requires Python 3.10.