Skip to content

Instantly share code, notes, and snippets.

View jasalt's full-sized avatar

Jarkko Saltiola jasalt

View GitHub Profile
@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> ");
# 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 / 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" >
@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 / 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 / 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 / link_post_translation.php
Created August 26, 2024 13:10 — forked from djoo/link_post_translation.php
WPML Custom end point link 2 existing translation
<?php
/**
* Link the FR translation and the EN translation
* Called by API https://domain.com/wp-json/link_translation/post/
*/
function custom_rest_link_translation($data) {
//Source https://wpml.org/wpml-hook/wpml_set_element_language_details/
@jasalt
jasalt / blender_nrepl.py
Created November 11, 2024 08:59
Hacky blender basilisp nrepl
# by Simo / maqq
# tl;dr; don't use this but see https://github.com/ikappaki/basilisp-blender
import bpy
import uuid
import traceback
from basilisp import main as basilisp, cli
from basilisp.lang import compiler, runtime
from collections import OrderedDict
import socket
@jasalt
jasalt / utils.phel
Last active August 27, 2025 15:15
utils.phel
# Some Phel utility fns / macros
(ns my-project\utils)
(defn parse-float
"Converts to float without doing odd type conversions, acting more like
Float/parseFloat in Clojure."
[x]
(when-not (php/is_numeric x)
(throw (php/new \InvalidArgumentException
(str "Invalid value for parse-float (" x ")"))))
@jasalt
jasalt / wp.phel
Last active August 27, 2025 15:15
wp.phel
### Phel wrapping over WP / PHP API's
## TODO make a library some day..
(ns my-project\lib\wp
(:require phel\str :as str)
(:require phel\pdo :as pdo)
(:require phel\pdo\statement :as statement))
## Initialize WordPress plugin environment for REPL / tests
(defn resolve-wp-load-path