Skip to content

Instantly share code, notes, and snippets.

View agargiulo's full-sized avatar

Anthony Gargiulo agargiulo

View GitHub Profile
function ssl_dates () {
local rem_host="${1}"
local rem_port="${2:-443}"
[[ -n $rem_host ]] || {
echo 'USAGE: ssl_dates host.example.com [8443]' && return 1
}
echo '' | openssl s_client -servername "${rem_host}" -showcerts -connect "${rem_host}:${rem_port}" | openssl x509 -noout -dates
}
@agargiulo
agargiulo / project_switcher.zsh
Last active January 2, 2019 23:30
Wanted a way to navigate between different projects using only zsh. Feedback welcome
setopt extendedglob
unset CURRENT_PROJECT_NAME
typeset -a project_dirs
find "${HOME}/projects" -maxdepth 1 -type d | while read project; do
project_dirs+=("${project:t}")
done
function proj() {
name=$1
base=${2-projects}
@agargiulo
agargiulo / .gitconfig
Last active March 3, 2023 07:57
my git config, more or less
[user]
name = Person Name
email = you_rock@example.com
# I love Vim. Vimdiff is amazing. This combined with `merge.conflictstyle = diff3`
# makes for fun 4 pane vim sessions that make merge headaches almost all go away
[diff]
tool = vimdiff
compactionHeuristic = true
@agargiulo
agargiulo / nothing.perl
Created July 23, 2015 23:02
Fun with returning nothing in different languages
sub Foo {
return;
}
sub Bar {
return undef;
}
my $foo_item = Foo();
my $bar_item = Bar();
@agargiulo
agargiulo / Things.rb
Created March 2, 2015 19:19
Playing around with Ruby classes and modules.
module Foo
class << self
def logger
@logger ||= Logger.new($stdout)
end
end
class FunThing
def self.is_fun? item
item.is_a? FunThing
end

Keybase proof

I hereby claim:

  • I am agargiulo on github.
  • I am agargiulo (https://keybase.io/agargiulo) on keybase.
  • I have a public key whose fingerprint is BAA1 A658 1060 B244 DE49 6D41 5C36 CA3C BF43 F315

To claim this, I am signing this object:

[19:45:48] % ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: icmp_seq=0 ttl=127 time=558.698 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=127 time=151.799 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=127 time=688.438 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=127 time=172.532 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=127 time=374.557 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=127 time=212.875 ms
64 bytes from 8.8.8.8: icmp_seq=6 ttl=127 time=206.686 ms
64 bytes from 8.8.8.8: icmp_seq=7 ttl=127 time=940.021 ms
@agargiulo
agargiulo / heron.c
Last active October 3, 2016 20:17
Heron square root implementations in a few languages.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
double heron_sqrt(long n, double percision);
void compare_sqrt(long n);
int main(int argc, char **argv)
{
@agargiulo
agargiulo / lrb.zsh
Last active August 29, 2015 14:06
Learning Ruby, got lazy so this was made.
lrb () {
filename="ex${1}.rb"
shift
if [[ -e $filename ]]
then
vim $filename
else
vim $filename +startinsert
fi
@agargiulo
agargiulo / diff.zsh
Last active August 29, 2015 14:06
Floating point fun
#!/usr/bin/zsh
money=103.4
print "ruby vs python:"
diff <(echo $money | ruby ex12b.rb) <(echo $money | python3 ex12b.py) && print "No changes"
print "ruby vs java:"
diff <(echo $money | ruby ex12b.rb) <(echo $money | java ex12b) && print "No changes"