Skip to content

Instantly share code, notes, and snippets.

View hartfordfive's full-sized avatar

Alain Lefebvre hartfordfive

View GitHub Profile
@hartfordfive
hartfordfive / gist:6db95bef1b2f07f64fca96e5a6436adf
Created April 17, 2016 22:59 — forked from grantr/gist:1105416
Chef mysql master/slave recipes
## mysql::master
ruby_block "store_mysql_master_status" do
block do
node.set[:mysql][:master] = true
m = Mysql.new("localhost", "root", node[:mysql][:server_root_password])
m.query("show master status") do |row|
row.each_hash do |h|
node.set[:mysql][:master_file] = h['File']
node.set[:mysql][:master_position] = h['Position']
end
@hartfordfive
hartfordfive / com.apple.newsyslog.plist
Created April 19, 2016 15:56
Example newsyslog configuration
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.apple.newsyslog</string>
<key>ProgramArguments</key>
<array>
<string>/usr/sbin/newsyslog</string>
</array>
@hartfordfive
hartfordfive / instance_termination.py
Created January 19, 2017 14:40 — forked from gswallow/instance_termination.py
Crude AWS Lambda to deregister nodes from Chef upon EC2 instance termination
import json
import chef
# Copy your .chef directory into the root folder of the deployment package:
# http://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html#deployment-pkg-for-virtualenv
# See also https://github.com/coderanger/pychef/issues/41
print('Loading function')
def lambda_handler(event, context):
@hartfordfive
hartfordfive / java-8-ami.md
Created February 5, 2017 19:45 — forked from rtfpessoa/java-8-ami.md
[Guide] Install Oracle Java (JDK) 8 on Amazon EC2 Ami
@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)
@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 / 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 / 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 / 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 / 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"
)