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
(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
tonygaetani /
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 --help`
# expected -
# usage: [-h] -f FOO [-b BAR]
tonygaetani /
Created January 29, 2016 10:01
Vagrant/Linux increase swap memory
# Thank you to Jorge Quilcate Otoya for this helpful script
# size of swapfile in megabytes
# does the swap file already exist?
grep -q "swapfile" /etc/fstab
#!/usr/bin/env bash
set -euo pipefail
HEAD=$(git rev-parse --abbrev-ref HEAD)
if [[ "${HEAD}" == "HEAD" ]]; then
HEAD=$(git rev-parse HEAD)
if [[ -n $(git status --porcelain) ]]; then
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 / .basic.tmux.conf
Last active April 13, 2016 10:13
Basic tmux conf
# increased buffer size
set-option -g history-limit 5000
# shell
set-option -g default-shell /bin/$SHELL
# no delay for escape key press
set -sg escape-time 0
tonygaetani /
Created July 26, 2016 11:32
github keybase proof

Keybase proof

I hereby claim:

  • I am tonygaetani on github.
  • I am 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 / docker-clean-all.bash
Created October 7, 2016 18:39
docker clean all
#!/usr/bin/env bash
set -euo pipefail
# thank you
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
tonygaetani /
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
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
v.customize ['storageattach', :id, '--storagectl', 'SATAController', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk]