-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.sh
executable file
·120 lines (94 loc) · 1.9 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
#
# Misc scripts.
#
# Usage:
# ./run.sh <function name>
set -o nounset
log() {
echo 1>&2 "$@"
}
unit() {
local this_dir=$(dirname $0)
export PYTHONPATH=$this_dir:~/hg/tnet/python:~/hg/json-template/python
"$@"
}
usage-sink() {
# listen in UDP mode on port 8988
log 'usage sink'
nc -v -u -l localhost 8988
}
usage-send() {
echo foo | nc -u localhost 8988
}
usage-config() {
local addr='localhost:19999'
echo $addr > webpipe/usage-address.txt
echo $addr > latch/usage-address.txt
}
#
# Gen testdata
#
make-Rplot-testdata() {
local dir=plugins/Rplot.png/testdata
mkdir -p $dir
local path=$dir/tiny.Rplot.png
R --vanilla --slave <<EOF
png('$path')
plot(1:3)
dev.off()
EOF
ls -l $path
}
make-tar-file() {
local ext=$1
local flag=$2
local out_dir=plugins/tar.$ext/testdata
mkdir -p $out_dir
tar --verbose --create $flag --file $out_dir/tiny.tar.$ext README.md
}
make-tar-testdata() {
make-tar-file gz --gzip
make-tar-file bz2 --bzip2
make-tar-file xz --xz
}
#
# Latch
#
# for doc.sh, use Makefile perhaps?
latch-demo() {
./latch.sh rebuild './doc.sh build' README.md doc/*.md
}
#
# Aliases
#
make-alias() {
pushd plugins
# assume terminal is ansi
ln -s -v -T ansi typescript
ln -s -v -T jpeg jpg
ln -s -v -T html htm
ln -s -v -T markdown md
# TODO: make your own png plugin, should show metadata, etc.
# "file" shows dimensions, colormap, etc. of png
ln -s -v -T Rplot.png png
# For now, jpeg does what png does.
ln -s -v -T png jpeg
ln -s -v -T png gif
popd
}
treemap-client() {
~/hg/treemap/run.sh find-with-format-string '%s %p\n' "$@"
}
# image magick command line to display all exif data
# http://www.imagemagick.org/script/escape.php
# TODO: use this for jpg plugin.
exif() {
identify -format '%[exif:*]' "$@"
}
_link() { ln -s -f -v "$@"; }
install() {
_link $PWD/latch.sh ~/bin/latch
_link $PWD/wp.sh ~/bin/wp
}
"$@"