Skip to content

Instantly share code, notes, and snippets.

View avrebarra's full-sized avatar
👨‍🚀
Experimenting on things

Avre Barra avrebarra

👨‍🚀
Experimenting on things
View GitHub Profile
@avrebarra
avrebarra / main.go
Last active April 18, 2022 05:34
Golang Weighted Response Engine
package main
import (
"fmt"
"math/rand"
"github.com/go-playground/validator"
)
type RespSpec struct {
@avrebarra
avrebarra / view_default.go
Last active December 23, 2021 11:58
avrebarra.github.io/simple-trick-to-know-if-your-code-is-readable/
var (
TableName = "transaction"
)
type Input struct {
TrxID string `validate:"-"`
ReferenceID string `validate:"-"`
UserID string `validate:"-"`
Status string `validate:"-"`
Limit int `validate:"required"`
@avrebarra
avrebarra / numstore.go
Last active December 2, 2021 03:04
avrebarra.github.io/structuring-go-module
package numstore
import (
"context"
"fmt"
)
var (
ErrNotImplemented = fmt.Errorf("feature not implemented")
ErrNotFound = fmt.Errorf("not found")
@avrebarra
avrebarra / basic.go
Last active September 22, 2021 14:14
golang sequence obfuscation
package main
import (
"fmt"
"math"
"math/rand"
"strings"
"time"
)
@avrebarra
avrebarra / lattopegon.js
Created September 13, 2021 13:20
convert latin to pegon
const vocal_list = ["i", "u", "e", "o"];
const ignore_list = [" ", "-", "+", "-", "=", "(", ")"];
const mapper = {
ng: "ع",
ny: "ۑ",
0: "٠",
1: "١",
2: "٢",
3: "٣",
4: "٤",
@avrebarra
avrebarra / validator-humanizer.go
Last active January 16, 2021 08:25
Humanize go-playground/validator validation errors and make it a bit more readable
package govalidatorhumanizer // you can change this
import (
"fmt"
"strings"
ut "github.com/go-playground/universal-translator"
en_translations "gopkg.in/go-playground/validator.v9/translations/en"
"github.com/go-playground/locales/en"
@avrebarra
avrebarra / index.html
Created July 24, 2020 02:10
extract coordinate sequences of canvas-drawn line
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>Coordinates from Line - results shown in log</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<script src='./index.js'></script>
</head>
@avrebarra
avrebarra / params_matcher.go
Created February 13, 2020 08:41
URL Params Matcher - Go
package main
import (
"fmt"
"regexp"
"time"
)
const ParamsRegexPattern = "(:[\\w_]+)"
@avrebarra
avrebarra / helper_test.go
Created November 18, 2019 09:03
Golang Basic Testing Helper
package some_test
import (
"testing"
)
// Credits to (Cory Jacobsen) from this file here https://github.com/unrolled/render/blob/7fc1b8f68b9beddc94385fd212c293caf729277a/render_test.go#L44
/* Test Helper */
func expect(t *testing.T, a interface{}, b interface{}) {
@avrebarra
avrebarra / values_pointers.go
Created September 30, 2019 05:27 — forked from josephspurrier/values_pointers.go
Golang - Asterisk and Ampersand Cheatsheet
/*
********************************************************************************
Golang - Asterisk and Ampersand Cheatsheet
********************************************************************************
Also available at: https://play.golang.org/p/lNpnS9j1ma
Allowed:
--------
p := Person{"Steve", 28} stores the value