Skip to content

Instantly share code, notes, and snippets.

View samerickson's full-sized avatar
🎯
Focusing

Sam Erickson samerickson

🎯
Focusing
View GitHub Profile
@samerickson
samerickson / DotEnv.cs
Last active September 11, 2022 21:38
Load .env in C# .NET applications
/// <summary>
/// Loads .env file environment variables into a format that can be used in C#.
/// This allows .NET applications to share a .env file with Docker and Node.js.
/// </summary>
public static class DotEnv
{
/// <summary>
/// Loads the projects .env file into the environment variables used by .NET.
/// </summary>
/// <param name="filePath">Path to the .env file to load.</param>

How to silence the visual bell in linux

Silence the bell in terminal

Create a .inputrc file and add set bell-style none.

Silence the bell in vim

Add set vb t_vb= to your .vimrc.

# This file allows you to combine multiple json files into one
# Just pass all the paths to all the files you want to combine using
# command line arguments
FILES=$@
TMP_FILE="/tmp/results.tmp"
RESULT_FILE=results.json
echo "${FILES}"
@samerickson
samerickson / center-elements.html
Last active June 27, 2020 23:35
I always forget how to center elements both horizontally and vertically in HTML5. This Gist is one way in which you can do that.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body {
background-color: #363537;
color: white;
@samerickson
samerickson / virtual-box-auto-resize.sh
Created June 13, 2020 21:39
Commands that make the display size of VirtualBox windows automatically update.
# Ubuntu
sudo apt install virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11
@samerickson
samerickson / crabs.py
Created May 24, 2020 23:59
Crabs simulator
import random
" Simulate dice roll"
def diceRoll( ):
return random.randint(1, 6)
" Simulates two dice being rolled by returning their sum"
def firstRoll():
return diceRoll() + diceRoll()
@samerickson
samerickson / commands.sh
Last active April 4, 2020 20:28
A collection of commands that I don't want to remember, but also don't want to forget.
# Takes a large number of files and moves them into smaller sub directories.
# I needed this for data sanitation. I wanted to create sub directories that
# countained 100 files. Then I could set goals for myself, say today I am going
# to do 2 subdirectories. This helped me stay motivated and get it done.
split() {
i=0; for f in *; do d=dir_$(printf %03d $((i/100+1))); mkdir -p $d; mv "$f" $d; let i++; done
}
@samerickson
samerickson / disable-gpe06.service
Created January 15, 2019 05:30
Disable interrupts on macbook running linux
[Unit]
Description=Disables GPE 06
[Service]
ExecStart=/usr/bin/bash -c 'echo "disable" > /sys/firmware/acpi/interrupts/gpe06'
[Install]
WantedBy=multi-user.target