Skip to content

Instantly share code, notes, and snippets.

View somersbmatthews's full-sized avatar
😀
hello

Somers B Matthews somersbmatthews

😀
hello
  • Phoenix, AZ
  • 01:37 (UTC -04:00)
View GitHub Profile
yarn create react-app my-app
@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
@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 / 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 / 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 / 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 / conputedProperties.swift
Created February 5, 2021 21:21
computed properties view extraction with swift #ios #swift #swiftui
import Foundation
import SwiftUI
struct PeopleView: View {
@ObservedObject var viewModel = PeopleModel()
var body: some View {
VStack {
@somersbmatthews
somersbmatthews / viewModel.swift
Last active February 5, 2021 21:30
view model in swift #swift #ios #swiftui
import Foundation
final class UserModel: ObservableObject {
struct User: Identifiable {
var id = UUID()
var firstName: String
var lastName: String
var email: String
var degree: String
@somersbmatthews
somersbmatthews / functionView.swift
Last active February 6, 2021 04:38
function view in swift #swift #ios #swiftui
import Foundation
import SwiftUI
struct PeopleView: View {
@ObservedObject var viewModel = PeopleModel()
var body: some View {
VStack {
@somersbmatthews
somersbmatthews / api_test.go
Created March 4, 2021 09:51
girc.app api tests
package test
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io/ioutil"
"log"