Skip to content

Instantly share code, notes, and snippets.

View Hamatti's full-sized avatar

Juha-Matti Santala Hamatti

View GitHub Profile
@Hamatti
Hamatti / start_projector.py
Last active June 9, 2025 05:31
A script that runs Playwright to open my Epson projector's web ui and clicks power button to start my projector.
#!/usr/bin/env -S uv run --quiet --script
# requires installation of Playwright browsers before this script is run
# can be done with `pipx run playwright install`
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "python-dotenv",
# "playwright",
# ]
@Hamatti
Hamatti / link.sh
Created April 26, 2025 16:30
A script to make scripts runnable and symbolically linked to /usr/local/bin in zsh
@Hamatti
Hamatti / find_links_from_markdown_documents.sh
Created April 7, 2024 10:02
Find all the links shared from my Syntax Error newsletter issues that are stored in my notes system using pcregrep
@Hamatti
Hamatti / liiga-bookmarklet.js
Created March 2, 2024 10:01
Bookmarklet for custom Liiga.fi experience.
/**
* A bookmarklet to highlight teams in standings in Liiga.fi
* You can use https://caiorss.github.io/bookmarklet-maker/ to turn this into a minified bookmarklet
*
* This works best when combined with custom CSS (I use Stylus extension for that) which hides everything
* except schedule and standings. See liiga.css.
*/
/**
* Injects our custom stylesheet into the `<head>`
@Hamatti
Hamatti / background.js
Last active November 9, 2022 19:45
Example code for a browser extension that uses extension page to ask for a user token if it does not exist and runs a function after it gets a token
/* Create and open extension page type of "panel"
function openForm() {
const createData = {
type: "panel",
url: "extensionPage.html",
width: 250,
height: 250
};
browser.windows.create(createData);
}
@Hamatti
Hamatti / README.md
Last active December 8, 2021 21:43
Liiga.fi customizations
@Hamatti
Hamatti / bot.js
Last active August 2, 2021 14:45
Very simple Discord bot skeleton
const Discord = require('discord.js');
const cron = require('cron');
const client = new Discord.Client();
client.login(process.env.BOT_TOKEN);
const job = new cron.CronJob("00 00 10 * * *", () => {
client.channels.cache.get("[channel id]").send("Tick tock");
});
@Hamatti
Hamatti / pattern_match_example-nesting.py
Last active March 11, 2021 11:46
Nested pattern matching in Python 3.10a6
class Card:
def __init__(self, id, name, supertype, subtype):
self.id = id
self.name = name
self.supertype = supertype
self.subtype = subtype
def play_card(card):
match card:
@Hamatti
Hamatti / pattern_match_example.py
Created March 11, 2021 10:26
Python pattern matching for Pokemon cards. Works on Python 3.10a6
class Card:
def __init__(self, id, name, supertype, subtype):
self.id = id
self.name = name
self.supertype = supertype
self.subtype = subtype
charizard = Card('ex3-100', 'Charizard', 'Pokemon', 'Stage 2')
lapras = Card('ex3-103', 'Lapras', 'Pokemon', 'Basic')
muscle_band = Card('xy1-121', 'Muscle Band', 'Trainer', 'Item')
@Hamatti
Hamatti / areena.js
Created December 6, 2020 15:32
Bookmarklet for removing YLE Areena's live chat
// This bookmarklet is for removing the live chat from YLE Areena
// Copy-paste the line below into the URL field of a new bookmark
javascript:(function() { document.getElementById('yle-livefeed').remove() })()