Skip to content

Instantly share code, notes, and snippets.

@asiegman
asiegman / ssh-exit-codes.sh
Last active April 30, 2022 07:45
Understanding SSH and exit codes in Bash scripts.
#!/bin/bash
#
# SSH Exit Codes
#
# Using SSH in scripting is pretty standard, but sometimes you want to stop execution of a script
# if a command inside an SSH session fails to exit cleanly (return 0). The key to remember is that
# the ssh command's exit code will be that of the *last executed* command inside the ssh session, just
# like a bash script ends with the exit code of the last command executed unless you specifically
# call exit.
#
@asiegman
asiegman / nginx.conf
Created January 29, 2015 16:29
nginx logstash output
# Output json-esque output for logstash to parse easily.
http {
# ...
log_format logstash_json '{"@timestamp": "$time_iso8601", '
'"remote_addr": "$remote_addr", '
'"remote_user": "$remote_user", '
'"body_bytes_sent": "$body_bytes_sent", '
'"request_time": "$request_time", '
@asiegman
asiegman / fizzbuzz.sh
Last active August 29, 2015 14:18
Fizz Buzz
#!/bin/bash
# Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz"
# instead of the number and for the multiples of five print "Buzz". For numbers which are multiples
# of both three and five print "FizzBuzz".
for i in {1..100} ; do
num=$i
[[ $(( $i % 3 )) == 0 ]] && echo -n "Fizz" && num=""
[[ $(( $i % 5 )) == 0 ]] && echo -n "Buzz" && num=""
@asiegman
asiegman / word.py
Created October 30, 2018 20:01
Given an array of letters, find word(s) of the same length that you can spell with those letters.
#!/usr/bin/env python3
words = []
letters = ['a', 'r', 'v', 'b', 'i', 't', 'o']
letters.sort()
# This is the correct path for OSX
f = open('/usr/share/dict/words')
print(f"letters: {letters}")

Keybase proof

I hereby claim:

  • I am asiegman on github.
  • I am asiegman (https://keybase.io/asiegman) on keybase.
  • I have a public key ASDkCIbmSjFT9VBBrZNhbUPkIpz2E275ddgBqPeCgWDTdQo

To claim this, I am signing this object: