This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
/* | |
Fast 64bit integer log10 | |
WARNING: calling ilog10c(0) yields undefined behaviour! | |
On x64 this compiles down to: | |
pushq %rbp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# there's a bunch of things that don't work properly: | |
# - can't capture computer audio output - it desyncs | |
# - need to change the input devices (`-i "v:a"`) based on the output of `ffmpeg -f avfoundation -list_devices true -i ""` | |
ffmpeg \ | |
-thread_queue_size 150 -f avfoundation -probesize 50M -framerate 30 -pix_fmt uyvy422 -i "2:3" \ | |
-thread_queue_size 150 -f avfoundation -probesize 50M -framerate 30 -pix_fmt uyvy422 -capture_cursor 1 -capture_mouse_clicks 1 -i "4" \ | |
-filter_complex ' | |
[1]fps=fps=30[scr], | |
[scr]scale=-1:1440[scr], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package bulkinsert | |
import ( | |
"context" | |
"database/sql" | |
"errors" | |
"fmt" | |
"strings" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package mysql | |
import ( | |
"bytes" | |
"context" | |
"database/sql" | |
"encoding/csv" | |
"errors" | |
"fmt" | |
"io" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Weak references for Go | |
// Copyright (C) 2021 Carlo Alberto Ferraris | |
// | |
// Based on: | |
// https://lab.nexedi.com/kirr/neo/blob/bb618ce122423c5ff5fa997c5aafd06819cafe40/go/zodb/internal/weak/weak.go | |
// | |
// Original copyright notice: | |
// | |
// Copyright (C) 2018 Nexedi SA and Contributors. | |
// Kirill Smelkov <kirr@nexedi.com> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package xsync | |
import "sync" | |
type TryLocker interface { | |
sync.Locker // Lock(); Unlock() | |
TryLock() bool | |
} | |
// LockAndDo will acquire the lock l and execute fn. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "sync" | |
import "fmt" | |
type Work interface { | |
Process() | |
} | |
type WorkFunc func() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func genOptIface(name string, opt ...string) { | |
if len(opt) == 0 { | |
panic("zero opt types") | |
} | |
if len(opt) > 10 { | |
panic("too many opt types") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <immintrin.h> | |
#include <stdint.h> | |
int getIndexOf(__m512i const *values, int64_t target) | |
{ | |
__m512i valuesSimd = _mm512_loadu_si512(values); | |
__m512i targetSplatted = _mm512_set1_epi64(target); | |
__mmask8 equalMask = _mm512_cmpeq_epi64_mask(valuesSimd, targetSplatted); | |
uint32_t equalMaskInt = _cvtmask8_u32(equalMask); | |
int index = _tzcnt_u32(equalMaskInt); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CFLAGS=-O2 -flto -ffunction-sections -fdata-sections -Wl,--gc-sections | |
CFLAGSNATIVE=-march=native -mtune=native | |
CFLAGSSTATIC=-static | |
build: aw.c | |
gcc -o aw aw.c $(CFLAGS) | |
build-static: aw.c | |
gcc -o aw aw.c $(CFLAGS) $(CFLAGSSTATIC) | |