Skip to content

Instantly share code, notes, and snippets.

View fiso's full-sized avatar
🍑

Filip Haglund fiso

🍑
View GitHub Profile
@fiso
fiso / noforyou.js
Last active December 17, 2023 10:17
Switch feed display to "following" on Threads
(function findElementsByContent(content, els) {
function recurse(node) {
if (node.innerHTML === content) {
els.push(node);
}
for (const child of node.children) {
recurse(child);
}
}
function pick<T>(array: T[]): T {
return array[Math.floor(Math.random() * array.length)];
}
function replaceAt(string: string, index: number, replacement: string) {
return (
string.substr(0, index) +
replacement +
string.substr(index + replacement.length)
);

Lathund för militär terminologi

Målgruppen för dokumentet är främst den som arbetar med nyhetsrapportering om militär aktivitet.

Undvik Använd
Krigsföring Krigföring

En expert som i närtid förekommit ofta i public service presenteras konsekvent där som "doktor i krigsföring".

#!/usr/bin/env node
const cp = require("child_process");
const fs = require("fs");
const colors = {
reset: "\x1b[0m",
bright: "\x1b[1m",
dim: "\x1b[2m",
underscore: "\x1b[4m",
blink: "\x1b[5m",
@fiso
fiso / it
Created February 2, 2021 09:01
it
#!/bin/bash
open https://i.imgur.com/M3DPod4.gif
git "$@"
(echo $(($(cat ~/.itcount) + 1)) > ~/.itcount) 2>/dev/null
echo ""
echo "You were visited by the spoopy clown 🤡"
echo "There have been >> `cat ~/.itcount` << clown-related incidents"
@fiso
fiso / spongebob.js
Last active September 8, 2020 10:55
#!/usr/bin/env node
const spongebob = str => [...str].map((c, i) => c[`toLocale${['Lower', 'Upper'][i % 2]}Case`]()).join('');
if (process.argv.length < 3) {
console.error(`Usage: ${process.argv[1]} FUNNY TEXT HERE`)
process.exit(1);
}
console.log(spongebob(process.argv.slice(2).join(' ')));
@fiso
fiso / !lempme.sh
Last active September 2, 2021 13:23
LEMP
#!/bin/bash
if [ $# -ne 1 ]; then
echo 1>&2 "Usage: $0 domainname"
exit 1
fi
DOMAIN=$1
export DEBIAN_FRONTEND=noninteractive
set -e
@fiso
fiso / trustly.js
Last active January 24, 2019 12:00
Helper module for integrating Trustly (https://trustly.com/) payment service with Node.js
const uuid = require('uuid/v1');
const crypto = require('crypto');
const fs = require('fs');
const myPrivateKey = fs.readFileSync('PATH_TO_YOUR_PRIVATE_KEY.pem', 'utf8');
const providerPublicKey = fs.readFileSync('PATH_TO_TRUSTLY_PUBLIC_KEY.pem', 'utf8');
const apiVersion = '1.1';
const request = (method, params) => ((uuid) => ({
method,
@fiso
fiso / ipchange.py
Last active March 16, 2018 08:05
Script that sends a push notification to an endpoint of your choice whenever the public IP of the machine changes. Can be used as a simple homemade tracking device in case someone steals your laptop or something.
#!/usr/bin/python
import os, subprocess
from pushbullet import Pushbullet
PUSHBULLET_API_KEY = "your_pushbullet_api_key"
def getIpFromFile():
with open(os.path.expanduser("~/.externalip"), "r") as f:
return f.read().strip()
console.log(
[...Array(100).keys()].map(n => n + 1).map(n =>
(n % 3 ? "" : "Fizz") + (n % 5 ? "" : "Buzz") || n
).join("\n"));