Skip to content

Instantly share code, notes, and snippets.

View tommica's full-sized avatar

Tommi Carleman tommica

View GitHub Profile
@tommica
tommica / resolveCookieConsentState.js
Created May 18, 2026 08:26
Get Cookie Consent State
/**
* Robust CMP consent resolver
*
* Normalized output:
* {
* necessary: boolean,
* functional: boolean,
* analytics: boolean,
* marketing: boolean,
* source: string,
@tommica
tommica / csv2xlsx.sh
Created April 9, 2026 06:30
Convert CSV to XLSX with libreoffice headless mode
#!/usr/bin/env bash
set -euo pipefail
INPUT=""
OUTPUT=""
DELIM=""
ENCODING=""
# --- Check dependencies ---
@tommica
tommica / tmp
Created October 24, 2024 08:09
Hail To The Fish: Migrate your zsh history to fish shell
cat ~/.zsh_history | perl -CSD -pe 's/^: ([0-9]+):[0-9];(.*)$/- cmd: $2\n when: $1\n/' >> ~/.local/share/fish/fish_history
@tommica
tommica / health-check.sh
Last active October 18, 2024 07:30
Poor-mans supervisord
#!/bin/sh
# Check all supervisor status files
supervisor_status_files=$(find /tmp -name "supervisor_status_*" 2>/dev/null)
if [ -z "$supervisor_status_files" ]; then
echo "No supervisor status files found"
exit 1
fi
@tommica
tommica / .editorconfig
Created February 19, 2024 14:09
Code styles for a laravel project
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = false
trim_trailing_whitespace = true
max_line_length = 120
@tommica
tommica / wean-off-google-search.js
Last active April 28, 2023 07:04
Userscript for Weaning off from google search
// ==UserScript==
// @name Wean off from Google Search
// @namespace Violentmonkey Scripts
// @match https://www.google.com/search
// @grant none
// @run-at document-start
// @version 1.0
// @author -
// @description 28/04/2023, 08.56.12
// ==/UserScript==
@tommica
tommica / typeHelpers.ts
Created January 27, 2023 13:26
Typescript type helpers
/**
* This type allows you to replace a certain substring (S) within a Set (T) with a different string (D).
* infer L means that L is inferred as a type that is the part of T before S.
* infer R means that R is inferred as a type that is the part of T after S.
* A is an accumulator variable that holds the replaced string(s) as the recursion progresses.
* The recursion stops when T no longer contains S and the final value of A is returned as the resulting type.
*/
export type Replace<T extends string, S extends string, D extends string,
A extends string = ""> = T extends `${infer L}${S}${infer R}` ?
Replace<R, S, D, `${A}${L}${D}`> : `${A}${T}`
@tommica
tommica / update.sh
Created May 2, 2022 09:05
Update ElixirLS used in the vscode extension
#!/bin/bash
cd /tmp/elixir-ls-update
if [ -d "/tmp/elixir-ls-update" ] ; then
rm -rf /tmp/elixir-ls-update
fi
git clone --depth 1 https://github.com/elixir-lsp/elixir-ls
cd elixir-ls
mix deps.get
mix elixir_ls.release -o ~/.vscode/extensions/jakebecker.elixir-ls-*/elixir-ls-release/
@tommica
tommica / da_DK.po
Created October 19, 2021 07:55
Danish version of wordpress translations - useful to find some standards texts for different situations, for example if password or email is wrong
# Translation of WordPress - 5.8.x - Development in Danish
# This file is distributed under the same license as the WordPress - 5.8.x - Development package.
msgid ""
msgstr ""
"PO-Revision-Date: 2021-10-07 08:20:41+0000\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: GlotPress/3.0.0-alpha.2\n"
@tommica
tommica / mailhog.sh
Created October 6, 2021 08:04
Install mailhog on a server
#!/bin/bash
cd /tmp
wget https://github.com/mailhog/MailHog/releases/download/v1.0.1/MailHog_linux_amd64
mv MailHog_linux_amd64 mailhog
chmod +x mailhog
sudo mv mailhog /usr/local/bin/mailhog
sudo mkdir /etc/mailhog
sudo echo "username:bcryptpw" > /etc/mailhog/auth.file