Skip to content

Instantly share code, notes, and snippets.

#include <netinet/ip.h>
#include <string.h>
int main(int argc, const char *const *argv) {
struct sockaddr_in6 a =
{ .sin6_family = AF_INET6, .sin6_addr = IN6ADDR_LOOPBACK_INIT };
int s = socket(AF_INET6, SOCK_STREAM, 0);
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &(int) {1}, sizeof(int));
bind(s, (struct sockaddr *) &a, sizeof(a));
getsockname(s, (struct sockaddr *) &a, &(socklen_t) {sizeof(a)});
connect(s, (struct sockaddr *) &a, sizeof(a));
sealed class Optional<out T: Any> {
abstract val isPresent: Boolean
}
object None : Optional<Nothing>() {
override val isPresent: Boolean = false
}
data class Some<T: Any>(val value: T) : Optional<T>() {
override val isPresent: Boolean = true
}
fun <T: Any> T?.asOptional(): Optional<T> = this?.let(::Some) ?: None
#!/usr/bin/env perl
use v5.14;
say s{
^ (?<a> [0369]* ) (?:
(?: (?<b> [147] ) (?<B> (?&a) (?: (?&c) | (?&b) (?&C) ) )
| (?<c> [258] ) (?<C> (?&a) (?: (?&b) | (?&c) (?&B) ) ) )
(?&a)
)* (?<=(\d)) $
}{Fizz$+}rx =~ s/\d*[05]$/Buzz/r =~ s/\D\K\d//r for 1..shift//100;
@ephemient
ephemient / .SRCINFO
Last active February 26, 2018 19:41
hid-apple-dkms
pkgbase = hid-apple-dkms
pkgdesc = hid_apple.ko patched
pkgver = 4.15.5
pkgrel = 1
url = https://www.kernel.org/
arch = x86_64
license = GPL2
depends = dkms
source = https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.15.tar.xz
source = https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.15.tar.sign

Keybase proof

I hereby claim:

  • I am ephemient on github.
  • I am ephemient (https://keybase.io/ephemient) on keybase.
  • I have a public key ASD96woEhLF3IsHyRBF_eoHsvm0RmBNp23n6X9GfZz9ueAo

To claim this, I am signing this object:

#!/usr/bin/env bash
set -eu
TOPLEVEL=$(git rev-parse --show-toplevel 2>/dev/null) PREFIX=$(git rev-parse --show-prefix 2>/dev/null) ||
TOPLEVEL= PREFIX=${PWD#/}
PREFIX=${PREFIX%/} GRADLE= BUILD=
while [[ -z ${GRADLE} || -z ${BUILD} ]]; do
[[ -z ${GRADLE} && -e ${TOPLEVEL}/${PREFIX:+${PREFIX}/}gradlew ]] &&
GRADLE=${TOPLEVEL}/${PREFIX:+${PREFIX}/}gradlew
if [[ -z ${BUILD} && -e ${TOPLEVEL}/${PREFIX:+${PREFIX}/}build.gradle.kts ]]; then
BUILD=${TOPLEVEL}/${PREFIX:+${PREFIX}/}build.gradle.kts
@ephemient
ephemient / .SRCINFO
Last active May 31, 2018 15:30
Anbox image + Open GApps
pkgbase = anbox-image-gapps-git
pkgdesc = Android image for running in Anbox, with Open GApps support
pkgver = 3
pkgrel = 1
epoch = 1
url = http://opengapps.org/
arch = x86_64
license = custom
makedepends = git
makedepends = java-environment-openjdk=8
#!/usr/bin/env python3
import argparse
import contextlib
import ctypes
import dbus
import errno
import fcntl
import io
import os
import pickle
@ephemient
ephemient / .SRCINFO
Last active December 5, 2017 21:42
pam_recent
pkgbase = pam_recent-git
pkgdesc = pam_recent is a small PAM module for making iptables' recent match more useful
pkgver = r12.9c942dc
pkgrel = 1
url = https://github.com/az143/pam_recent
arch = x86_64
license = GPL
provides = pam_recent
conflicts = pam_recent
source = git+https://github.com/az143/pam_recent.git
import heapq
import sys
if sys.version_info >= (3, 0):
xrange = range
def is_prime_trial_division(n):
"""Prime checking by trial division, checking only odds up to sqrt(n).