Skip to content

Instantly share code, notes, and snippets.

View matthewoestreich's full-sized avatar
♠️
👋

Matt Oestreich matthewoestreich

♠️
👋
View GitHub Profile
type JobReact struct {
name string
Duration time.Duration
Info interface{}
Error error
}
func (m *JobReact) Name() string {
return m.name
}
@matthewoestreich
matthewoestreich / worker_pools_demo.go
Last active September 24, 2020 21:09
How to create and use worker pools - learning about goroutines + channels
package main
/**
* Each worker calculates fibonacci sequence for N int in order to show how worker pools can be utilized.
*
* Instructions:
* UNCOMMENT `DemoCreateSingleWorker()` OR `DemoCreateOneWorkerPerCPUCore()`
* FOR BEST RESULTS, ONLY UNCOMMENT ONE AT A TIME
*
* BE WARNED THIS CAN GET PRETTY INTENSE ON YOUR CPU AFTER LIKE 2 MIN
@matthewoestreich
matthewoestreich / main.go
Created September 17, 2020 03:19
GoDaddy Dynamic DNS
package main
import (
"errors"
"fmt"
"io/ioutil"
"net/http"
"os"
"strings"
@matthewoestreich
matthewoestreich / commands.sh
Last active August 23, 2020 23:16
Create mdadm raid array Ubuntu 20.04
# Credit to https://www.youtube.com/watch?v=o_PnB7bHhA0
# create raid based upon drives
sudo mdadm --create /dev/md1 --level=1 --raid-devices=4 /dev/sd[a-d]
# list drives
lsblk
# get status of raid setup
# CHANGE md0 TO WHATEVER YOU WANT TO CALL THE PARTITION
@matthewoestreich
matthewoestreich / named_params_example.sh
Last active August 21, 2020 19:55
Example of how to use named params in bash
#!/bin/bash
#
# Use like:
# ./this-script.sh --container_name yourcontainername
#
printf '%s\n' "[NOTE] We assume you have a 'Dockerfile' at the root of this project"
container_name=${container_name:-}
@matthewoestreich
matthewoestreich / upgrade_kubectl_v1.19.0-rc.1.sh
Created August 16, 2020 22:16
Upgrade kubectl to v1.19.0-rc.1
#!/bin/bash
curl -LO "https://storage.googleapis.com/kubernetes-release/release/v1.19.0-rc.1/bin/linux/amd64/kubectl"
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
kubectl version --client --short
@matthewoestreich
matthewoestreich / docker-compose.rabbitmq.yaml
Last active August 12, 2020 02:18
docker-compose for rabbitmq with mgmt web interface
# -------------------------------------- #
# ------------- How to use ------------- #
# -------------------------------------- #
# 1) Run: docker-compose up -d
# 2) Go to: http://localhost:15672
# 3) Default Creds: guest/guest` (obviously, this is if you don't use the `environment` vars below)
# rabbitmq port list at EOF
version: "3.7"
@matthewoestreich
matthewoestreich / javascript_property_descriptors.js
Last active August 9, 2020 08:34
JavaScript Property Descriptors
// https://flaviocopes.com/javascript-property-descriptors/
const js_standard_property_descriptors_and_definitions = {
value: "the value of the property",
writable: "true the property can be changed",
configurable: "if false, the property cannot be removed nor any attribute can be changed, except its value",
enumerable: "true if the property is enumerable",
get: "a getter function for the property, called when the property is read",
set: "a setter function for the property, called when the property is set to a value",
};
@matthewoestreich
matthewoestreich / fix.sh
Created July 17, 2020 21:26
Fix GYP NPM/Node issue after Mac updates - this happens to me after every update...
#!/bin/bash
sudo rm -rf $(xcode-select -print-path)
xcode-select --install
@matthewoestreich
matthewoestreich / DOMRegex.js
Last active March 16, 2023 23:30
Essentially querySelectorAll with regex support. Modified from: https://stackoverflow.com/a/62144522
/**
* @plug
* DOMRegex.js
* https://mattoestreich.com
*
* @description
* Modified from: https://stackoverflow.com/a/62144522
* TLDR; querySelectorAll with regex support
*
* @important