This file contains hidden or 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
#! /bin/bash | |
# A script that watches the running status of Amazon EMR jobs, sending an XMPP | |
# message upon completion. | |
# | |
# A destination jabber account, where the messages are sent, should be supplied | |
# either as the first argument at invocation or in the environment variable | |
# JABBER_ACCOUNT. | |
# | |
# Dependencies: |
This file contains hidden or 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
### Sending a file | |
# BSD nc syntax | |
cat myDocument.pdf | ssh me.myserver.com nc -l 20000 | |
# Hobbit nc syntax - try this one if unsure! | |
cat myDocument.pdf | ssh me.myserver.com nc -l -p 20000 | |
### Receiving a file | |
nc me.myserver.com 20000 > myDocument.pdf |
This file contains hidden or 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 java.util.Properties | |
val in = getClass.getClassLoader.getResourceAsStream("config_values.properties") | |
// The Classloader is not always available (sbt test runner), then use the current class instead: | |
// val in = getClass.getResourceAsStream("config_values.properties") | |
val props = new Properties() | |
props.load(in) | |
in.close | |
props.getProperty("my.property.name", "default-value") |
This file contains hidden or 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
object Main { | |
def main(args: Array[String]) = { | |
def m3(x: Int) = x % 3 == 0 | |
def m5(x: Int) = x % 5 == 0 | |
val checks = List((m3 _, "Fizz"), (m5 _, "Buzz")) | |
Stream.from(1) map { n => | |
checks filter (_._1(n)) map (_._2) reduceOption (_ + _) getOrElse n | |
} take 100 foreach println |
This file contains hidden or 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
function _build_completions_helper { | |
local current_word | |
COMPREPLY=() | |
current_word=${COMP_WORDS[COMP_CWORD]} | |
COMPREPLY=($(compgen -W "${PROGRAM_COMMANDS}" -- $current_word)) | |
return 0 | |
} | |
# param 1: command to build completions for. Ex: fab | |
# |
This file contains hidden or 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
# Show commits that are in feature123_rebased_on_master but not in feature123, even though they have aquired new commit ids due to rebase. | |
git log --cherry-pick --left-right feature123...feature123_rebased_on_master ^master |
This file contains hidden or 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
/* | |
GNU GENERAL PUBLIC LICENSE | |
Version 3, 29 June 2007 | |
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> | |
Everyone is permitted to copy and distribute verbatim copies | |
of this license document, but changing it is not allowed. |
This file contains hidden or 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 java.util.concurrent.Executors | |
import concurrent.ExecutionContext | |
import concurrent.Future | |
import concurrent.Await | |
import scala.concurrent.duration._ | |
implicit val executionContext = ExecutionContext.fromExecutorService(Executors.newFixedThreadPool(2)) | |
Await.ready(Future { println("sdf") }, 3.seconds) |
This file contains hidden or 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
CMD='last=JSON.load(ARGF.read)["data"]["last"]["display"]; puts "#{Time.now}: #{last}"'; watch "curl https://data.mtgox.com/api/2/BTCUSD/money/ticker 2>/dev/null | ruby -r json -e '$CMD'" |
This file contains hidden or 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
# Communicate with an IRC channel from the shell | |
# | |
# Runs in background, writes messages to stdout in tty | |
# Depends on sic | |
TMPF=ircsession.tmp; CHAN='#testircfrombash'; ME=bot001; cat /dev/null > $TMPF; (tail -f $TMPF | sic -h irc.freenode.net -p 6667 -n $ME | while read MSG; do case "$MSG" in "$ME"*) echo ":j $CHAN" >> $TMPF;; "$CHAN"*) echo "$MSG";; esac; done;) & | |
# Then, to write to the channel: | |
echo "Hello all!" >> $TMPF | |
# or open a buffer to write many rows: |