$ cal -m $(date '+%m') && cal -m $(date -v+1m '+%m')
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://docs.python.org/2/library/signal.html#signal.signal | |
import signal | |
import sys | |
import os | |
def signal_term_handler(signal, frame): | |
if signal == 15: | |
print("got SIGTERM") | |
sys.exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def hodor(): | |
hodor_text = "Hodor" | |
rand_num_words = random.randrange(5, 9) | |
for i in range(rand_num_words): | |
if random.randrange(1, 4) == 3 and i != (rand_num_words - 1): | |
hodor_text += " hodor," | |
else: | |
hodor_text += " hodor" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def inception(target_depth, current_depth=0, going_deeper=True): | |
if going_deeper == True: | |
if current_depth < target_depth: | |
current_depth += 1 | |
if current_depth != target_depth: | |
print("Dream Level: {0}, going deeper..".format(current_depth)) | |
elif current_depth == target_depth: | |
print("Dream Level: {0}, coming back up..".format(current_depth)) | |
return inception(target_depth, current_depth, True) | |
elif current_depth == target_depth: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# put this in your .bash_profile | |
if [ $ITERM_SESSION_ID ]; then | |
export PROMPT_COMMAND='echo -ne "\033];${PWD##*/}\007"; ':"$PROMPT_COMMAND"; | |
fi | |
# Piece-by-Piece Explanation: | |
# the if condition makes sure we only screw with $PROMPT_COMMAND if we're in an iTerm environment | |
# iTerm happens to give each session a unique $ITERM_SESSION_ID we can use, $ITERM_PROFILE is an option too | |
# the $PROMPT_COMMAND environment variable is executed every time a command is run | |
# see: ss64.com/bash/syntax-prompt.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import sys | |
trips_to_store = 0 | |
total_bottles_drank =0 | |
bottles = 100 | |
def final_stats(trips_to_store, total_bottles_drank): | |
if trips_to_store == 0: | |
print("\nNever went to the store for more beer.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/expect -f | |
# usage: ./hubottest "hubot help" | |
spawn bin/hubot.coffee | |
sleep 3 | |
expect "Hubot>" | |
send "hubot [lrange $argv 0 10]\n" | |
expect eo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#From http://blog.codinghorror.com/why-cant-programmers-program/ | |
def FizzBuzz(): | |
for i in range(1,100): | |
if ((i % 3 == 0) and (i % 5 == 0)): | |
print "FizzBuzz" | |
elif (i % 3 == 0): | |
print "Fizz" | |
elif (i % 5 == 0): | |
print "Buzz" | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//From http://blog.codinghorror.com/why-cant-programmers-program/ | |
function FizzBuzz() { | |
for (var i = 1; i <= 100; i++) { | |
if ((i % 3 === 0) && (i % 5 === 0)) { | |
console.log("FizzBuzz"); | |
} else if (i % 3 === 0) { | |
console.log("Fizz") | |
} else if (i % 5 === 0) { | |
console.log("Buzz") | |
} else { |