Skip to content

Instantly share code, notes, and snippets.

View cjmcgraw's full-sized avatar

Carl McGraw cjmcgraw

View GitHub Profile
@cjmcgraw
cjmcgraw / smart-caps-lock.md
Created January 6, 2021 00:38 — forked from tanyuan/smart-caps-lock.md
Smart Caps Lock: Remap Caps Lock to Control AND Escape

Smart Caps Lock: Remap to Control AND Escape (Linux, Mac, Windows)

  • Send Escape if you tap Caps Lock alone.
  • Send Control if you press Caps Lock with another key.

For both Vim and Emacs world.

GNU/Linux

@cjmcgraw
cjmcgraw / parse_args.sh
Last active September 13, 2021 20:00
This is a custom way that I parse args in bash scripts. I consider it the most terse and readable form.
#! /usr/bin/env bash
first=""
second=""
third_flag=""
function usage() {
echo "$0 args"
echo ""
echo "required arguments:"
echo " --first first argument"
#! /usr/bin/env python
import subprocess
import argparse
import httplib
import json
parser = argparse.ArgumentParser(description="print out all documents in an index to stdout")
parser.add_argument("--index", type=str)
parser.add_argument("--host", type=str)
parser.add_argument("--port", default=9200, type=int)
@bwhite
bwhite / rank_metrics.py
Created September 15, 2012 03:23
Ranking Metrics
"""Information Retrieval metrics
Useful Resources:
http://www.cs.utexas.edu/~mooney/ir-course/slides/Evaluation.ppt
http://www.nii.ac.jp/TechReports/05-014E.pdf
http://www.stanford.edu/class/cs276/handouts/EvaluationNew-handout-6-per.pdf
http://hal.archives-ouvertes.fr/docs/00/72/67/60/PDF/07-busa-fekete.pdf
Learning to Rank for Information Retrieval (Tie-Yan Liu)
"""
import numpy as np
@jboner
jboner / latency.txt
Last active July 6, 2024 18:55
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