Skip to content

Instantly share code, notes, and snippets.

@ephemient
ephemient / Advent of Code 2018.md
Last active February 20, 2025 19:51
my answers in Python
@ephemient
ephemient / ⁄etc⁄systemd⁄system⁄[email protected]
Created December 13, 2018 20:34
Chrome Remote Desktop - DISPLAY=:0 sharing
[Unit]
Description=Chromoting Server for X11
Requires=display-manager.service
Wants=network-online.target user@%i.service
After=display-manager.service network-online.target
[Service]
User=%I
Group=chrome-remote-desktop
PermissionsStartOnly=true
#!/bin/bash
set -euo pipefail
declare -r IFACE=${IFACE:-wg0}
declare -r CONFIG_FILE=${CONFIG_FILE:-/etc/systemd/network/90-${IFACE}.netdev}
declare -r BASE_TIME=${BASE_TIME:-$(date -d '5 minutes ago' +%s)}
declare -A PEERS=()
declare PEER_SECTION= PUBLIC_KEY= ENDPOINT=
import android.content.Context
import android.graphics.Canvas
import android.graphics.Outline
import android.graphics.Path
import android.graphics.Rect
import android.graphics.Region
import android.graphics.drawable.Drawable
import android.graphics.drawable.LevelListDrawable
import android.os.Build
import android.util.AttributeSet
#include <stdlib.h>
#include <string.h>
static void swap(int *a, int *b) {
if (a != b) {
int c = *a;
*a = *b;
*b = c;
}
}
@ephemient
ephemient / pty-example.hs
Created December 30, 2019 08:28
How to fake forkpty without posix-pty
#!/usr/bin/env stack
-- stack script --resolver lts --package "ioctl monad-loops process unix"
{-# LANGUAGE CPP, MultiParamTypeClasses, NondecreasingIndentation #-}
module Main where
import Control.Concurrent (forkFinally, killThread)
import Control.Concurrent.MVar (newEmptyMVar, takeMVar, tryPutMVar)
import Control.Exception (bracket, catchJust, finally)
import Control.Monad (void, when)
import Control.Monad.Fix (fix)
@ephemient
ephemient / example.hs
Created December 30, 2019 08:50
A forkIO'ed thread that is reading from the TTY cannot be killed?
#!/usr/bin/env stack
-- stack script --resolver lts --package unix
module Main where
import Control.Concurrent
import Control.Concurrent.MVar
import System.Posix
main :: IO ()
main = do
@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"),
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
int main() {
int pipefd[2];
close(0);
close(1);
pipe(pipefd);
write(1, "echo $Q\n", 8);
execle("/bin/sh", "sh", NULL, (char *[]) {"Q=echo $Q", NULL});
From: Daniel Lin <[email protected]>
Date: Thu, 11 Feb 2021 15:54:17 -0500
Subject: [PATCH] resolve: configure systemd-resolved's MulticastDNS= setting
When using iwd.conf:[General].EnableNetworkConfiguration=true, it is not
possible to configure systemd.network:[Network].MulticastDNS= as
systemd-networkd considers the link to be unmanaged. This patch allows
iwd to configure that setting on systemd-resolved directly.
---
src/iwd.config.rst | 9 ++++++