$ sudo -u postgres psql
postgres=# CREATE ROLE foouser WITH LOGIN PASSWORD '************';
| #!/usr/bin/env groovy | |
| /* | |
| Generates a template for journal (for a single month). | |
| Example: | |
| Journal 2013/11 |
| def gandalf(func): | |
| def inner(*args, **kwargs): | |
| raise ValueError("You shall not pass!") | |
| return func(*args, **kwargs) | |
| return inner | |
| @gandalf | |
| def balrog(): | |
| pass |
| #!/usr/bin/env python | |
| # ByteBeats - byte-level procedural music | |
| # | |
| # Source: Jamey at Royal Paw | |
| # http://royal-paw.com/2012/01/bytebeats-in-c-and-python-generative-symphonies-from-extremely-small-programs/ | |
| # | |
| # Adapted to run in a single script. | |
| # | |
| # run as: | |
| # $ python bytebeats.py 0 | sox -r 8000 -b 8 -c 1 -t raw -e signed-integer - -d |
| import socket | |
| def netcat(hostname, port): | |
| """ | |
| Reads lines from a network socket and prints them to standard output. | |
| Similar to: netcat $HOST $PORT. | |
| """ | |
| s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| s.connect((hostname, port)) | |
| socket_file = s.makefile() |
| import zmq | |
| import time | |
| context = zmq.Context() | |
| socket = context.socket(zmq.PUB) | |
| socket.connect("tcp://127.0.0.1:5556") | |
| # Sleep a bit of time until the connection is properly established, | |
| # otherwise some messages may be lost. | |
| # http://stackoverflow.com/questions/7470472/lost-messages-on-zeromq-pub-sub |
| # https://spark.apache.org/downloads.html | |
| # https://spark.apache.org/docs/latest/ | |
| # download | |
| wget http://d3kbcqa49mib13.cloudfront.net/spark-2.0.0-bin-hadoop2.7.tgz | |
| # verify the checksum | |
| curl http://www.apache.org/dist/spark/spark-2.0.0/spark-2.0.0-bin-hadoop2.7.tgz.md5 | |
| md5sum spark-2.0.0-bin-hadoop2.7.tgz |
| // run eg. in spark-shell... | |
| // uncompressed CSV without a header | |
| val df = spark.read.csv("input.csv") | |
| df.write.format("parquet").save("output.parquet") | |
| // it produces a directory output.parquet/ with the following content: | |
| // | |
| // ls -l output.parquet/ | |
| // -rw-r--r-- 1 bza bza 146346 Sep 29 16:06 part-r-00000-8a89541d-9071-4246-b525-22e894ef3e0b.snappy.parquet |