Skip to content

Instantly share code, notes, and snippets.

View rsms's full-sized avatar

Rasmus rsms

View GitHub Profile
@rsms
rsms / apk-size-list.sh
Created September 1, 2022 17:50
apk: list installed packages sorted by file size (e.g. alpine linux)
#!/bin/ash
# list installed packages sorted by file size
apk info -e -s \* >/tmp/apksize
awk 'NR % 3 == 1' /tmp/apksize | cut -d ' ' -f 1 > /tmp/apkname
awk 'NR % 3 == 2' /tmp/apksize > /tmp/apksize2
while read -r n unit; do
B=$n
case "$unit" in
@rsms
rsms / macos-distribution.md
Last active January 12, 2025 12:25
macOS distribution — code signing, notarization, quarantine, distribution vehicles
@rsms
rsms / foo.service
Created October 3, 2020 00:18
Example go http server with systemd socket activation and zero-downtime restart
[Unit]
Description = Foo HTTP server
Requires = foo.socket
After = multi-user.target
[Service]
User = www-data
Group = www-data
WorkingDirectory = /var/foo
ExecStart = /var/foo/bin/foo-server
@rsms
rsms / 00-README.md
Last active November 24, 2024 15:14
Example programs and tests for the POSIX Asynchronous file I/O

There are some tests ripped out from git://repo.or.cz/ltp-debian.git/testcases/open_posix_testsuite/conformance/interfaces and made self-containing. They demonstrate and can be used to test the POSIX AIO interface for asynchronous I/O and formerly file IO.

Build with a c compiler (for instance clang or cc):

cc -o aio_read-test aio_read-test.c && ./aio_read-test

Note: Contrary to popular belief, it has been tested and confirmed to actually be asynchronous on Darwin 10.6.0 (xnu 1504.9.26~3).

// Find the latest version of this script here:
// https://gist.github.com/rsms/a8ad736ba3d448100577de2b88e826de
//
const EM = 2048
interface FontInfo {
familyName :string
styleName :string
unitsPerEm :int
ascender :int
@rsms
rsms / grab-twitter-emojis.js
Created December 8, 2016 18:28
Download all Twitter Emojis as SVG
"use strict";
const fs = require('fs');
const https = require('https');
const outdir = __dirname + '/svg';
function DownloadSVG(codepoint) {
return new Promise((resolve, reject) => {
let cpstr = codepoint.toString(16).toLowerCase();
@rsms
rsms / gist:3564654
Created September 1, 2012 05:33
Life is purposeless. And it is beautiful that it is purposeless

Life is purposeless. And it is beautiful that it is purposeless

It is very difficult, particularly for the Western mind, to understand that life is purposeless. And it is beautiful that it is purposeless. If it is purposeful then the whole thing becomes absurd – then who will decide the purpose? Then some God has to be conceived who decides the purpose, and then human beings become just puppets; then no freedom is possible. And if there is some purpose then life becomes businesslike, it cannot be ecstatic.

The West has been thinking in terms of purpose, but the East has been thinking in terms of purposelessness. The East says life is not a business, it is a play. And a play has no purpose really, it is nonpurposeful. Or you can say play is its own purpose, to play is enough. Life is not reaching towards some goal, life itself is the goal. It is not evolving towards some ultimate; this very moment, here and now, life is ultimate.

Life as it is, is accepted in the East. It is not moving towards some end, b

@rsms
rsms / time_diff.js
Last active July 5, 2024 06:56
Relative time between two points in time, expressed in years → months → weeks → days → hours → seconds → milliseconds, accounting for leap years and days-in month.
function time_diff(date1, date2) {
var future_date, past_date;
date1 < date2 ? (past_date = date1, future_date = date2)
: (past_date = date2, future_date = date1);
var D = {},
t = future_date - past_date,
SECOND = 1000,
MINUTE = 6e4,
HOUR = 36e5, // 60 minutes
DAY = 864e5, // 24 hours
@rsms
rsms / playbit-vconsole.sh
Last active July 4, 2024 00:57
Script for connecting to Playbit development console
#!/bin/sh
set -eo pipefail
SOCKFILE="$HOME/Library/Application Support/Playbit/vconsole0.sock"
while [ $# -gt 0 ]; do case "$1" in
-h|-help|--help) cat <<END
Connect a terminal to Playbit
Usage: $0 [--help | <sockfile>]
<sockfile> defaults to $SOCKFILE