Skip to content

Instantly share code, notes, and snippets.

@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() })()
@Hamatti
Hamatti / on24-bookmarklet.js
Created November 9, 2020 18:01
A bookmarklet to add keyboard / presentation clicker support to ON24.com webinar platform
/**
* @author Juha-Matti Santala / @hamatti
*
* This code is a bookmarklet that adds support to ON24.com's presentator view for arrow right/left and page down/up keys
* to switch slides.
*
* If your presentation clicker sends different keys to the computer when clicking next/prev, you can adjust the code by
* changing the if clauses
*/
@Hamatti
Hamatti / alias.sh
Created March 7, 2020 16:00
Asus ZenScreen rotation aliases
# You can find out your display id with displayplacer list
# Find displayplacer at https://github.com/jakehilborn/displayplacer
alias asusportrait='displayplacer "id:[your_display_id] degree:90 origin:(1920, 0)"'
alias asuslandscape='displayplacer "id:[your_display_id] degree:0 origin:(1920, 0)"'