Skip to content

Instantly share code, notes, and snippets.

View tonygaetani's full-sized avatar
🏠
Working from home

Tony Gaetani tonygaetani

🏠
Working from home
View GitHub Profile
@tonygaetani
tonygaetani / docker-clean-all.bash
Created October 7, 2016 18:39
docker clean all
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
# thank you https://coderwall.com/p/ewk0mq/stop-remove-all-docker-containers
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
@tonygaetani
tonygaetani / keybase.md
Created July 26, 2016 11:32
github keybase proof

Keybase proof

I hereby claim:

  • I am tonygaetani on github.
  • I am tonygaetani (https://keybase.io/tonygaetani) on keybase.
  • I have a public key whose fingerprint is 984C EC21 2057 94EF D296 AD3F 436F D09B AD04 F349

To claim this, I am signing this object:

@tonygaetani
tonygaetani / .basic.vimrc
Last active April 13, 2016 10:13
basic vimrc
" show syntax highlighting
syntax enable
" dark theme just like my heart
set background=dark
" show line numbers
set number
" re-enable backspace usage
set backspace=2
set backspace=indent,eol,start
" use 4 space charachters for indentation
@tonygaetani
tonygaetani / concurrentexample.py
Last active April 8, 2017 12:17
an example of concurrent.futures.ProcessPoolExecutor for python 2.7
import concurrent.futures
import time
def sleep_print_return(input):
print "{} started".format(input)
time.sleep(input % 3)
return input
def main():
# to observe the difference, change max_workers to 1
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
HEAD=$(git rev-parse --abbrev-ref HEAD)
if [[ "${HEAD}" == "HEAD" ]]; then
HEAD=$(git rev-parse HEAD)
fi
STASH=0
if [[ -n $(git status --porcelain) ]]; then
@tonygaetani
tonygaetani / swapmem.sh
Created January 29, 2016 10:01
Vagrant/Linux increase swap memory
#!/bin/sh
# Thank you to Jorge Quilcate Otoya for this helpful script
# https://jeqo.github.io/blog/devops/vagrant-quickstart/
# size of swapfile in megabytes
swapsize=8000
# does the swap file already exist?
grep -q "swapfile" /etc/fstab
@tonygaetani
tonygaetani / argparseissue.py
Last active January 27, 2016 09:28
Potential argparse issue?
#!/usr/bin/env python
# mac OSX 10.10.3
# python 2.7.10 (installed with homebrew)
# argparse 1.4.0
# to test - `python argparseissue.py --help`
# expected -
# usage: issue.py [-h] -f FOO [-b BAR]
@tonygaetani
tonygaetani / .basic.tmux.conf
Last active April 13, 2016 10:13
Basic tmux conf
# increased buffer size
set-option -g history-limit 5000
# shell
SHELL=bash
set-option -g default-shell /bin/$SHELL
# no delay for escape key press
set -sg escape-time 0
@tonygaetani
tonygaetani / Vagrantfile
Last active August 28, 2019 22:12 — forked from leifg/Vagrantfile
Add a second disk to system using vagrant
config.vm.provider "virtualbox" do |v|
file_to_disk = './tmp/large_disk.vdi'
unless File.exist?(file_to_disk)
v.customize ['createhd', '--filename', file_to_disk, '--size', 500] # size is in MB
end
v.customize ['storageattach', :id, '--storagectl', 'SATAController', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk]
end
(defn pow2 [n]
"Returns a long representing 2^n"
(->> n (Math/pow 2) long))
(defn b10->b2
"Converts a base 10 number to a lazy seq of 1's and 0's that make up a base 2 number"
([n] (b10->b2 n '()))
([n col]
(if (= 1 n)
(merge col 1) ; base case