Skip to content

Instantly share code, notes, and snippets.

@nullscm
nullscm / guix-wsl-infect.sh
Created September 1, 2022 13:06
guix-wsl-infect.sh - Guix System on WSL2
# wget https://github.com/0xbadfca11/miniwsl/releases/download/release3041562/rootfs.tgz
# wsl --import guix /guix rootfs.tgz --version 2
# wsl -d guix /bin/busybox sh -c "/mnt/c/sys/misc/guix-infect.sh"
mkdir -p /root /etc /tmp /var/run /run /home
chmod 1777 /tmp
rm /etc/passwd
cat <<EOM >> /etc/passwd
root:x:0:0:root:/root:/bin/bash
guixbuilder01:x:999:999:Guix build user 01:/var/empty:/usr/sbin/nologin
guixbuilder02:x:998:999:Guix build user 02:/var/empty:/usr/sbin/nologin
@globin
globin / configuration.nix
Last active March 1, 2024 00:46
prometheus on nixos
{ pkgs, lib, config, ... }:
{
networking = {
firewall.allowedTCPPorts = [
3000 # grafana
9090 # prometheus
9093 # alertmanager
];
useDHCP = true;
};
@aras-p
aras-p / preprocessor_fun.h
Last active July 16, 2024 02:50
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@mantoni
mantoni / test.sh
Last active February 9, 2024 15:00
Minimal bash unit testing framework
#!/bin/bash
#
# Copyright (c) 2013 Maximilian Antoni
#
export TEST_COLOR_GREEN="\033[1m\033[32m"
export TEST_COLOR_RED="\033[1m\033[31m"
export TEST_COLOR_TITLE="\033[1m\033[36m"
export TEST_COLOR_OFF="\033[0m"
export TEST_SPACES=" "
export TEST_LINE="-----------------------------------------------------"
@willurd
willurd / web-servers.md
Last active July 22, 2024 15:25
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@mathiasbynens
mathiasbynens / appify
Created November 12, 2010 13:46 — forked from subtleGradient/appify
appify — create the simplest possible Mac app from a shell script
#!/bin/bash
if [ "$1" = "-h" -o "$1" = "--help" -o -z "$1" ]; then cat <<EOF
appify v3.0.1 for Mac OS X - http://mths.be/appify
Creates the simplest possible Mac app from a shell script.
Appify takes a shell script as its first argument:
`basename "$0"` my-script.sh