Skip to content

Instantly share code, notes, and snippets.

@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) {
@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 / 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 / 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 / .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 / 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 / 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 / go-ssh-reverse-tunnel.go
Created June 10, 2022 10:37 — forked from codref/go-ssh-reverse-tunnel.go
Go SSH reverse tunnel implementation (SSH -R)
/*
Go-Language implementation of an SSH Reverse Tunnel, the equivalent of below SSH command:
ssh -R 8080:127.0.0.1:8080 operatore@146.148.22.123
which opens a tunnel between the two endpoints and permit to exchange information on this direction:
server:8080 -----> client:8080
@daveteu
daveteu / keysUndefined
Last active January 6, 2022 04:47
Find undefine keys in plain object
/**
* @param {object} obj plain object with { key: value }
* @param {array} keysToCheck List of keys to check for undefined values e.g. ['a','b','c']
* @example
*
* const obj = { a: undefined, b: 1, c: 2, d: undefined }
*
* console.log(keysUndefined(obj))
* returns ['a','d' ]
**/
@daveteu
daveteu / electron_submenu_notshowing.html
Last active January 4, 2022 02:00
SubMenu Not working
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<link href="./styles.css" rel="stylesheet">
<title>Hello World!</title>
</head>
<body>