Skip to content

Instantly share code, notes, and snippets.

@gregberns
gregberns / README.md
Last active November 12, 2020 19:23
Git: Windows switch CRLF to LF

Git: Windows switch CRLF to LF

When working on Windows with Docker, Linux, etc, your files should be standardized to LF. This command only needs to be run once:

git config --global core.autocrlf input

Source: https://stackoverflow.com/a/5834094/684966

@gregberns
gregberns / README.md
Last active September 10, 2020 23:31

Stripe Payment Example

Example of how to use Stripe.js and Node.JS libraries.

  • index.html - Client side workflow (JS)
  • index.js - Server side workflow (Node.JS)

Note: Examples are a very rough POC, so please excuse the rough style.

@gregberns
gregberns / Azure-SQL-Server-Application-Connectivity.md
Last active October 18, 2023 12:15
Azure SQL Server Application Connectivity

Tags: Azure, Managed Identity, SQL Server Access Token, Managed Service Identity, SQL Server Authentication, App Registrations

This document will outline the concepts needed to connect to a "Secure" Azure SQL Server database, both from within Azure and outside of Azure. It also provides code snippets to demonstrate what is involved.

TLDR

Today's best practice is to access SQL databases with OAuth tokens. To connect to an Azure SQL DB, you get an OAuth token, then supply it when connecting to the SQL Database. Getting the OAuth token is different whether you're accessing it in Azure or outside Azure.

Overview

Stevey's Google Platforms Rant

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't real

@gregberns
gregberns / setup.sh
Last active November 12, 2021 05:53 — forked from bradp/setup.sh
New Mac Setup Script
# curl ~~Get gist raw url~~ > setup.sh
# chmod +x ~/setup.sh
# ~/setup.sh
GIT_USERNAME=________
GIT_EMAIL=________
GITHUB_ACCOUNT_NAME=________
MAC_USERNAME=________
MAC_MACHINE_NAME=________
@gregberns
gregberns / problems-parse-file.md
Last active April 9, 2020 22:02
Programming Problem - Parse File

Programming Problem - Parse File

  • Either read the "File Contents" from a file or place the text into a multi-line block
  • Parse the contents
  • Aggregate the time (last field)
  • Report of total calls
  • Report any error cases (non-200)
    • Bonus points: report what line number the error occured on

File Contents

@gregberns
gregberns / jq-filters.md
Last active March 30, 2020 22:47
jq - filter keys containing dash

jq can filter keys with dashes (-), but that requires special syntax: [\"field-name\"]

Input:

echo '{"the-long-field-name":"true"}' | jq ". | select(.[\"the-long-field-name\"] != null)"

Output:

@gregberns
gregberns / latency.txt
Created October 12, 2019 03:22 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@gregberns
gregberns / gist:b197a36e5a7e5cd0e9da965511b355cb
Created April 29, 2019 15:54
Managing Secrets - Notes from 2019-04-24 PHX DevOps meetup
Notes from 2019-04-24 PHX DevOps meetup
Managing Secrets
NoDramaDevOps.com Blog
Platform Identity
* Can give a VM a service account which has rights to access
* Use short term credentials to talk between services.
@gregberns
gregberns / gist:f5fac3df9d5790c03647e014a91fdbbd
Created April 18, 2019 22:37
Rust implementation for `partition` function for `Result`
fn partition<A,B>(list: Vec<Result<A,B>>) -> (Vec<A>, Vec<B>) {
let mut aa = vec!();
let mut bb = vec!();
for i in list {
match i {
Ok(a) => aa.push(a),
Err(b) => bb.push(b),
};
}
(aa, bb)