Skip to content

Instantly share code, notes, and snippets.

View infamousjoeg's full-sized avatar
🙊
I'm really good at keeping secrets.

Joe Garcia infamousjoeg

🙊
I'm really good at keeping secrets.
View GitHub Profile
@jboner
jboner / latency.txt
Last active April 26, 2024 03:40
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
@adrienbrault
adrienbrault / purge.sh
Created September 24, 2012 10:02
Script to reduce VM size before packaging for vagrant
#!/bin/sh
# Credits to:
# - http://vstone.eu/reducing-vagrant-box-size/
# - https://github.com/mitchellh/vagrant/issues/343
aptitude -y purge ri
aptitude -y purge installation-report landscape-common wireless-tools wpasupplicant ubuntu-serverguide
aptitude -y purge python-dbus libnl1 python-smartpm python-twisted-core libiw30
aptitude -y purge python-twisted-bin libdbus-glib-1-2 python-pexpect python-pycurl python-serial python-gobject python-pam python-openssl libffi5
@BlakeGardner
BlakeGardner / install nano.sh
Last active April 23, 2024 20:22
Syntax highlighting in nano on Mac OS
# Last updated March, 2022 for Apple silicon Macs
# Install Homebrew if you don't already have it: https://brew.sh
# install nano from homebrew
brew install nano nanorc
# update your nanorc file
echo 'include "/opt/homebrew/share/nanorc/*.nanorc"' >> ~/.nanorc
# close and re-open your terminal and you'll have syntax highlighting
@ofstudio
ofstudio / get_password.sh
Created December 14, 2014 16:39
Get password from OS X Keychain shell / bash function
# Get password from OS X Keychain function
# Replace %ACCOUNT_NAME% with account name of Keychain item
# See `man security` for more info
get_pw () {
security 2>&1 >/dev/null find-generic-password -ga "%ACCOUNT_NAME%" \
| sed 's/password: "\(.*\)"/\1/'
}
# Don't store server credentials in plain text!
PASS=$(get_pw)
@srijanshetty
srijanshetty / package-vagrant-box.md
Last active June 20, 2023 08:49
Clean up a vagrant box before packaging

We’re now going to clean up disk space on the VM so when we package it into a new Vagrant box, it’s as clean as possible. First, remove APT cache

$ sudo apt-get clean

Then, “zero out” the drive (this is for Ubuntu):

$ sudo dd if=/dev/zero of=/EMPTY bs=1M
@tinkerbotfoo
tinkerbotfoo / get_ec2_instance_secur_info.py
Last active October 3, 2021 11:13
Get decrypted EC2 Windows instance Administrator password using python boto
###requirements.txt
#pycrypto
#pyopenssl
## Creds
AWS_EC2_ACCESS_ID='AKIA**********'
AWS_EC2_SECRET_KEY = 'mh83**************'
PEM_FILE = os.path.expanduser('D:\\abc\\scripts\\s\\test.pem')
### Get Windows Admin password of the newly created AWS instance
@ccampanale
ccampanale / vaultsealmanager.sh
Created December 10, 2015 19:31
Bash shell script to check seal status for local vault server and attempt to unseal using keys secured in vault secret store. Supports HA Vault clusters with TLS with unseal keys stored as secrets in vault (see code). Relies on registered service vault.service.consul, in place DNS configuration, and a single unsealed vault instance in your clust…
#!/bin/bash
export vault=/usr/local/bin/vault
export VAULT_TOKEN=$(cat /root/.vault-token)
vault_cacert='-ca-cert=/path/to/your/ca.pem'
local_vault="-address=https://$(hostname -f):8200"
unsealed_vault="-address=https://$(getent hosts $(dig +short vault.service.consul | tail -n 1) | awk '{ print $2 }'):8200"
leader_vault="-address=https://$($vault status $vault_cacert $unsealed_vault 2> /dev/null | grep Leader | awk '{ print $2 }' | sed 's/^http\(\|s\):\/\///g'):8200"
vault_read="$vault read $vault_cacert $leader_vault"
vault_unseal="$vault unseal $vault_cacert $local_vault"
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@Xainey
Xainey / touch.ps1
Created January 18, 2017 17:12
Touch command for PowerShell $Profile
# Add nix-like touch command
function touch
{
$file = $args[0]
if($file -eq $null)
{
throw "No filename supplied"
}
@jgamblin
jgamblin / slackspotify.sh
Created April 19, 2017 01:10
A Script To Set Current Spotify Song As Slack Status
#!/bin/bash
APIKEY="From Here https://api.slack.com/custom-integrations/legacy-tokens"
SONG=$(osascript -e 'tell application "Spotify" to name of current track as string')
URLSONG=$(echo "$SONG" | perl -MURI::Escape -ne 'chomp;print uri_escape($_),"\n"')
while true
do
curl -s -d "payload=$json" "https://slack.com/api/users.profile.set?token="$APIKEY"&profile=%7B%22status_text%22%3A%22"$URLSONG"%22%2C%22status_emoji%22%3A%22%3Amusical_note%3A%22%7D" > /dev/null
sleep 60
done