Skip to content

Instantly share code, notes, and snippets.

View thykka's full-sized avatar
🛠️

Moses Holmström thykka

🛠️
View GitHub Profile
@thykka
thykka / youtube-annoyances.txt
Created August 24, 2024 00:35
Adblock filters for youtube shorts & other annoyances
# Youtube Shorts
www.youtube.com##ytd-guide-renderer a.yt-simple-endpoint path[d^="M10 14.65v-5.3L15 12l-5 2.65zm7.77-4.33"]:upward(ytd-guide-entry-renderer)
www.youtube.com##ytd-mini-guide-renderer a.yt-simple-endpoint path[d^="M10 14.65v-5.3L15 12l-5 2.65zm7.77-4.33"]:upward(ytd-mini-guide-entry-renderer)
www.youtube.com##ytd-browse[page-subtype="home"] .ytd-thumbnail[href^="/shorts/"]:upward(ytd-rich-item-renderer)
www.youtube.com##ytd-browse[page-subtype="subscriptions"] .ytd-thumbnail[href^="/shorts/"]:upward(ytd-grid-video-renderer,ytd-rich-item-renderer)
www.youtube.com##ytd-search .ytd-thumbnail[href^="/shorts/"]:upward(ytd-video-renderer)
www.youtube.com##ytd-browse[page-subtype="subscriptions"] ytd-video-renderer .ytd-thumbnail[href^="/shorts/"]:upward(ytd-item-section-renderer)
www.youtube.com##ytd-watch-next-secondary-results-renderer .ytd-thumbnail[href^="/shorts/"]:upward(ytd-compact-video-renderer,ytd-shelf-renderer)
www.youtube.com##ytd-browse[page-subtype="trending"] .ytd-thumbnail[href^="/sh
@thykka
thykka / timeline.lua
Created June 20, 2024 09:18
PICO-8 Timeline module with Beat sync & drift correction
function init_timeline(state)
tl_scenes={}
tl_state={
time=0,duration=0,
seek_time=0,frame=0,
loop=true,
music_bpm=120.5,
music_sig=4,
music_idx=nil,
fixsync=true,
@thykka
thykka / debug.lua
Created November 13, 2023 10:24
Serializer for PICO-8
--[[
Debug function for Pico-8
- Supports nested tables
- Colors output according to type
- Lists table values in alphanumeric key order
]]
function debug(val,x,y)
local oc=peek(0x5f25)--store original drawing color
local serialized=debug_serialize(val)
@thykka
thykka / grid_neighbors.p8
Last active January 30, 2023 19:09
Grid neighbor search
--[[
Given a 1D-array of cells in a 2D-grid,
and a target cell with x and y coordinates,
it returns a table of neigboring cells.
Given a truthy third parameter,
it also returns diagonally adjacent cells.
]]
@thykka
thykka / tictactoebot.js
Last active May 19, 2022 10:33
Unbeatable Tic-Tac-Toe AI
"use strict";
const OPPONENT = 1;
const RANDOM_OPPONENT = false;
module.exports = {
onTurn: function onTurn(turn) {
try {
const { gameState: state } = turn;
const { x, y, index, message } = makeMove(state);
@thykka
thykka / stage-codemirror-linewrap.user.js
Last active June 8, 2022 07:32
Enable Stage CodeMirror line wrapping
// ==UserScript==
// @name Stage / CodeMirror Line wrapping
// @namespace http://tampermonkey.net/
// @version 0.1.2
// @description Enables line wrapping for CodeMirror, with some responsive tweaks.
// @author Moses Holmström
// @match https://*.stage.crasman.fi/admin/*
// @match https://*.stage.crasman.cloud/admin/*
// @grant none
// @updateURL https://gist.github.com/thykka/53b1e602131a0c86a28bc62a116b9f18/raw/stage-codemirror-linewrap.user.js
@thykka
thykka / debug.lua
Created January 18, 2022 14:58
PICO-8 debug serializer
--[[
Debug function for Pico-8
- Serializes nested tables
- Colors output according to variable's type
- Lists table values in alphanumeric key order
]]
function debug(val,x,y)
local oc=peek(0x5f25)--store original drawing color
local serialized=debug_serialize(val)
// using for-loop structure to perform an action until a condition is satisfied
for(
// for-loop initialization:
// create a var which is a function that returns 0, 1 or 2, given an age
check = age =>
// check for underage
age < 18
? 0
// check for oldness. what would a golfed loop be without a nested ternary?
: age < 66
@thykka
thykka / line-fonts.lua
Last active October 3, 2021 18:12
Line Fonts for PICO-8
--[[
line fonts v0.1 - thykka 2021
==usage==
printl(
text,
x, y,
color,
font_size,
@thykka
thykka / tables.lua
Last active May 4, 2021 20:17
tables.lua
--[[ Table helper functions --
join(tbl)
shuffle(a)
sort(t, a, b)
t_filter(tbl, filter_fn)
t_find_i(tbl, find_fn) -- find_fn optional, defaults to matching equality with find_fn
t_find(tbl, find_fn) -- find_fn optional, -"-
t_flat(tbl)
t_map(tbl, map_fn)