Skip to content

Instantly share code, notes, and snippets.

@gweakliem
gweakliem / OSXSetup.md
Last active December 30, 2024 13:45
Setting up Command Line Environment on OSX

This is pretty much true for Linux as well, but I mostly use OSX these days. I set up machines infrequently enough that there's a lot of fumbling around while I remember how to do all this so I'm writing this down to have in one place for the next time I have to set up a new machine. This list doesn't include things like Rust, which manages itself pretty well, it's for environment settings and things that need an external manager to keep the environment sane.

Aside from the usual applications distributed in .dmg format, I like the following:

  1. Install ITerm2 because the system terminal is kinda lame. I don't typically do a lot of customization but I do add vi mode to the shell by putting bindkey -v into ~/.zshrc (or ~/.bashrc).
  2. Create a new SSH key and add it to Github.
  3. Install Homebrew -
@gweakliem
gweakliem / SysDesignTemplate.md
Last active January 20, 2023 21:15
System Design Interview Template
  1. FEATURE EXPECTATIONS [5 min]
    1. Use cases
    2. Scenarios that will not be covered
    3. Who will use
    4. How many will use
    5. Usage patterns
  2. ESTIMATIONS [5 min]
    1. Throughput (QPS for read and write queries)
    2. Latency expected from the system (for read and write queries)
    3. Read/Write ratio
@gweakliem
gweakliem / intro-to-kotlin.md
Created August 15, 2019 02:01
Venkat S. Kotlin for Java Programmers

Kotlin for Java Programmers

  • Multiparadigm language
  • Statically Typed
  • Compiles to java & javascript

"I'll teach you java, let's learn hello world". First word is public. What's public? then static. What's static?.

There's a lot of stuff "you don't need to know right now". Kotlin doesn't make its problems your problems.

@gweakliem
gweakliem / okta.sh
Created August 15, 2019 00:08
Okta SAML authentication logic as a bash script
OKTA_DOMAIN= # e.g. example.okta.com
curl -d '{ "username":"$USERNAME","password":"$PASSWORD" }' -c cookie_jar.txt \
-H "Content-Type: application/json" -b cookie_jar.txt -c cookie_jar.txt \
https://$OKTA_DOMAIN/api/v1/authn > auth.json
{
"stateToken": "00oBpbTzKnRdKLYvc8yNBdFTusuoS4KUhdANgrMsOt",
"expiresAt": "2019-07-08T22:54:32.000Z",
"status": "MFA_REQUIRED",
"_embedded": {
@gweakliem
gweakliem / venkat.md
Last active August 13, 2019 02:23
Venkat S Don't walk from complexity, run!

Don't Walk Away From Complexity, Run

August 12, 2019

"If only management gave me the opportunity" Only constant is change. Point of Agile the ability to adapt to change.

"I've set the wedding date. I've not asked her out yet." -- how software projects are managed @venkat_s https://twitter.com/venkat_s/status/617052918491918336

@gweakliem
gweakliem / Sample.java
Created August 13, 2019 02:16
Interview question: what does this print?
class Scratch {
private static boolean done;
private static int count;
public static void main(String[] args) throws InterruptedException {
done = false;
new Thread(() -> {
System.out.println("Running");
count = 0;
@gweakliem
gweakliem / AWS.md
Last active July 30, 2019 16:21
Stupid AWS Tricks

All these assume OSX bash. Most should be portable to Linux.

brew install spark to get the nifty sparklines stuff

Price history of the last 12 hours of c5.18xlarge instances

aws ec2 describe-spot-price-history --instance-types c5.18xlarge --product-descriptions "Linux/UNIX"  --start-time $(date -v-12H -u +"%Y-%m-%dT%H:%M:%S.000Z") --query "SpotPriceHistory[].SpotPrice" --output text
@gweakliem
gweakliem / handy_bash.sh
Last active August 13, 2018 17:39
handy bash stuff
# find pigs - find what directories consume the most space. You can recursively run down this report to get to a specific dir
sudo du -cha --max-depth=1 $1 | grep -E "M|G"
# getflinkenv.sh - if you're running in yarn, this gets the address of the jobtracker and then from that, the address of the jobmanager.
# this moves every time the container restarts so it's handy to have around.
FLINK_SRV=`yarn application -list 2> /dev/null | grep "Flink 1.2.1" | awk '{print $NF}'`
FLINK_JOBMGR=`curl --silent $FLINK_SRV/jobmanager/config | jq -r '.[] | select(.key == "jobmanager.rpc.address"),select(.key == "jobmanager.rpc.port") | .value' | tr "\n" ":" | sed 's/:$//'`
echo $FLINK_SRV $FLINK_JOBMGR
# calc-offset.sh
@gweakliem
gweakliem / Solution.js
Created January 4, 2018 21:03
Scala shell for typical HackerRank problem
import scala.io
object Solution {
# Handle input of the format <size>\n<num>\n<num>\n...^d
def main(args: Array[String]) {
val n = StdIn.readInt()
val nums = new Array[Int](n)
for (i <- 1 to n) {
nums[i] = StdIn.readInt()
}
}
@gweakliem
gweakliem / Node.py
Created October 28, 2016 03:17
Another take at the IntTree using something like S-Expressions.
'''Tree representing
1
/|\
2 3 4
/\ |\
5 6 9 11
/\ \
7 8 10
Not especially happy with this. Feels like I'm fighting the representation.