Skip to content

Instantly share code, notes, and snippets.

@tasermonkey
tasermonkey / mbti.ts
Created October 16, 2023 13:55
Sample typescript code showing some power of the type system
type PreferenceEI = 'I' | 'E';
type PreferenceSN = 'S' | 'N';
type PreferenceTF = 'T' | 'F';
type PreferenceJP = 'J' | 'P';
type Preference = PreferenceEI | PreferenceSN | PreferenceTF | PreferenceJP;
type Name = `${PreferenceEI}${PreferenceSN}${PreferenceTF}${PreferenceJP}`;
// type Name =
Verifying that +jstapleton is my blockchain ID. https://onename.com/jstapleton
@tasermonkey
tasermonkey / is_anagram.rb
Created March 31, 2015 02:14
is_anagram.rb
#!/usr/bin/env ruby
# note that, I am not an expert ruby developer, so there is probably a more ruby way of doing this...
require 'awesome_print'
def freq(str)
str.downcase.split("").map.with_object({}) do |c,h|
(h[c] = h.fetch(c, 0) + 1) if c =~ /\w/
end
@tasermonkey
tasermonkey / shell-print-date-time-on-execute
Created February 25, 2015 17:59
shell-print-date-time-on-execute
preexec () {
DATE=`date +"%H:%M:%S on %Y-%m-%d"`
C=$(($COLUMNS-24))
echo -e "\033[1A\033[${C}C ${fg[red]}${DATE}${reset_color}"
}
@tasermonkey
tasermonkey / VangrantFile
Created August 21, 2014 13:32
~/.vagrant.d/VangrantFile
Vagrant.configure("2") do |config|
config.vm.synced_folder "~/.m2", "/home/vagrant/.m2"
if Vagrant.has_plugin?("vagrant-cachier")
# Configure cached packages to be shared between instances of the same base box.
# More info on the "Usage" link above
config.cache.scope = :box
config.cache.enable :generic, {
"www" => { cache_dir: "/var/cache/www" },
}
@tasermonkey
tasermonkey / puppet_erb_render.rb
Last active August 29, 2015 14:03
super simple not well tested erb renderer.
require 'optparse'
require 'yaml'
require 'erubis'
options = {}
opt_parser = OptionParser.new do |opt|
opt.banner = "Usage: erb_renderer -c config.yml -f file.erb"
opt.on("-c", "--config FILE", "config file to use for data") do |conf|
options[:config] = conf
@tasermonkey
tasermonkey / gist:8d93400be28d5e8e5418
Created June 25, 2014 18:12
keybase proof of identity
### Keybase proof
I hereby claim:
* I am tasermonkey on github.
* I am jstapleton (https://keybase.io/jstapleton) on keybase.
* I have a public key whose fingerprint is AFC8 AE95 9C2E FD84 04D6 D4B1 DDC6 5FF1 3230 1B95
To claim this, I am signing this object:
@tasermonkey
tasermonkey / listening.sh
Last active April 4, 2023 14:38
Listening
Mac OSX:
listening () {
lsof -Pni | grep '(LISTEN)' | awk 'BEGIN {printf "%-15s %5s %21s\n", "Command", "PID", "PORT"} {printf "%-15s %5s %21s\n", $1,$2,$9}'
}
Linux (if you want non-you processes that are listening):
listening () {
sudo lsof -Pni | grep '(LISTEN)' | awk 'BEGIN {printf "%-15s %5s %21s\n", "Command", "PID", "PORT"} {printf "%-15s %5s %21s\n", $1,$2,$9}'
}