Skip to content

Instantly share code, notes, and snippets.

View alexrios's full-sized avatar
🦎
Zigging around

Alex Rios alexrios

🦎
Zigging around
View GitHub Profile
@alexrios
alexrios / TickLeakyBucket.go
Last active May 29, 2021 21:08
Ticker Based Leaky Bucket
package main
import (
"errors"
"fmt"
"sync"
"time"
)
var ErrBucketReachedCap = errors.New("bucket reached its max capacity")
@alexrios
alexrios / starred-until-2020.json
Created January 12, 2021 05:09
All projects starred until 2020
{
"ulr": "https://github.com/ssrathi/go-attr"
}
{
"ulr": "https://github.com/m7shapan/querycsv"
}
{
"ulr": "https://github.com/hotwired/turbo"
}
{
@alexrios
alexrios / k8s-jumpbox.sh
Created December 10, 2020 01:40
Tuneling RDS through K8S
#!/usr/bin/env bash
set -e
TEMP_POD_NAME=postgres-jump-server
LOCAL_PORT=5433
REMOTE_HOST=<postgres-host>
REMOTE_PORT=5432
function cleanup {
@alexrios
alexrios / presign-url.go
Created November 27, 2020 18:17
Creating pre sign URL AWS S3
package main
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
"log"
"time"
)
@alexrios
alexrios / pglock.go
Created November 13, 2020 02:26
Postgres advisory locks with Go
package database
import (
"context"
"errors"
"fmt"
)
import "github.com/jackc/pgx/v4"
// mutex is an implementation of the Mutexer interface
@alexrios
alexrios / utf-8-test.txt
Created November 3, 2020 12:42
UTF-8 stress test (thanks Markus Kuhn)
UTF-8 decoder capability and stress test
----------------------------------------
Markus Kuhn <http://www.cl.cam.ac.uk/~mgk25/> - 2015-08-28 - CC BY 4.0
This test file can help you examine, how your UTF-8 decoder handles
various types of correct, malformed, or otherwise interesting UTF-8
sequences. This file is not meant to be a conformance test. It does
not prescribe any particular outcome. Therefore, there is no way to
"pass" or "fail" this test file, even though the text does suggest a
@alexrios
alexrios / main.go
Created September 13, 2020 01:28
Rate limiting with redis
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/go-redis/redis/v8"
"github.com/go-redis/redis_rate/v9"
@alexrios
alexrios / main.go
Created August 20, 2020 21:12
Formatting json.Marshall() using time.Time
package main
import (
"encoding/json"
"fmt"
"time"
)
type JSONTime time.Time
@alexrios
alexrios / main.go
Created August 20, 2020 17:48
GCP PubSub ~emulator~ client.
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"os"
"time"
@alexrios
alexrios / crypto-wrong-answers.md
Created June 24, 2020 10:36 — forked from paragonie-scott/crypto-wrong-answers.md
An Open Letter to Developers Everywhere (About Cryptography)