Skip to content

Instantly share code, notes, and snippets.

@ephemient
ephemient / ⁄etc⁄pacman.d⁄hooks⁄linux-modules-post.hook
Last active April 4, 2024 21:49
(Arch Linux) Keep current modules around during kernel upgrade
[Trigger]
Operation = Upgrade
Type = Package
Target = linux
[Action]
Description = Restore Linux kernel modules
When = PostTransaction
Depends = coreutils
Depends = rsync
[Desktop Entry]
Name=Browser chooser
Exec=/usr/local/bin/crostini-browser.sh %U
MimeType=text/html;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;x-scheme-handler/mailto;
Type=Application
NoDisplay=true
OnlyShowIn=Never
@ephemient
ephemient / robolectric-jars⁄build.gradle.kts
Last active July 12, 2023 13:27
Download Robolectric jars using Gradle
// see org.robolectric.plugins.DefaultSdkProvider
enum class Sdk(val apiLevel: Int, val androidVersion: String, val robolectricVersion: String) {
JELLY_BEAN(16, "4.1.2_r1", "r1"),
JELLY_BEAN_MR1(17, "4.2.2_r1.2", "r1"),
JELLY_BEAN_MR2(18, "4.3_r2", "r1"),
KITKAT(19, "4.4_r1", "r2"),
LOLLIPOP(21, "5.0.2_r3", "r0"),
LOLLIPOP_MR1(22, "5.1.1_r9", "r2"),
M(23, "6.0.1_r3", "r1"),
N(24, "7.0.0_r1", "r1"),
@ephemient
ephemient / ⁄etc⁄systemd⁄network⁄90-wifi.network
Created January 29, 2018 19:26
systemd-networkd + wpa_supplicant integration
[Match]
Type=wlan
[Network]
DHCP=yes
[DHCP]
RouteMetric=2048
@ephemient
ephemient / iwatch
Created December 21, 2022 12:39
Run a command whenever changes are detected by inotify
#!/bin/bash
set -euo pipefail
declare -a ARGS=() INOTIFY_ARGS
while (($#)); do
case $1 in
--) break;;
*) ARGS+=("$1");;
esac
shift
done
import java.lang.reflect.Parameter
import java.util.stream.Stream
import kotlin.reflect.KFunction
import kotlin.reflect.KParameter
import kotlin.reflect.full.callSuspendBy
import kotlin.reflect.full.functions
import kotlin.reflect.full.hasAnnotation
import kotlin.reflect.full.isSubtypeOf
import kotlin.reflect.full.isSupertypeOf
import kotlin.reflect.typeOf
{
"include" : [
"default/direct"
],
"define": {
"keymap": {
"A-k": "set-input-mode-hiragana",
"A-l": "set-input-mode-latin",
"C-j": "convert-hiragana",
"C-k": "convert-katakana",
@ephemient
ephemient / share-polyfill.user.js
Created May 27, 2022 04:56
Web Share Polyfill
// ==UserScript==
// @name Web Share Polyfill
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Implements Web Share API using clipboard and downloads
// @author ephemient
// @include https://*/*
// @grant none
// @run-at document-start
// ==/UserScript==
@ephemient
ephemient / invert.html
Created May 9, 2022 06:14
Invert black and white while maintaining colors
<style>
img {
filter: url(#invert);
}
</style>
<svg style="display: none;">
<defs>
<filter id="invert">
<feColorMatrix in="SourceGraphic" type="matrix" values="0.402 -1.174 -0.228 0 1 -0.598 -0.174 -0.228 0 1 -0.598 -1.174 0.772 0 1 0 0 0 1 0"></feColorMatrix>
import android.os.Parcel
import kotlinx.parcelize.Parceler
import kotlinx.serialization.BinaryFormat
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.KSerializer
/**
* This class allows any [kotlinx.serialization.Serializable] type to be easily used within a
* [kotlinx.parcelize.Parcelize] type without implementing [android.os.Parcelable].
*