Skip to content

Instantly share code, notes, and snippets.

View frizz925's full-sized avatar

Izra frizz925

  • Tokyo, Japan
View GitHub Profile
import numpy as np
np.random.seed(1)
inputs = np.array([
[0, 0, 1],
[0, 1, 1],
[1, 0, 1],
[1, 1, 1]
])
@frizz925
frizz925 / main.py
Last active May 28, 2024 02:47
AES-256-CBC w/ Base64 using PyCryptodome library
from Crypto.Cipher import AES
from Crypto.Util import Padding
from hashlib import md5
from base64 import b64encode, b64decode
import sys
passphrase = sys.argv[1]
content = sys.argv[2]
print(passphrase, content)
@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
}
#!/bin/sh
timeout=30
counter=0
echo_error() {
echo $@ >&2
}
password_fallback() {
@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
@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 / 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 / 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 / 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 / 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"