Skip to content

Instantly share code, notes, and snippets.

View DarkGL's full-sized avatar

Rafał Więcek DarkGL

View GitHub Profile
@DarkGL
DarkGL / int_to_byte_conversion_benchmark.go
Created April 26, 2025 08:51
Golang Fast: Converting 9-Digit Integers to Bytes Benchmark
package benchmark
import (
"strconv"
"testing"
)
var resultSink []byte
func BenchmarkConvertIntToString(b *testing.B) {
@DarkGL
DarkGL / nvvp.md
Created April 11, 2025 05:02 — forked from sonots/nvvp.md
How to use NVIDIA profiler

Usually, located at /usr/local/cuda/bin

Non-Visual Profiler

$ nvprof python train_mnist.py

I prefer to use --print-gpu-trace.

@DarkGL
DarkGL / dod.md
Created November 2, 2024 21:49 — forked from debasishg/dod.md
Data oriented design, hardware awareness, cache awareness in data structures & algorithms
@DarkGL
DarkGL / README.md
Last active January 18, 2025 13:50 — forked from GusAntoniassi/README.md
Configure autocompletion to kubectl with zsh

kubectl with ZSH (oh-my-zsh)

How to configure

Use the following commands to add the kubectl autocomplete to zsh:

mkdir -p ~/.oh-my-zsh/custom/plugins/kubectl-autocomplete/
kubectl completion zsh > ~/.oh-my-zsh/custom/plugins/kubectl-autocomplete/kubectl-autocomplete.plugin.zsh
@DarkGL
DarkGL / dedupe.ts
Created June 12, 2024 02:04 — forked from umstek/dedupe.ts
Deduplicate ESLint configs migrated with Biome
// Needs Bun
import biome from './biome.json';
// Extracted from https://biomejs.dev/linter/rules/#recommended-rules
const recommended = (await Bun.file('./recommended.txt').text())
.split('\n')
.map((x: string) => x.trim())
.filter(Boolean);
@DarkGL
DarkGL / gist:4c0a0e0f73251d8db85c7cb1ee476843
Created June 7, 2024 16:18 — forked from totherik/gist:3a4432f26eea1224ceeb
v8 --allow-natives-syntax RuntimeFunctions
Per https://code.google.com/p/v8/codesearch#v8/trunk/src/runtime.cc
%CreateSymbol
%CreatePrivateSymbol
%CreateGlobalPrivateSymbol
%NewSymbolWrapper
%SymbolDescription
%SymbolRegistry
%SymbolIsPrivate
@DarkGL
DarkGL / GetOptimizationStatus.md
Created June 7, 2024 16:13 — forked from naugtur/GetOptimizationStatus.md
V8 %GetOptimizationStatus

%GetOptimizationStatus return a set of bitwise flags instead of a single value, to access the value, you need to take the binary representation of the returned value. Now, for example, if 65 is returned, the binary representation is the following:

(65).toString(2).padStart(12, '0');
// 000001000001

Each binary digit acts as a boolean with the following meaning:

@DarkGL
DarkGL / lowercase.ts
Last active July 13, 2024 19:01
Disable toLowerCase on already lower cased string
// Step 1: Define the Branded Type
type LowercaseString = string & { __brand: "LowercaseString" };
// Step 2: Type Guard Function
function toLowercaseString(s: string): LowercaseString {
return s.toLowerCase() as LowercaseString;
}
// Step 3: Override Type Definitions
type RemoveToLowerCase<T> = Omit<T, "toLowerCase">;
@DarkGL
DarkGL / branded.ts
Last active May 19, 2024 14:13
Improve Runtime Type Safety with Branded Types in TypeScript
declare const __brand: unique symbol
type Brand<B> = { [__brand]: B }
export type Branded<T, B> = T & Brand<B>
/**
* Branded type for a person's age, should belong to the interval [0, 125] (inclusive)
**/
type Age = Branded<number, "Age">;
/**
@DarkGL
DarkGL / deps-puppetteer-debian9.sh
Created April 17, 2024 22:25 — forked from HugoJBello/deps-puppetteer-debian9.sh
install dependencies debian 9 puppeteer
# https://medium.com/google-cloud/node-to-google-cloud-compute-engine-in-25-minutes-7188830d884e
curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
sudo apt install nodejs
#install dependencies
#https://github.com/GoogleChrome/puppeteer/issues/290#issuecomment-322838700
sudo apt-get install gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget