Skip to content

Instantly share code, notes, and snippets.

@arkadijs
arkadijs / sbc-bench.md
Last active October 20, 2023 23:31
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 1
@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'
@arkadijs
arkadijs / 0_pre-req.md
Last active October 9, 2015 21:40
Workshop: React Native mobilization http://ldn.lv/events/222075297

React Native workshop

The instructions below are shortened version of Facebook React Native guides:

  • [Getting started]
  • [Android SDK setup]
  • [Running on Android device]
  • [Running on iOS device]

Mac OS X

@arkadijs
arkadijs / _README.md
Last active September 19, 2015 20:07
Hackathon: Elixir of truth http://ldn.lv/events/224421036

Elixir hackathon

A 16-core Linux VM in the cloud with 104GB of RAM for running search engines:

ssh-add workshop.pem 
ssh elixir@elixir.hosting.lv

A smaller 8-core, 7GB RAM VM in the same zone for running performance tests:

ssh elixir@elixir-test.hosting.lv