Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex Siegman asiegman

View GitHub Profile
View keybase.md

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:

@asiegman
asiegman / word.py
Created Oct 30, 2018
Given an array of letters, find word(s) of the same length that you can spell with those letters.
View word.py
#!/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}")
View fizzbuzz.sh
#!/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 / nginx.conf
Created Jan 29, 2015
nginx logstash output
View nginx.conf
# 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 / ssh-exit-codes.sh
Last active Jun 16, 2020
Understanding SSH and exit codes in Bash scripts.
View ssh-exit-codes.sh
#!/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.
#
You can’t perform that action at this time.