Skip to content

Instantly share code, notes, and snippets.

View RReverser's full-sized avatar
🇺🇦

Ingvar Stepanyan RReverser

🇺🇦
View GitHub Profile
@RReverser
RReverser / config.toml
Created February 8, 2025 20:39
My cargo.config
[env]
[profile.dev.package."*"]
opt-level = 2
[profile.dev.build-override]
opt-level = 2
[net]
git-fetch-with-cli = true
@RReverser
RReverser / cargo_config.toml
Last active February 9, 2025 15:57
PowerShell script to isolate benchmarks as much as possible
[target.x86_64-pc-windows-msvc]
runner = ["pwsh", "D:\\run_bench.ps1"]
use serde::de::{DeserializeSeed, MapAccess, Visitor};
use serde::{forward_to_deserialize_any, Deserializer};
use std::fmt::Formatter;
struct CaseInsensitiveStructWrapper<T> {
fields: &'static [&'static str],
inner: T,
}
impl<T> CaseInsensitiveStructWrapper<T> {
@RReverser
RReverser / venues-to-loc.mjs
Created March 22, 2024 15:19
Resolve locations from all checkins from your Foursquare GDPR data export
import { readFile, writeFile } from 'fs/promises';
// Get a Places API key at https://foursquare.com/developers/home.
const FOURSQUARE_PLACES_API_KEY = 'XXX';
// First, collect all deduplicated venue IDs.
let venueIds = new Set();
for (let i = 1; ; i++) {
try {
var json = require(`./checkins${i}.json`);
@RReverser
RReverser / bisect.ps1
Created December 1, 2023 19:11
Bisect list of files within a large commit
$files = git diff --name-only main
# Binary search for a file that causes `./test/runner other.test_closure_type_annotations` to fail.
# At each step, try to revert half of the files to `main` branch.
# In the end $files will contain only the files that cause the test to fail.
while ($files.Length -gt 1) {
Write-Output "Testing $($files.Length) files:"
$files | ForEach-Object { Write-Output " $_" }
$mid = [math]::floor($files.Length / 2)
if test "$prefix" = NONE; then
# Set prefix for installations to the Emscripten's sysroot.
prefix=$EMSDK/upstream/emscripten/cache/sysroot
# Mainly used by libtool, but doesn't hurt to set it for all autoconf scripts.
with_sysroot=$prefix
# Set host to switch autotools into cross-compilation mode.
host_alias=$($CC $CFLAGS --print-target-triple /dev/null -E)
# Ignore warnings about "using cross tools not prefixed with host triplet"
ac_tool_warned=yes
# Create cache file, but be careful to set it per-target so that
choco list --limit-output
# Extract name and find corresponding winget package
| ForEach-Object -Parallel {
$chocoName = $_.Split('|')[0]
Get-WinGetPackage $chocoName -Count 1 |% {
@{
'chocoName' = $chocoName
'wingetPackage' = $_.Name
}
}
namespace Atmo;
public class Interop
{
public static void HelloWorld()
{
Console.WriteLine(DateTimeOffset.UnixEpoch);
}
static void Main() {
@RReverser
RReverser / gist:2dc92bdd7c67ec734dc68b462f976182
Created December 29, 2022 20:21
JS <-> Rust Wasm conversion benchmarks
=====
parse
=====
canada x serde_json x 14.41 ops/sec ±3.31% (40 runs sampled)
canada x serde_wasm_bindgen x 90.55 ops/sec ±0.53% (77 runs sampled)
canada x msgpack x 101 ops/sec ±1.90% (72 runs sampled)
citm_catalog x serde_json x 131 ops/sec ±0.64% (83 runs sampled)
citm_catalog x serde_wasm_bindgen x 192 ops/sec ±1.02% (85 runs sampled)
citm_catalog x msgpack x 161 ops/sec ±1.09% (82 runs sampled)
twitter x serde_json x 203 ops/sec ±0.89% (85 runs sampled)
import cv2
import numpy as np
# Read the image
img = cv2.imread('sky.jpg')
# Convert the image to grayscale
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Use a threshold to detect stars in the image