Skip to content

Instantly share code, notes, and snippets.

@daveteu
daveteu / config.go
Last active June 23, 2022 15:05
Golang - check env is loaded.
import (
"fmt"
"reflect"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
)
type Config struct {
MongoHost string
@daveteu
daveteu / doveadmpw.go
Created August 21, 2022 08:06 — forked from osiloke/doveadmpw.go
This generate a dovecot password in golang, inspired by https://gist.github.com/garrettreid/8329796
package main
import (
"crypto/sha512"
"encoding/base64"
"fmt"
"math/rand"
"time"
)
@daveteu
daveteu / .bash_aliases
Created September 5, 2022 06:03 — forked from vratiu/.bash_aliases
Git shell coloring
# Customize BASH PS1 prompt to show current GIT repository and branch.
# by Mike Stewart - http://MediaDoneRight.com
# SETUP CONSTANTS
# Bunch-o-predefined colors. Makes reading code easier than escape sequences.
# I don't remember where I found this. o_O
# Reset
Color_Off="\[\033[0m\]" # Text Reset
@daveteu
daveteu / gotestsum_actions.yml
Last active September 6, 2022 06:07
GitHub Actions to run tests and post results on Pull Request
name: gotestsum
# This action works only on pull request
# since the reporter requires the PR id to
# generate a Checks report.
# Using other events will likely fail the action
on: [pull_request]
jobs:
@daveteu
daveteu / chart.js
Created October 3, 2023 01:44 — forked from ashworth-zach/chart.js
candlestick chart with vanilla js
// let metaData = {
// information:"",
// symbol:"",
// lastRefresh:"",
// outputSize:"",
// timeZone:""
// }
let candleOhlcMappings = [];
@daveteu
daveteu / axios-stream.js
Created October 18, 2023 08:30
Axios Read Stream
/*
* How to process stream and NDJson
*/
const matcher = /\r?\n/
const processLine = (line) => {
console.log('line', line)
}
@daveteu
daveteu / fetch-stream.js
Created October 18, 2023 09:15
Fetch - Reading Stream
import ndjsonStream from 'can-ndjson-stream';
const getStream = async () => {
try {
const response = await fetch(url);
const reader = ndjsonStream(response.body).getReader();
let reader;
while (!result || !result.done) {