Skip to content

Instantly share code, notes, and snippets.

@teepark
teepark / gotest
Last active August 19, 2016 18:04
colorful go test output
#!/usr/bin/env bash
set -euo pipefail
go test "$@" | \
sed -E \
-e "/^((--- PASS:.*)|(ok.*)|(PASS.*))$/s//$(printf '\033[32m\\1\033[0m')/" \
-e "/^(\\?.*\\[no test files\\])$/s//$(printf '\033[33m\\1\033[0m')/" \
-e "/^(FAIL.*|--- FAIL:.*)$/s//$(printf '\033[31m\\1\033[0m')/"
@teepark
teepark / whitespace.go
Last active May 24, 2016 22:05
whitespace-eating tags backport wrapper
// +build !go1.6
package main
import (
"regexp"
"text/template"
)
func parseTemplate(tmpl *template.Template, input string) (*template.Template, error) {
import io
def gen_lines(readable, chunk_size=8192, sep=b'\n'):
buf = io.BytesIO()
while 1:
buf.seek(0)
buffered = buf.read()
; problem 5 from https://aphyr.com/posts/305-clojure-from-the-ground-up-macros
(defmacro exact [expr]
`(let [~'+ (fn ([& a#] (apply + (map rationalize a#))))
~'- (fn ([& a#] (apply - (map rationalize a#))))
~'* (fn ([& a#] (apply * (map rationalize a#))))
~'/ (fn ([& a#] (apply / (map rationalize a#))))]
~expr))
(let [* (fn ([& a] (apply * (map rationalize a))))]
(* 2452.45 100))
[192.168.56.3] run: rm /tmp/streamparse_requirements-EWAsyKnfF.txt
Cleaning from prior builds...
Creating topology uberjar...
Uberjar created: /home/travis/storm-vagrant/topo/_build/wordcount-0.0.1-SNAPSHOT-standalone.jar
Deploying "wordcount" topology...
ssh tunnel to Nimbus 192.168.56.1:6627 established.
Routing Python logging to None.
Running lein command to submit topology to nimbus:
lein run -m streamparse.commands.submit_topology/-main topologies/wordcount.clj --option 'topology.workers=2' --option 'topology.acker.executors=2' --option 'topology.python.path="/home/storm/virtualenv_root/wordcount/bin/python"' --option 'streamparse.log.max_bytes=1000000' --option 'streamparse.log.backup_count=10' --option 'streamparse.log.level="info"'
{:option {streamparse.log.level info, streamparse.log.backup_count 10, streamparse.log.max_bytes 1000000, topology.python.path /home/storm/virtualenv_root/wordcount/bin/python, topology.acker.executors 2, topology.workers 2}, :debug false, :port 6627, :host localhost, :help
package main
import (
"fmt"
"image"
"image/jpeg"
"os"
"github.com/nfnt/resize"
"github.com/oliamb/cutter"
package tmp
import (
"bufio"
"bytes"
"mime/multipart"
"net/http"
"net/http/httptest"
"testing"
)
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDCzZNqEwnbuMigKFPFjtHAPTWesENDO+HBkc2J84KKUP9n7jZoUYU2bNHJmpBVPYyBZtZbNbkooDkMW2DX4QzYtPlTTEqaQKIvMEdOCODatcdPTA5kbdouKuWZYCe+4PMoSJ+ThatALxYz/npPCEezIdpxAUKAqcvwH5AJn5gbUQPpDPfaz5B/8gdA+PZhOnZiVie2XckoVwj0I+bdU+OE/7Bab2uVJXIbERqU2cNu32Hu6Bd1+NfB0eXxWJNLmQPFLprWdScpns8HZ4xrdPcf6yFt2dV9YibpgCoX3bd9zrSQoUYRKGwvYwd/qNSliIjGOHojwKWZPbD7olFjoXtZ travis@bubbles
def write_all(fd, data):
while data:
written = os.write(fd, data)
data = data[written:]
def read_all(fd):
t = []
while 1:
x = os.read(fd, 4096)
if not x:
return ''.join(t)
t.append(x)