Skip to content

Instantly share code, notes, and snippets.

View fikr4n's full-sized avatar

Fikrul Arif fikr4n

  • Telkom
  • Indonesia
View GitHub Profile
@fikr4n
fikr4n / mejik
Created November 20, 2026 14:53
Convert videos or images to AV1, AVIF, or WebP
#!/bin/bash
# The code is the doc.
while getopts 'f:q:p:mi:' opt; do
case "$opt" in
f) format="$OPTARG" ;;
q) qvars+=( "$OPTARG" ) ;;
p) preset="$OPTARG" ;;
m) usemeta=. ;;
i) ifiles+=( "$OPTARG" ) ;;
@fikr4n
fikr4n / loading-heart.svg
Last active November 17, 2026 06:32
SVG animation with SMIL
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fikr4n
fikr4n / floatify.py
Last active January 20, 2025 03:42
Convert float to/from string to illustrate/understand how a double precision floating-point number is encoded based on IEEE 754
#!/usr/bin/env python3
import struct
def to_float(bins):
"""
Convert a binary string to float.
"""
def _expand(s, length):
ei = s.find('..')
if ei == -1: return s
@fikr4n
fikr4n / update.sh
Created September 26, 2024 06:26
GNOME dynamic (slideshow) desktop background (XML) generator
#!/bin/zsh
# Place this file as the sibling of directory 'img/' which contains all the images.
# The output will be 'img.xml' which changes the backgrounds every 24 hours (86400 secs).
cd "${0:h}"
(
cat <<EOF
<background>
<starttime>
@fikr4n
fikr4n / colortoalpha.sh
Created February 28, 2019 06:06
Convert color to alpha with ImageMagick
convert input.jpg -fuzz 20% -transparent white output.png
# taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/
# generate server.xml with the following command:
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
# run as follows:
# python simple-https-server.py
# then in your browser, visit:
# https://localhost:4443
import BaseHTTPServer, SimpleHTTPServer
import ssl
@fikr4n
fikr4n / coroutine-pool.kts
Last active November 12, 2024 06:21
A quick example of thread pool-like Kotlin coroutine
import kotlinx.coroutines.experimental.*
import kotlinx.coroutines.experimental.channels.*
class FixedPool(val workerCount: Int) {
val channel = Channel<Task>()
val jobs = mutableListOf<Job>()
init {
start() // start immediately
@fikr4n
fikr4n / isupertarg.kts
Last active October 13, 2017 03:07
Indirect generic superclass actual type arguments of a Java class (with Kotlin)
#!/usr/bin/env kotlinc -script
import java.lang.reflect.*
import kotlin.reflect.*
fun targ(c: Class<*>) = c.typeParameters.toList()
fun satarg(c: Class<*>) = (c.genericSuperclass as? ParameterizedType)?.
actualTypeArguments?.toList() ?: emptyList()
fun isatarg(c: Class<*>?, ancestor: Class<*>, resolvedT: List<Type>): List<Type>? {
@fikr4n
fikr4n / typeface.py
Last active September 26, 2017 23:03
Translate string in basic latin script to mathematical symbols or add combining character as if the typeface/style is changed/applied
#!/usr/bin/env python3
# Raw table source: https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols
table = (
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',
'๐€๐๐‚๐ƒ๐„๐…๐†๐‡๐ˆ๐‰๐Š๐‹๐Œ๐๐Ž๐๐๐‘๐’๐“๐”๐•๐–๐—๐˜๐™๐š๐›๐œ๐๐ž๐Ÿ๐ ๐ก๐ข๐ฃ๐ค๐ฅ๐ฆ๐ง๐จ๐ฉ๐ช๐ซ๐ฌ๐ญ๐ฎ๐ฏ๐ฐ๐ฑ๐ฒ๐ณ',
'๐ด๐ต๐ถ๐ท๐ธ๐น๐บ๐ป๐ผ๐ฝ๐พ๐ฟ๐‘€๐‘๐‘‚๐‘ƒ๐‘„๐‘…๐‘†๐‘‡๐‘ˆ๐‘‰๐‘Š๐‘‹๐‘Œ๐‘๐‘Ž๐‘๐‘๐‘‘๐‘’๐‘“๐‘”โ„Ž๐‘–๐‘—๐‘˜๐‘™๐‘š๐‘›๐‘œ๐‘๐‘ž๐‘Ÿ๐‘ ๐‘ก๐‘ข๐‘ฃ๐‘ค๐‘ฅ๐‘ฆ๐‘ง',
'๐‘จ๐‘ฉ๐‘ช๐‘ซ๐‘ฌ๐‘ญ๐‘ฎ๐‘ฏ๐‘ฐ๐‘ฑ๐‘ฒ๐‘ณ๐‘ด๐‘ต๐‘ถ๐‘ท๐‘ธ๐‘น๐‘บ๐‘ป๐‘ผ๐‘ฝ๐‘พ๐‘ฟ๐’€๐’๐’‚๐’ƒ๐’„๐’…๐’†๐’‡๐’ˆ๐’‰๐’Š๐’‹๐’Œ๐’๐’Ž๐’๐’๐’‘๐’’๐’“๐’”๐’•๐’–๐’—๐’˜๐’™๐’š๐’›',
'๐– ๐–ก๐–ข๐–ฃ๐–ค๐–ฅ๐–ฆ๐–ง๐–จ๐–ฉ๐–ช๐–ซ๐–ฌ๐–ญ๐–ฎ๐–ฏ๐–ฐ๐–ฑ๐–ฒ๐–ณ๐–ด๐–ต๐–ถ๐–ท๐–ธ๐–น๐–บ๐–ป๐–ผ๐–ฝ๐–พ๐–ฟ๐—€๐—๐—‚๐—ƒ๐—„๐—…๐—†๐—‡๐—ˆ๐—‰๐—Š๐—‹๐—Œ๐—๐—Ž๐—๐—๐—‘๐—’๐—“',
'๐—”๐—•๐—–๐——๐—˜๐—™๐—š๐—›๐—œ๐—๐—ž๐—Ÿ๐— ๐—ก๐—ข๐—ฃ๐—ค๐—ฅ๐—ฆ๐—ง๐—จ๐—ฉ๐—ช๐—ซ๐—ฌ๐—ญ๐—ฎ๐—ฏ๐—ฐ๐—ฑ๐—ฒ๐—ณ๐—ด๐—ต๐—ถ๐—ท๐—ธ๐—น๐—บ๐—ป๐—ผ๐—ฝ๐—พ๐—ฟ๐˜€๐˜๐˜‚๐˜ƒ๐˜„๐˜…๐˜†๐˜‡',
@fikr4n
fikr4n / pygigtk.py
Last active January 5, 2023 15:48
Interactive Python interpreter to play with GTK+ without blocking the console
#!/usr/bin/python3
"""An interactive Python interpreter to play with GTK+ without blocking the console
Usage:
./pygigtk.py
You don't need to call 'Gtk.main' in the console, just start using Gtk, such as
creating a window and 'show_all' it. Gtk, GObject, etc have been imported.
Author: fikr4n <github.com/fikr4n>