Skip to content

Instantly share code, notes, and snippets.

View thalesfsp's full-sized avatar
🚀
Rocking the world!

Energy Star thalesfsp

🚀
Rocking the world!
  • Global
View GitHub Profile
@thalesfsp
thalesfsp / latency.markdown
Created June 23, 2023 09:11 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know
View latency.markdown

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@thalesfsp
thalesfsp / pget.go
Created November 24, 2022 09:56 — forked from montanaflynn/pget.go
Bounded Parallel Get Requests in Golang
View pget.go
package main
import (
"fmt"
"net/http"
"sort"
"time"
)
// a struct to hold the result from each request including an index
@thalesfsp
thalesfsp / custom-json-marshalling-in-go.md
Created October 5, 2022 01:08
Custom JSON Marshalling in Go
View custom-json-marshalling-in-go.md

Custom JSON Marshalling in Go

Go’s encoding/json package makes it really easy to marshal structs to JSON data.

package main

import (
	"encoding/json"
	"os"
@thalesfsp
thalesfsp / openpgp-card-guide.md
Created June 6, 2022 08:05 — forked from ageis/openpgp-card-guide.md
Quick GPG Smartcard Guide
View openpgp-card-guide.md
@thalesfsp
thalesfsp / install-teleport.sh
Created May 25, 2022 22:10 — forked from vairisingh/install-teleport.sh
Script to install Teleport on a system
View install-teleport.sh
#!/bin/bash
export version=v4.2.8
export os=linux
export arch=amd64
#####################################
curl -O https://get.gravitational.com/teleport-$version-$os-$arch-bin.tar.gz
tar -xzf teleport-$version-$os-$arch-bin.tar.gz
@thalesfsp
thalesfsp / yubikey+gpupgp+ssh_howto.md
Created May 24, 2022 04:04 — forked from xirkus/yubikey+gpupgp+ssh_howto.md
Security Adventures 1. How to get yubikey+gpg+ssh+gitbhub working on MacOS
View yubikey+gpupgp+ssh_howto.md

I've spent the day trying to get this setup working with GitHub and given the number of gotcha's I encountered, it seemed like a good idea to document how I finally got this working with as few hacks as possible. There's a lot of documentation out there (some of it old and misleading) and committing here for posterity will help me remember this when I inevitably need to do this again.

Rationale

Passwords are simply not enough these days. Regardless of the company, breaches (and the associated Personally Identifiable Information harvested) are a matter of not if, but when. There are a number of things you can do to protect yourself, but being on the tin-foil-hat side of paranoia, means there are a few Commandents that I adhere to (and recommend for other folks)[Insert link to Fight Club Rules for the Secure Internet].

That being said, if you use 2-factor authentication and have committed to using a hardware token such as the Yubikey, then you're already ahead of the curve. The problem is that wh

@thalesfsp
thalesfsp / combinations.js
Created April 28, 2022 22:18 — forked from axelpale/combinations.js
JavaScript functions to calculate combinations of elements in Array.
View combinations.js
/**
* Copyright 2012 Akseli Palén.
* Created 2012-07-15.
* Licensed under the MIT license.
*
* <license>
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
View asd.json
{
"openapi": "3.0.0",
"info": {
"title": "mavenapi",
"version": "1.0",
"contact": {
"name": "Wrecing Ball",
"url": "https://www.getwrecked.com",
"email": "developers@getwrecked.com"
}
@thalesfsp
thalesfsp / main.go
Created March 2, 2022 03:42
Subject <-> Observer behavioural design pattern
View main.go
// It is mainly used for implementing distributed event handling systems, in "event driven" software.
// Channels could have been used.
package main
//////
// Starts here.
//////
func main() {
@thalesfsp
thalesfsp / HttpProxy.go
Created October 14, 2021 21:37 — forked from yowu/HttpProxy.go
A simple HTTP proxy by Golang
View HttpProxy.go
package main
import (
"flag"
"io"
"log"
"net"
"net/http"
"strings"
)