Skip to content

Instantly share code, notes, and snippets.

View hartfordfive's full-sized avatar

Alain L hartfordfive

View GitHub Profile
@hartfordfive
hartfordfive / self-signed-certificate-with-custom-ca.md
Created February 9, 2021 19:47 — forked from fntlnz/self-signed-certificate-with-custom-ca.md
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@hartfordfive
hartfordfive / prometheus-timescaledb-metrics-backfilling.md
Last active November 5, 2020 22:32
How to backfill prometheus metrics into a Postgres TimescaleDB instance

Description

Method of populating data into TimescaleDB where Prometheus doesn't directly scrape the metrics.
This can be used in cases where a user needs to backfill metrics which are only generated every few hours or at the end of every day.

Method #1: Run the inserts directly on the Postgres database


Create the cpu_total metric table, or in other words, create the actual "cpu_total" series

@hartfordfive
hartfordfive / sshremote.go
Created January 15, 2020 12:54 — forked from josephspurrier/sshremote.go
Golang Remote Execution
package main
/*
// Example
sci := ServerConnInfo{
"127.0.0.1",
"22",
"ubuntu",
`key.pem`,
}
@hartfordfive
hartfordfive / Acceptor.go
Created January 15, 2019 00:41 — forked from StandoffVenus/Acceptor.go
Gale-Shapley Algorithm in Golang
package Village
type Acceptor struct {
Name string
preferences map[*Proposer]int
Free bool
partner *Proposer
proposalPool []*Proposer
}
@hartfordfive
hartfordfive / characters.sh
Last active January 5, 2018 15:57
Bash functions to get the encoding number of chars of a given text file
function filereport() {
if [ "$1" != "run" ]; then
echo "Notice Dry-run mode"
MODE="dryrun"
else
MODE="run"
fi
@hartfordfive
hartfordfive / custom_errors.go
Created October 6, 2017 20:18
Custom Go Errors Examples
package main
import (
"errors"
"fmt"
"time"
)
type HostError struct {
message string
@hartfordfive
hartfordfive / k8s-convert-env.py
Created August 31, 2017 19:25
Python script to convert container env blocks to config maps in Kubernetes configs
import json, argparse, sys, os, time
from os.path import basename
def getFileContents(filename):
with open(filename, 'r') as f:
return f.read()
def writeToFile(filename, contents):
file = open(filename, "w")
@hartfordfive
hartfordfive / k8s-convert-env.py
Created August 31, 2017 19:25
Python script to convert container env blocks to config maps in Kubernetes configs
import json, argparse, sys, os, time
from os.path import basename
def getFileContents(filename):
with open(filename, 'r') as f:
return f.read()
def writeToFile(filename, contents):
file = open(filename, "w")
@hartfordfive
hartfordfive / event_interface_example.go
Last active June 29, 2017 14:36
Simple Go Interfaces Example
package main
// Run at https://play.golang.org/p/QDc3-94kqJ
import (
"fmt"
"reflect"
)
type Event interface {
@hartfordfive
hartfordfive / The Technical Interview Cheat Sheet.md
Created June 14, 2017 13:12 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.