Skip to content

Instantly share code, notes, and snippets.

Avatar

maxlath maxlath

View GitHub Profile
@maxlath
maxlath / userChrome.css
Last active Oct 12, 2021
Hide "Firefox suggests" text in Firefox 93 search menu
View userChrome.css
/*
Create or edit userChrome.css in your Firefox profile folder,
typically found on Linux at ~/.mozilla/firefox/[your firefox profile folder]/chrome/userChrome.css
*/
.urlbarView-row[label]{
margin-block-start: 0 !important;
}
.urlbarView-row[label]::before{
@maxlath
maxlath / wd_config_from_environment
Created Sep 3, 2021
Setup Wikidata OAuth credentials for wikibase-cli from environment variables
View wd_config_from_environment
#!/usr/bin/env bash
# Assuming that the workflow yaml file sets the following
# env:
# WD_CONSUMER_KEY: ${{ secrets.WD_CONSUMER_KEY }}
# WD_CONSUMER_SECRET: ${{ secrets.WD_CONSUMER_SECRET }}
# WD_TOKEN: ${{ secrets.WD_TOKEN }}
# WD_TOKEN_SECRET: ${{ secrets.WD_TOKEN_SECRET }}
echo "{
@maxlath
maxlath / handlebars2svelte.js
Last active Mar 4, 2021
Convert a Handlebars template to Svelte
View handlebars2svelte.js
#!/usr/bin/env node
// Handlebars and Svelte templates are quite similar (that is, looking a lot like plain HTML),
// so converting from Handlebars to Svelte is mostly a matter of converting handlebars helpers argument syntax
// into Svelte JS-based syntax, and importing the helper functions.
// WARNING: if you have been using named arguments in Handlebars (a.k.a. 'hash' arguments),
// the helper function interface will need to be updated (or the arguments passed as `{ hash: argsObject }`)
// STATUS: WIP.
@maxlath
maxlath / inv_add_publisher.sh
Last active Jan 13, 2021
add publishers to editions on inventaire.io using curl
View inv_add_publisher.sh
# Use your username and password to get session cookies
INV_USERNAME=foo
INV_PASSWORD=bar
INV_SESSION_COOKIES=$(curl -v 'https://inventaire.io/api/auth?action=login' -d "{\"username\":\"$INV_USERNAME\",\"password\":\"$INV_PASSWORD\"}" 2>&1 | grep 'Set-Cookie: inventaire:session' | awk '{print $3}' | xargs echo)
add_claim(){
uri=$1
property=$2
value=$3
curl -s -XPUT "https://inventaire.io/api/entities?action=update-claim" -H "Cookie: $INV_SESSION_COOKIES" -H "Content-Type: application/json" -d "{\"uri\":\"${uri}\",\"property\":\"${property}\",\"new-value\":\"${value}\"}"
@maxlath
maxlath / update_commit_previous_hashes_list
Last active Oct 30, 2020
Keep a list of the hashes by which a commit was previously known
View update_commit_previous_hashes_list
#!/usr/bin/env sh
# A script to keep a list of the hashes by which a commit was previously known
# Adapted from https://stackoverflow.com/a/54352290/3324977
# Installation:
# - copy this script to a directory in your $PATH
# - make it executable:
# chmod +x ./update_commit_previous_hashes_list
# - it should now be accessible from any directory, which can be checked like this:
@maxlath
maxlath / branches-diff
Last active Aug 31, 2020
Display changes made to a file in all the active branches
View branches-diff
#!/usr/bin/env bash
# Display changes made to a file in all the active branches
if [[ $1 == "" ]] ; then
echo "branches-diff <files...|folders...>"
exit 1
fi
branches_on_origin_remote_with_last_commit_less_than_a_year_ago(){
View .aliases
# Initialize the array of favs
source ~/.favs
# Create an alias for each of the favs
for key in $favs
do
directory="$favs[$key]"
alias $key="cd $directory"
done
@maxlath
maxlath / test_sorting.js
Last active Feb 23, 2020
testing performance of sorting with or without pre-sorting
View test_sorting.js
#!/usr/bin/env node
// Environment
// ------------------
// NodeJS: v12.14.0
// CPU: 2.50GHz
// arrays length = 1000 (that is, sorting 1000^2 elements)
// Results
// ------------------
@maxlath
maxlath / decaffeinate_cleanup.js
Last active Nov 10, 2019
completing bulk-decaffeinate and eslint --fix
View decaffeinate_cleanup.js
#!/usr/bin/env node
// To be run after bulk-decaffeinate is done
// bulk-decaffeinate convert --num-workers 8 --config ~/bulk-decaffeinate.config.js
// cleanup(){
// decaffeinate_cleanup.js "$@" && npm run lint-fix "$@"
// }
//
// cleanup **/*.js
@maxlath
maxlath / index.html
Created Nov 3, 2016
allow to add MediaChain as a search engine
View index.html
<!doctype html>
<html>
<head>
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="MediaChain Search" />
</head>
<body></body>
</html>