Skip to content

Instantly share code, notes, and snippets.

View hartfordfive's full-sized avatar

Alain Lefebvre hartfordfive

View GitHub Profile
@hartfordfive
hartfordfive / gist:2cd190f1e1cd2ecdf04bfee57b34c464
Created August 17, 2023 14:15 — forked from ipedrazas/gist:403df2ed30ea8682e2b709ddc1c24bcf
curl internal service kubernetes kubectl proxy
# To call from outside the cluster a service type `ClusterIP`
# We use `kubectl proxy`
kubectl proxy
# Then, the service can be accessed by calling:
curl http://localhost:8001/api/v1/namespaces/status/services/x01-kstatus-api:5000/proxy/api/jobs
# This is
# curl http://localhost:8001/api/v1/namespaces/[NAMESPACE]/services/[SERVICE:PORT]/proxy/[QUERY_STRING]
@hartfordfive
hartfordfive / wsgiref_flask.py
Created April 27, 2023 21:31 — forked from 5j9/wsgiref_flask.py
running flask app using python's built-in wsgiref
# call this server using the following js command from the browser console:
# (await fetch('http://localhost:5000/', {method: "POST", body: '5'})).text()
# note: wsgiref is only good for development and in that case Werkzeug is
# usually preferred. See http://mitsuhiko.pocoo.org/wzdoc/wsgihowto.html
from wsgiref.simple_server import make_server
from flask import Flask, request, Response
app = Flask(__name__)
@hartfordfive
hartfordfive / README.md
Last active October 11, 2022 17:14 — forked from roidelapluie/gist:8c67e9c8fb18b310a4a90cb92a23056b
Prometheus alert on business days
  1. Implement the defined alerting conditions
  2. Set the following rule in the alerts: vector(1) and on() business_hour
@hartfordfive
hartfordfive / HttpProxy.go
Created July 8, 2022 01:07 — forked from yowu/HttpProxy.go
A simple HTTP proxy by Golang
package main
import (
"flag"
"io"
"log"
"net"
"net/http"
"strings"
)
@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 / 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 / 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 / term_context.go
Created June 1, 2017 16:48 — forked from matryer/term_context.go
Making Ctrl+C termination cancel the context.Context
func main() {
ctx := context.Background()
// trap Ctrl+C and call cancel on the context
ctx, cancel := context.WithCancel(ctx)
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
defer func() {
signal.Stop(c)