Skip to content

Instantly share code, notes, and snippets.

@mfridman
mfridman / comments.md
Created November 8, 2019 04:33
top i.e., "controversial" comments from golang/go
@mfridman
mfridman / rsa_util.go
Created October 23, 2019 04:01 — forked from miguelmota/rsa_util.go
Golang RSA encrypt and decrypt example
package ciphers
import (
"crypto/rand"
"crypto/rsa"
"crypto/sha512"
"crypto/x509"
"encoding/pem"
"log"
)
@mfridman
mfridman / k8s.json
Created October 14, 2019 03:13
sample data
{
"id": 28265,
"language": "Go",
"fork": false,
"forks_count": 20568,
"open_issues_count": 3299,
"stargazers_count": 58727,
"watchers_count": 58727,
"archived": false,
"disabled": false,
@mfridman
mfridman / PostgreSQL_index_naming.rst
Created September 12, 2019 03:58 — forked from popravich/PostgreSQL_index_naming.rst
PostgreSQL index naming convention to remember

The standard names for indexes in PostgreSQL are:

{tablename}_{columnname(s)}_{suffix}

where the suffix is one of the following:

  • pkey for a Primary Key constraint;
  • key for a Unique constraint;
  • excl for an Exclusion constraint;
  • idx for any other kind of index;
@mfridman
mfridman / sentry_example.go
Created July 29, 2019 02:55
capture sentry alert with error
func (a *alertWrapper) Error(err error) error {
// sentry Go SDK uses asynchronous transport, if fatal (os.Exit) or panic is called after the alert
// the event might get dropped, so we call Flush explicitly.
defer sentry.Flush(time.Second * 2)
hub := sentry.CurrentHub().Clone()
ev := sentry.NewEvent()
ev.Level = sentry.LevelError
@mfridman
mfridman / client_tls_info.go
Created March 6, 2019 04:58 — forked from husobee/client_tls_info.go
discovery of tls in go, and the handshake process
package main
import (
"crypto/tls"
"encoding/json"
"fmt"
"log"
"net"
"net/http"
)
@mfridman
mfridman / Makefile
Created December 1, 2018 21:01 — forked from kwilczynski/Makefile
Makefile for my Go projects (an example).
SHELL := /bin/bash
REV := $(shell git rev-parse HEAD)
CHANGES := $(shell test -n "$$(git status --porcelain)" && echo '+CHANGES' || true)
TARGET := packer-provisioner-itamae-local
VERSION := $(shell cat VERSION)
OS := darwin freebsd linux openbsd
ARCH := 386 amd64
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mfridman
mfridman / go-ssh-hostkey.go
Last active June 15, 2020 21:25
Go host key checking for non-standard port(s)
// thes below two functions are talked about in
// http://mfridman.com/2017/09/04/go-ssh-hostkey.html
func validatePort(s string) (string, error) {
// empty string defaults to port 22, ports 1-65535 valid, otherwise error
if s == "" {
// it is the caller's responsibility to pass in a valid, non-empty port
return "22", nil
}
i, _ := strconv.Atoi(s)
@mfridman
mfridman / osx-for-hackers.sh
Created July 1, 2017 18:13 — forked from brandonb927/osx-for-hackers.sh
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx