Skip to content

Instantly share code, notes, and snippets.

View hartfordfive's full-sized avatar

Alain L hartfordfive

View GitHub Profile
@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.
@hartfordfive
hartfordfive / byte-city-bus-network
Created June 7, 2017 18:49
Programming Test Question
(Originally found at: https://pastebin.com/Lkjad3y6)
The Bus
-----------------
The streets of Byte City form a regular, chessboardlike network - they are either north-south or west-east directed. We shall call them NS- and WE-streets. Furthermore, each street crosses the whole city. Every NS-street intersects every WE- one and vice versa. The NS-streets are numbered from 1 to n, starting from the westernmost. The WE-streets are numbered from 1 to m, beginning with the southernmost. Each intersection of the i-th NS-street with the j-th WE-street is denoted by a pair of numbers (i, j) (for 1 <= i <= n, 1 <= j <= m).
There is a bus line in Byte City, with intersections serving as bus stops. The bus begins its itinerary by the (1, 1) intersection, and finishes by the (n, m) intersection. Moreover, the bus may only travel in the eastern and/or northern direction.
There are passengers awaiting the bus by some of the intersections. The bus driver wants to choose his route in a way that allows him to take as many