Skip to content

Instantly share code, notes, and snippets.

View brettinternet's full-sized avatar
👋

Brett brettinternet

👋
View GitHub Profile
@brettinternet
brettinternet / scale-deployments.sh
Last active November 15, 2022 19:12
Scale up or down kubernetes deployments within a container from a bash script
#!/bin/bash
set -e
DEPLOYMENTS="$1"
NUMBER_OF_REPLICAS="${2:-1}"
API_SERVER="https://kubernetes.default.svc"
SERVICE_ACCOUNT_FOLDER="/var/run/secrets/kubernetes.io/serviceaccount"
NAMESPACE=$(cat ${SERVICE_ACCOUNT_FOLDER}/namespace)
@brettinternet
brettinternet / privatebin-dev.sh
Last active August 28, 2024 17:34
Develop PrivateBin client views
#!/bin/bash
# https://github.com/PrivateBin/PrivateBin
if [ ! -f ./conf.ini ]; then
curl https://github.com/PrivateBin/PrivateBin/blob/master/cfg/conf.sample.php \
--output ./conf.ini
fi
mkdir -p tpl
@brettinternet
brettinternet / update-zfs.sh
Created May 27, 2022 17:03
Update zfs-dkms and zfs-utils on Arch Linux with an AUR helper
#!/bin/bash
# Source: https://github.com/Morganamilo/paru/issues/707#issuecomment-1116491359
# e.g. paru or yay
AUR_HELPER="paru"
$AUR_HELPER -Sy
g='/Version/{print $3}'
@brettinternet
brettinternet / package.json
Last active December 24, 2021 19:21
Cross-platform method to pipe Create React App stdout in order to prevent scripts from clearing the console
{
"scripts": {
"start": "ts-node scripts/start-cra"
}
}
@brettinternet
brettinternet / no_afk.ahk
Last active April 5, 2022 20:23
anti afk for games
; Ocassionally moves mouse to a random location
; Use Win+z to enable/disable
Pause On ; Start paused
Loop
{
Random, x, -10, 10
Random, y, -10, 10
Random, SleepDelay, 600, 18000
@brettinternet
brettinternet / get-values.ex
Last active May 22, 2023 17:37
Accessing values in maps, keyword lists, and structs in Elixir
# Accessing values in maps, keyword lists, and structs
# 1. using . they key can’t be missing, works with structs or maps, but not with keyword lists
# 2. using […] works on maps and keyword lists, but not structs. Key can be missing and i’ll return nil
# 3. Map.get(…) works on maps and structs, but not keyword lists. will return nil if key is missing
@brettinternet
brettinternet / markdown.ex
Last active November 7, 2021 21:54
Accept markdown input
# include deps:
# {:earmark, "~> 1.4"},
# {:html_sanitize_ex, "~> 1.4"},
defmodule Utils.Markdown do
@earmark_options %Earmark.Options{
code_class_prefix: "lang-",
smartypants: false
}
@brettinternet
brettinternet / hoist.js
Last active July 3, 2021 22:38
Hoisting in JavaScript
var foo = function() { console.log('bar'); };
function foo() { console.log('baz'); }
foo(); // 'baz' or 'bar' ?
/*
JS isn't really interpreted anymore like truly interpreted languages such as bash.
JS is actually compiled in modern browsers and node into machine code using just-in-time compilation before executing it.
@brettinternet
brettinternet / error.js
Created June 29, 2021 14:34
Extending the JavaScript Error
// reference: https://stackoverflow.com/q/1382107
/**
* @description ES6
*/
class CustomError extends Error {
/**
*
* @param {string} message
* @param {number} code
@brettinternet
brettinternet / settings.json
Created June 29, 2021 02:37
vscode settings for python project with virtualenv
{
"python.linting.pylintEnabled": false,
"python.linting.enabled": true,
"python.formatting.provider": "black",
"python.pythonPath": "~/.virtualenvs/<project_name>/bin/python",
"python.linting.flake8Enabled": true
}