Skip to content

Instantly share code, notes, and snippets.

View MSevey's full-sized avatar
🦝
Looking into purchasing a racoon dog

Matthew Sevey MSevey

🦝
Looking into purchasing a racoon dog
  • Celestia Labs
  • Boston, MA
View GitHub Profile
@MSevey
MSevey / example_test.go
Created July 13, 2023 01:30
Example of how go routines will continue even after a test fails.
package temp
import (
"errors"
"fmt"
"testing"
"time"
"github.com/stretchr/testify/require"
)
@MSevey
MSevey / prettier.json
Created March 9, 2021 15:29
prettier formatting directives for package.json files.
{
"prettier": {
"arrowParens": "always",
"bracketSpacing": true,
"endOfLine": "lf",
"htmlWhitespaceSensitivity": "css",
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"semi": true,
"singleQuote": true,
@MSevey
MSevey / dircreateandbubble.go
Last active November 13, 2020 21:00
Used with the skynet-portal-rename to clean up all the renaming. Add to `modules/renter/renter.go` ~line 1053
// SEVEY: Handle directory rename
if build.Release != "testing" {
f, err := os.Open(filepath.Join(r.persistDir, "dirpaths"))
if err != nil {
return nil, errors.AddContext(err, "unable to open dirpaths file")
}
urp := r.newUniqueRefreshPaths()
r.log.Println("SEVEY: Reading dirs")
totalDirs := 0
scanner := bufio.NewScanner(f)
@MSevey
MSevey / parsepercentages.go
Last active April 24, 2020 13:01
parsePercentages is an implementation of a rounding algorithm that ensures floating point values are rounded in a way that the total adds up to 100%. Additionally this algorithm ensures the order is preserved.
// parsePercentages takes a range of floats and returns them rounded to
// percentages that add up to 100. They will be returned in the same order that
// they were provided
func parsePercentages(values []float64) []float64 {
// Create a slice of percentInfo to track information of the values in the
// slice and calculate the subTotal of the floor values
type percentInfo struct {
index int
floorVal float64
originalVal float64
@MSevey
MSevey / siatest.go
Created December 3, 2019 22:38
This is an example of a simple upload and download test using the siatest package
// TestSiaTest is an example of how to structure a test using the siatest
// package
//
// The testnodes created with the TestGroup can access all the client
// package methods as well as a number of helper siatest methods for common
// tasks.
func TestSiaTest(t *testing.T) {
// These integration tests can take some time and so should be run with a
// longer timeout
if testing.Short() {
@MSevey
MSevey / quicksort.go
Created November 4, 2019 19:26
Easy Quick Sort
package main
import (
"fmt"
"gitlab.com/NebulousLabs/fastrand"
)
func main() {
slice := generateIntSlice(20)
@MSevey
MSevey / quicksort.go
Last active November 4, 2019 19:25
In Place Quick Sort
package main
import (
"fmt"
"gitlab.com/NebulousLabs/fastrand"
)
func main() {
slice := generateIntSlice(20)
@MSevey
MSevey / mergesort.go
Last active November 4, 2019 19:22
Merge Sort
package main
import "fmt"
// mergeSort splits an array into sub arrays until they are of length 1. A
// length 1 array is sorted. Then the sorted arrays are merged
func mergeSort(arr []int) []int {
// If an array has a length of one then it is sorted
length := len(arr)
if length <= 1 {
package main
// This code is for creating copies of a clean Sia node and initiallizing the
// wallet, sending Siacoins to it, setting an allowance, and waiting for
// contracts to form.
// For this context, a clean Sia node is defined as a node that was created with
// ./siad and allowed to fully sync. No other commands or initialization took
// place.
### Keybase proof
I hereby claim:
* I am msevey on github.
* I am sevey (https://keybase.io/sevey) on keybase.
* I have a public key ASBgPwBkubkckUaXx6C1e_qWKmw351gVCmxyLVkpqZ4s-Qo
To claim this, I am signing this object: