Skip to content

Instantly share code, notes, and snippets.

View slackingfred's full-sized avatar

Chang Qian (Fred) slackingfred

View GitHub Profile
@slackingfred
slackingfred / useraddx.sh
Created January 27, 2023 05:24
Create new user $1 with authorized pubkey file $2
#!/bin/bash
# 2014-02-26 custom script for adding user on servers.
# Ubuntu servers were not shipped with `adduser` back then.
# For newer versions of Ubuntu, use `adduser` instead.
sudo su
useradd $1
passwd $1
cd /home
mkdir $1
cd $1
@slackingfred
slackingfred / CreateLargeFileNonSparse.cmd
Created January 3, 2024 08:32
Quickly create large non-sparse NTFS file for use of virtual machine disk image
@echo off
REM Administrator privilege required
fsutil FILE createNew "%1" "%2"
fsutil FILE setValidData "%1" "%2"

List of go module knobs for controlling CI, vendoring, and when go commands access the network

By default, a command like go build ignores the vendor directory and will reach out to the network as needed to satisfy imports.

Some teams will not want the go tooling to touch the network in CI, whereas other teams might want greater control during day-to-day work regarding when the go tooling updates go.mod, how dependencies are obtained, and how vendoring is used.

This list is an attempt to build a more consolidated enumeration of some of the primary knobs and options that people might use to adapt the default Go behavior to better suite their particular use cases. Most of this information is currently spread throughout different sections of the official documentation or modules wiki.

The intent of this list is to help socialize the existence of these knobs, without giving all the detai

@slackingfred
slackingfred / format.sh
Created June 20, 2024 21:09
Initialize ephemeral storage of certain AWS EC2 instance types
#!/bin/bash
mkdir -p /data
mkfs.btrfs -d single -m single /dev/nvme1n1
mount /dev/nvme1n1 /data
chmod 777 /data
@slackingfred
slackingfred / add_swap.sh
Created July 17, 2024 20:49
Enable swap on an Ubuntu cloud instance
#!/bin/bash
# Run with sudo
dd if=/dev/zero of=/Win386.swp bs=1M count=4096
chmod 600 /Win386.swp
mkswap /Win386.swp
echo '/Win386.swp none swap sw 0 0' >> /etc/fstab
swapon -a
free -m
@slackingfred
slackingfred / win386.service
Created July 21, 2024 15:14
Systemd config to create swap file in Azure ephemeral volume (B1s and some other instance types, but not all) -- adapted from zram.service
[Unit]
Description=Swap with ephemeral volume
After=multi-user.target
[Service]
Type=oneshot
RemainAfterExit=true
ExecStartPre=/bin/fallocate -l 2560M /mnt/Win386.swp
ExecStartPre=/bin/chmod 0600 /mnt/Win386.swp
ExecStartPre=/sbin/mkswap /mnt/Win386.swp
#!/bin/bash
mkdir -p ~/.local/bin
cd ~/.local/bin
ln -s /usr/lib/llvm-14/bin/clang
ln -s /usr/lib/llvm-14/bin/clang-format
ln -s /usr/lib/llvm-14/bin/llvm-link
ln -s /usr/lib/llvm-14/bin/opt
#!/bin/bash
nmcli con down your-ssid
nmcli con up your-ssid
@slackingfred
slackingfred / distro-repository-installation.md
Last active September 14, 2024 20:20
"rust-analyer failed to load workspace: Failed to find sysroot"

This may happen when Rust is installed by your distro's package manager instead of rustup. The cause is Rust source code not being automatically installed along with the compiler.

To fix, run:

sudo apt install rust-src

or