curl -ks https://gist.github.com/nicerobot/4751388/raw/run.sh | sh
// This is an example of how to reason about covariance vs contravariance. | |
// Between the two co*.reasoning.scala examples, the following compiles but meaning is slightly different due to the class hierarchy. | |
type SHORT = A[SMALL] | |
type INT = A[MEDIUM] | |
type LONG = A[LARGE] | |
val s:SHORT = new SHORT() | |
val i:INT = s |
Let's say i want to apply functions a
, b
, c
, and d
to each element of a list, xs
, such that the result of a
is passed to b
who's result is passed to c
who's result is passed to d
. It's:
xs.map(a).map(b).map(c).map(d)
or
xs.map(d(c(b(a(_)))))
To me, that's clear (assuming the naming is clearly defined), but it probably doesn't read well since, at least in english, we read left to right, not inside-out (nor right to left).
#!/bin/bash | |
# http://www.readability.com/read?url=http://pynash.org/2013/02/25/Heroku-Like-Deploys-on-AWS.html | |
# http://stackoverflow.com/questions/5009324/node-js-nginx-and-now | |
app=${1:-app${RANDOM}} | |
cd | |
# TODO provision |
curl -ks 'https://gist.githubusercontent.com/nicerobot/5160658/raw/install-gdalpc.sh' | sudo bash -
In Scala, "DI" should stand for "Default/Implicit".
curl -ks https://gist.githubusercontent.com/nicerobot/5203624/raw/di.sh | bash -
A simple type of dependency injection can be accomplished with default parameters. It is enhanced further with implicits.
It's not perfect. For example, implicits don't seem to cascade so the ones to inject have to be explicitly defined each time. But the primary reason for DI is to decouple code (while costing simplicity). I think this approach accomplishes the goal and with less complexity because it doesn't require any framework and relies on rudimentary Scala features.
#!/bin/bash | |
csv2tsv() { | |
local tsv=$(dirname ${1})/$(basename ${1} .csv).tsv | |
python -c "import csv; csv.writer(file('${tsv}', 'w+'), delimiter='\t').writerows(csv.reader(open('${1}')))" | |
} |
#!/bin/bash | |
grep "^## " "$0" | cut -c 4- | groff -Tascii -man | more | |
## .TH USAGE 1 "March 24 2013" "Version 1.0" "USER COMMANDS" | |
## .\" strings | |
## .ds ex \fIexpr\fR | |
## .SH NAME | |
## usage \- example of incorporating usage | |
## .SH SYNOPSIS |
Add before /body:
<script src="//d3js.org/d3.v3.min.js"></script>
<script src="//gist.googlecode.com/svn/trunk/kares/script.js"></script>
<script src="//gist.googlecode.com/svn/trunk/nicerobot/5233890/replacegista.js"></script>
You can then just add normal markdown references to a gist like this gist and it'll find them and replace them with the embedded gist. Example tumblr post.
I looked at soemarko/1395926 but I didn't want to have to use a div since Markdown already inserts a link. Also, it degrades nicely in case something with the scripts breaks. Lastly, D3 is much more fun than jQuery :P
curl -ks https://gist.github.com/nicerobot/5259643/raw/run.sh | bash -
Python code swiped from this stackoverflow.