Skip to content

Instantly share code, notes, and snippets.

@arkadijs
arkadijs / aosc-mesa.md
Last active August 17, 2024 21:47
Mesa 3D retro survey

Mesa 3D retro survey

Surveying retro graphics cards...

Device 24.1.3 21.3.9 amber 20.3.5 [^1]
R600 Radeon HD2600 XT glxgears
- OpenGL 3.3, GLES 3.0 glquake[^2]
- RV630 [^10] lzdoom
@arkadijs
arkadijs / loopback.c
Last active July 24, 2024 07:43
PortAudio capture WASAPI synthetic [Loopback] device
#include <fcntl.h>
#include <io.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include "portaudio.h"
@arkadijs
arkadijs / sbc-bench.md
Last active September 4, 2024 20:06
Selected sbc-bench results

Based mostly on sbc-bench submissions and a few entries of my own testing. Ordered by 7-zip single threaded performance. Italic MHz font marks overclock.

Device Clock MHz Kernel Distro 7-zip multi single AES kB/s memcpy memset MB/s latency s/dual hugepg ns
Apple M1 Pro 3030/2060 5.18 Gentoo arm64 43800 5010 1064450 27110 71910 100/126
Pentium G4600 (Kaby Lake, 2017) 3600 4.19 Buster amd64 11810 4448 984820 15120 33380 76/83 64/73
Qualcomm Snapdragon 8cx Gen 3 3000/2440 6.3 Lunar arm64 35370 4312 1686160
@arkadijs
arkadijs / pipeline.go
Last active May 5, 2023 14:34
Streaming Writer-based pipeline in Go
package main
import (
"fmt"
"io"
"strings"
)
const rate = 2 // bytes per millisec of "audio"
@arkadijs
arkadijs / external-dns.yaml
Created December 18, 2020 22:27
Socks and HTTP proxy in Kubernetes with ingress via Traefik (with SNI) or via Nginx, also ExternalDNS
apiVersion: externaldns.k8s.io/v1alpha1
kind: DNSEndpoint
metadata:
name: proxy
spec:
endpoints:
- dnsName: proxy.superhub.io
recordTTL: 300
recordType: CNAME
targets:
@arkadijs
arkadijs / cache.js
Last active October 20, 2022 13:25
Serialize and Cache JavaScript Promise
const defaultTtl = 60 * 60;
const validAtLeast = 10 * 1000;
const retry = 5 * 1000;
function cache(retrieve) {
const context = {
expireAt: 0,
promise: null,
get() {
@arkadijs
arkadijs / Main.java
Created December 16, 2016 12:06
Dekker's algorithm
package dekker;
public class Main {
private static volatile boolean flag0 = false;
private static volatile boolean flag1 = false;
private static volatile int turn = 0;
private static long count = 0;
private static long count0 = 0;
private static long count1 = 0;
@arkadijs
arkadijs / channels.rs
Created September 10, 2016 15:43
Beauty of Rust
use std::char;
use std::collections::HashMap;
use std::thread;
use std::sync::{Arc, Barrier};
use std::sync::mpsc::{channel, Sender};
const NTHREADS: u32 = 5;
fn slow(n: u32) -> char {
thread::sleep_ms(n);
import (
"archive/zip"
"fmt"
awss3 "github.com/aws/aws-sdk-go/service/s3"
"io"
)
var s3 *awss3.S3
head, err := s3.HeadObject(
@arkadijs
arkadijs / catc.sh
Last active March 1, 2016 21:41
Cat's C Xcode template
#!/bin/sh -xe
cd $HOME/Library/Developer/Xcode
tmpl='Templates/File Templates/Source'
catc=$tmpl/'Cat C File.xctemplate'
mkdir -p "$tmpl"
cp -pr '/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates/Source/C File.xctemplate' "$catc"
find "$catc" -name '*.[ch]' -print0 |
xargs -0 sed -i '' -e 's@___COPYRIGHT___@ != == > <\
// \&\& ||@g'