Skip to content

Instantly share code, notes, and snippets.

View frizz925's full-sized avatar

Izra frizz925

  • Tokyo, Japan
View GitHub Profile
@frizz925
frizz925 / btrfs-snapshot.sh
Created July 7, 2023 12:56
Bash script to manage Btrfs snapshots
#!/bin/bash
set -eo pipefail
SCRIPT_PATH=$0
MOUNT_DEV=/dev/mapper/fedora-root
MOUNT_PATH=/mnt
SNAPSHOTS_SUBVOL=.snapshots
SNAPSHOTS_PATH="$MOUNT_PATH/$SNAPSHOTS_SUBVOL"
@frizz925
frizz925 / cloud-config.yaml
Created October 5, 2022 12:52
Cloud config for setting up DNSCrypt Proxy and Pi-Hole
#cloud-config
users:
- default
- name: dnscrypt-proxy
gecos: DNSCrypt Proxy User
system: true
package_upgrade: true
packages:
- curl
- supervisor
@frizz925
frizz925 / main.go
Last active April 29, 2021 22:14
Remove empty directories and non-media files
package main
import (
"context"
"errors"
"fmt"
"io/fs"
"io/ioutil"
"log"
"os"
@frizz925
frizz925 / remove-topads.js
Last active June 29, 2023 22:20
Userscript to remove TopAds from Tokopedia's search results
// ==UserScript==
// @name Tokopedia Remove TopAds
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Remove those annoying TopAds from your search results!
// @author Izra Faturrahman <[email protected]>
// @match https://www.tokopedia.com/*
// @grant none
// @run-at document-start
// ==/UserScript==
@frizz925
frizz925 / SetEnv.sh
Created January 1, 2020 18:04
Script for setting up environment for Android NDK
#!/bin/bash
if [ $# -lt 1 ]; then
echo >&2 "Usage: SetEnv.sh <android-arch> [min-sdk-version]"
return 1
fi
if [ -z "$NDK" ]; then
echo >&2 "Missing 'NDK' environment variable"
return 1
@frizz925
frizz925 / ip_dhcp-client.rsc
Created December 15, 2019 11:10
RouterOS commands and scripts for failover setup + load-balancing using PCC
/ip dhcp-client
add interface=ether2 add-default-route=no script=""
# The following is the script used to automatically add and remove the gateway from the DHCP client
:if ($bound = 1) do={
/ip route add dst-address=8.8.8.8 gateway=$"gateway-address" scope=10 comment="ether2 gateway"
} else={
/ip route remove [find comment="ether2 gateway"]
}
@frizz925
frizz925 / pretty-csv.py
Created October 16, 2019 06:04
Simple Python script that reads CSV from stdin then pretty-print them into a table
#!/usr/bin/env python3
import csv
import sys
from typing import Iterable, List
def main():
content_lines = sys.stdin.buffer.readlines()
reader = csv.reader(line.decode('utf-8') for line in content_lines)
headers = next(reader)
@frizz925
frizz925 / palette-extraction.py
Created July 20, 2019 22:56
Extract dominant colors from image using numpy, opencv, and imagemagick
import sys
import cv2
import numpy as np
from wand.color import Color
from wand.drawing import Drawing
from wand.image import Image
MAX_IMAGE_HEIGHT = 600
COLORSCHEME_COUNT = 12
#!/bin/sh
timeout=30
counter=0
echo_error() {
echo $@ >&2
}
password_fallback() {
@frizz925
frizz925 / cat_or_askpass
Last active October 23, 2018 16:40
Keyscript for cryptsetup
#!/bin/sh
timeout=30
counter=0
keyfile="$1"
echo_error() {
echo $@ >&2
}