Skip to content

Instantly share code, notes, and snippets.

View hohl's full-sized avatar

Michael Hohl hohl

View GitHub Profile
package hohl.irc
/*
<message> ::= [':' <prefix> <SPACE> ] <command> <params> <crlf>
<prefix> ::= <servername> | <nick> [ '!' <user> ] [ '@' <host> ]
<command> ::= <letter> { <letter> } | <number> <number> <number>
<SPACE> ::= ' ' { ' ' }
<params> ::= <SPACE> [ ':' <trailing> | <middle> <params> ]
<middle> ::= <Any *non-empty* sequence of octets not including SPACE or NUL or CR or LF, the first of which may not be ':'>
<trailing> ::= <Any, possibly *empty*, sequence of octets not including NUL or CR or LF>
@hohl
hohl / Parser.scala
Created September 14, 2015 09:21
Why does this single test case fail, while others work as expected?
// ...
lazy val prefix: Parser[Prefix] =
(host | nick) ~ opt('!' ~> user) ~ opt('@' ~> host) ^^ {
case t ~ u ~ s => Prefix(t, u, s)
}
lazy val host = """[a-zA-Z0-9.:\-^_\-\[\]\\/`]+""".r
lazy val nick = """(\p{L}|[0-9]|[-_\[\]\\`^\{\}\|])+""".r
lazy val user = """[^(\s|@)]+""".r
@hohl
hohl / pg_backup.sh
Last active September 5, 2015 11:35
Bash script which dumps a Postgres DB and uploads it via SFTP
#!/bin/bash
# Purpose: Dumps a PostgreSQL database and uploads it via SFTP to another host.
# Author: Michael Hohl <me@michaelhohl.net>
# -----------------------------------------------------------------------------
display_usage() {
echo "Usage: $0 <dbname> <user@stfp-target>"
}
if [ $# -ne 2 ]; then
@hohl
hohl / RedisEventEmitter.test.ts
Last active August 29, 2015 14:18
RedisEventEmitter for Node.JS written in TypeScript
/*
*
* █████╗ ██╗ ██╗ ██╗ █████╗ ██╗ ██╗███████╗ ██████╗ ███╗ ██╗ ██╗██████╗ ██████╗
* ██╔══██╗██║ ██║ ██║██╔══██╗╚██╗ ██╔╝██╔════╝██╔═══██╗████╗ ██║██╗██╗██║██╔══██╗██╔════╝
* ███████║██║ ██║ █╗ ██║███████║ ╚████╔╝ ███████╗██║ ██║██╔██╗ ██║╚═╝╚═╝██║██████╔╝██║
* ██╔══██║██║ ██║███╗██║██╔══██║ ╚██╔╝ ╚════██║██║ ██║██║╚██╗██║██╗██╗██║██╔══██╗██║
* ██║ ██║███████╗╚███╔███╔╝██║ ██║ ██║ ███████║╚██████╔╝██║ ╚████║╚═╝╚═╝██║██║ ██║╚██████╗
* ╚═╝ ╚═╝╚══════╝ ╚══╝╚══╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ╚═════╝
*
*