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
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
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
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
### 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
#! /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
#!/usr/bin/ruby | |
require 'cgi' | |
require 'erb' | |
cgi = CGI.new('html') | |
template = <<TEMPLATE | |
<html> | |
<head> |
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
require 'webrick' | |
require 'erb' | |
template = <<TEMPLATE | |
<html> | |
<head> | |
<title>Ruby as PHP</title> | |
</head> | |
<body> | |
<h1>Loop</h1> |
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
# Create svg graph file | |
cat plotdata_raw | gnuplot -e "set terminal svg; plot '-' using 2:1 with lines" > my_graph.svg | |
# where plotdata_raw is a file with data, 2 columns separated by whitespace. | |
# using 2:1 means: use column 2 as x, column 1 as y axis | |
# with lines: draw a line graph | |
# Parse time | |
cat plotdata_raw | gnuplot -e "set xdata time; set timefmt '%s'; plot '-' using 2:1 with lines" -p |
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
// Lives at: https://gist.github.com/3103615/ | |
function cartesianProduct(xss) { | |
if (!xss || xss.length < 1) | |
return []; | |
else { | |
var head = xss[0]; | |
var tail = xss.slice(1); | |
var result = []; | |
for (var i = 0; i < head.length; i++) { | |
var productOfTail = cartesianProduct(tail); |