Skip to content

Instantly share code, notes, and snippets.

View somersbmatthews's full-sized avatar
😀
hello

Somers B Matthews somersbmatthews

😀
hello
  • Mason, OH
  • 05:28 (UTC -04:00)
View GitHub Profile
@somersbmatthews
somersbmatthews / bubble_sort.go
Created January 22, 2021 17:41
bubble sorts #golang #go #algorithms
// ascending, non-decreasing
func BubbleSort(data []int) {
for i := 0; i < len(data); i++ {
for j := 1; j < len(data)-i; j++ {
if data[j] < data[j-1] {
data[j], data[j-1] = data[j-1], data[j]
}
}
}
@somersbmatthews
somersbmatthews / interrupt_cancel.go
Created January 22, 2021 16:55
interrupt cancel #go #golang #context #signal #interrupt
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt)
go func() {
select {
case sig := <-c:
fmt.Printf("Got %s signal. Aborting...\n", sig)
os.Exit(1)
}
}()
@somersbmatthews
somersbmatthews / bcrypt.go
Created January 11, 2021 20:25
bcrypt hashing functions #bcrypt #go
func hashAndSalt(pwd []byte) string {
hash, err := bcrypt.GenerateFromPassword(pwd, bcrypt.MinCost)
if err != nil {
log.Println(err)
}
return string(hash)
}
func comparePasswords(hashedPassword string, plainPassword []byte) bool {
@somersbmatthews
somersbmatthews / surf_error.go
Created December 31, 2020 09:15
surf package returns error for x509 authority certificate
package main
import (
"fmt"
"github.com/headzoo/surf"
)
// const x509UnknownAuthorityError = "Get \"https://digitalmint.exchange/\": x509: certificate signed by unknown authority"
@somersbmatthews
somersbmatthews / vault_operator_init.sh
Created August 30, 2020 21:36
vault operator init with flags #vault
vault operator init -key-shares=3 -key-threshold=2
yarn create react-app my-app
@somersbmatthews
somersbmatthews / restart_shell.sh
Created June 4, 2020 03:38
#bash #shell #zsh
exec -l $SHELL
@somersbmatthews
somersbmatthews / cantfindbundleurl.sh
Last active December 9, 2019 13:27
in case react native can't find bundle url #reactnative #metro #bundler
rm -rf ios/build/ && kill $(lsof -t -i:8081) && watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ rm -f package-lock.json && npm cache clean --force && rm -rf /tmp/metro-* && npm cache verify && npm install && react-native start --reset-cache && react-native run-ios
@somersbmatthews
somersbmatthews / gcp_multizonal_kubernetes.sh
Created November 27, 2019 13:43
multizonal kubernetes cluster #kubernetes #gcp
gcloud container clusters create circle-ci-cluster --zone us-central1-a --node-locations us-central1-a,us-central1-b,us-central1-f --num-nodes 2 --enable-autoscaling --min-nodes 1 --max-nodes 4
@somersbmatthews
somersbmatthews / rails_api_notest_postgresql.sh
Created November 27, 2019 10:25
rails new app generator no tests api only postgres
rails new project-name-here --skip-test --api --database=postgresql