Skip to content

Instantly share code, notes, and snippets.

@daveteu
daveteu / gotestsum_actions.yml
Last active Sep 6, 2022
GitHub Actions to run tests and post results on Pull Request
View gotestsum_actions.yml
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 Sep 5, 2022 — forked from vratiu/.bash_aliases
Git shell coloring
View .bash_aliases
# 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 Aug 21, 2022 — forked from osiloke/doveadmpw.go
This generate a dovecot password in golang, inspired by https://gist.github.com/garrettreid/8329796
View doveadmpw.go
package main
import (
"crypto/sha512"
"encoding/base64"
"fmt"
"math/rand"
"time"
)
@daveteu
daveteu / config.go
Last active Jun 23, 2022
Golang - check env is loaded.
View config.go
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 Jun 10, 2022 — forked from codref/go-ssh-reverse-tunnel.go
Go SSH reverse tunnel implementation (SSH -R)
View go-ssh-reverse-tunnel.go
/*
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 Jan 6, 2022
Find undefine keys in plain object
View keysUndefined
/**
* @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' ]
**/
View electron_submenu_notshowing.html
<!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>
@daveteu
daveteu / pre-push.sh
Last active Jul 17, 2021 — forked from vlucas/pre-push.sh
Prevent Pushes Directly to Master
View pre-push.sh
#!/bin/bash
# @link https://gist.github.com/mattscilipoti/8424018
#
# Called by "git push" after it has checked the remote status,
# but before anything has been pushed.
#
# If this script exits with a non-zero status nothing will be pushed.
#
# Steps to install, from the root directory of your repo...
@daveteu
daveteu / tweet.js
Created Jun 4, 2021
Tweet Component
View tweet.js
/*
* Credit to https://blog.maximeheckel.com/posts/static-tweets-with-mdx-nextjs/
*/
import { css } from '@emotion/react';
import { format } from 'date-fns';
import Image from 'next/image';
import { TransformedTweet } from 'types/tweet';
import { LikeIcon, ReplyIcon, RetweetIcon, TwitterLogo } from './Icons';
import {
View DeleteWithUseConfirm.js
const DeleteWithUseConfirm = () => {
const [ getConfirmation, Confirmation ] = useConfirm()
const onDelete = async () => {
const status = await getConfirmation('Shall we have dinner together tonight?');
if (status) { //status = true
...We can now do the job of deleting