start new:
tmux
start new with session name:
tmux new -s myname
// simple map and fold left/right implementations | |
// in scala using pattern matching for List[Int] | |
def map(list:List[Int], f:(Int) => Int):List[Int] = { | |
list match { | |
case Nil => Nil | |
case head::tail => f(head)::map(tail, f) | |
} | |
} |
A warning occurred (42 apples) | |
An error occurred |
#!/bin/bash | |
HOST=$(hostname) | |
function install_postfix() { | |
echo | sudo debconf-set-selections <<__EOF | |
postfix postfix/root_address string | |
postfix postfix/rfc1035_violation boolean false | |
postfix postfix/mydomain_warning boolean | |
postfix postfix/mynetworks string 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 |
Note: This was written using elasticsearch 0.9.
Elasticsearch will automatically create an index (with basic settings and mappings) for you if you post a first document:
$ curl -X POST 'http://localhost:9200/thegame/weapons/1' -d \
'{
"_id": 1,
""" | |
An asynchronous task manager. | |
This is a simple implementation for background task handing. No guarentees are | |
provided for task execution. | |
This was developed in the course of the work don for the victims project and | |
that version is available at | |
https://github.com/victims/victims-web/blob/master/src/victims_web/handlers/task.py |
Magic words:
psql -U postgres
Some interesting flags (to see all, use -h
or --help
depending on your psql version):
-E
: will describe the underlaying queries of the \
commands (cool for learning!)-l
: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)May 28, 2014
This code is a companion to the APIcon presentation Real-World Functional Programming by @jearldouglas and @kelleyrobinson. The slides are available here.
In this code, we compare imperative and functional implementations of a withdraw
function that might be used in a banking ATM.