Skip to content

Instantly share code, notes, and snippets.

View ivan's full-sized avatar
🕸️

Ivan Kozik ivan

🕸️
View GitHub Profile
@ivan
ivan / tutorial.sh
Last active May 28, 2023 05:40
Using single-file-cli on NixOS without Docker
# or properly via environment.systemPackages
nix-env -iA google-chrome-dev nodePackages.pnpm nodejs_latest
(cd ~/ && git clone https://github.com/gildas-lormeau/single-file-cli)
(cd ~/single-file-cli && pnpm import && pnpm install --ignore-scripts --no-optional --prod)
~/single-file-cli/single-file --browser-executable-path google-chrome-unstable --dump-content "https://twitter.com/"
@ivan
ivan / pg_prefaulter.nix
Last active January 4, 2022 14:08
NixOS configuration for deploying pg_prefaulter
{ pkgs, config, ... }:
let
pg_prefaulter_config = pkgs.writeTextFile {
name = "pg_prefaulter.toml";
text = ''
[log]
# level can be set to "DEBUG", "INFO", "WARN", "ERROR", or "FATAL"
level = "DEBUG"
@ivan
ivan / make-sqlx-data.sh
Last active February 22, 2022 23:27
An alternative to `cargo sqlx prepare --merged` that doesn't rebuild all the crates in the workspace
#!/bin/sh
set -eu -o pipefail
export DATABASE_URL=$(pg_tmp)
psql "$DATABASE_URL" -f schema/schema.sql
# We don't use `cargo sqlx prepare --merged` because it rebuilds everything
for i in crates/{a,b,c}; do
(cd "$i" && cargo sqlx prepare -- --lib)
@ivan
ivan / cargo.sh
Last active December 13, 2024 17:03
cargo wrapper for NixOS and Rust nightly: mold, target-cpu, -Z share-generics
#!/usr/bin/env bash
# NixOS-only cargo wrapper that:
# - always uses mold for linking.
# - sets `-C target-cpu=haswell` to avoid generating code for pre-2013 CPUs.
# - sets `-C link-arg=-Wl,--compress-debug-sections=zlib-gabi` to compress debug sections.
# - sets LIBCLANG_PATH for projects that need clang.
# - sets `-Z share-generics` to reduce output binary sizes by ~2MB.
# - turns on cargo's sparse-registry feature.
# - increases niceness slightly with `nice -n 2` .
@brendanzab
brendanzab / gist:d41c3ae485d66c07178749eaeeb9e5f7
Last active December 27, 2025 06:03
My personal list of Rust grievances (September 2021)

September 2022:

This has spread to a far wider audience than I had anticipated - probably my fault for using a title that is in hindsight catnip for link aggregators. I wrote this back in 2021 just as a bunch of personal thoughts of my experiences using Rust over the years (not always well thought through), and don't intend on trying to push them further, outside of personal experiments and projects.

Managing a living language is challenging and difficult work, and I am grateful for all the hard work that the Rust community and contributors put in given the difficult constraints they work within. Many of the things I listed below are not new, and there's been plenty of difficult discussions about many of them over the years, and some are being worked on or postponed, or rejected for various good reasons. For more thoughts, please see my comment below.

My personal list of Rust gr

@ryangjchandler
ryangjchandler / index.ts
Created September 16, 2021 13:21
Typescript Optional<T> type (Rust-esque)
type Option<T> = Some<T> | None<T>;
interface Optional<T> {
unwrap(): T;
unwrapOr(or: T): T;
isSome(): boolean;
isNone(): boolean;
}
class Some<T> implements Optional<T> {
@ivan
ivan / discord_styles.js
Last active March 7, 2025 17:14
Userscript to fix Discord styles and replace server icons in the sidebar with text labels
// ==UserScript==
// @name Discord: Fix styles
// @namespace discord_styles
// @include *://discord.com/*
// @version 1
// @grant GM_addStyle
// ==/UserScript==
GM_addStyle(`
@ChuckM
ChuckM / farewell.md
Last active June 7, 2021 18:21
On my departure (fictional)

Dear non-executive team members,

All of my options have vested, and I haven’t been offered any new ones so my earning potential here is no longer all that great. Worse, as we’ve operated and developed better understandings of the problems we face it seems less likely than ever that we’ll achieve the vision we set out to achieve. Finally, the blackout periods are having a real negative effect on my ability to diversify my wealth and avoid the high risk of this company’s success chances. Therefore I’m leaving on a “high note” while we can still plausibly call this endeavor a success, and after I’ve left will convert all my equity in this venture into other forms of wealth while not having to report it

@ivan
ivan / nixpkgs-zsh-don-t-load-the-annoying-newuser-module.patch
Created April 1, 2021 18:28
nixpkgs: zsh: don't load the annoying newuser module
From c22f21a459fcf72843ed904b4f3a02edc417478a Mon Sep 17 00:00:00 2001
From: Ivan Kozik <ivan@ludios.org>
Date: Sat, 24 Aug 2019 14:58:00 +0000
Subject: [PATCH] zsh: don't load the annoying newuser module
---
pkgs/shells/zsh/default.nix | 4 ++
pkgs/shells/zsh/dont-load-newuser.patch | 51 +++++++++++++++++++++++++
2 files changed, 55 insertions(+)
create mode 100644 pkgs/shells/zsh/dont-load-newuser.patch
@ivan
ivan / cargo.sh
Last active November 2, 2021 01:19
cargo wrapper script to use lld via RUSTFLAGS="-C link-arg=-fuse-ld=lld" for all projects
#!/usr/bin/env bash
# cargo wrapper to use lld on all projects, which is 2-4x faster to link than bfd:
# https://github.com/rust-lang/rust/issues/39915#issuecomment-538049306
# Note that the advised `-C linker=clang` does not actually make it use lld.
#
# Place this into an executable ~/bin/cargo and edit the real cargo path at the
# end of the wrapper. Remove the nice and choom if not desired.
#
# You will also need to symlink a recent clang to ~/bin/cc so that -fuse-ld=lld works.