<commit_before>#!/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 main' README.md doc/*.md
}

#
# Aliases
#

make-alias() {
  pushd plugins
  # assume terminal is ansi
  ln -s -v ansi typescript
  ln -s -v jpeg jpg
  ln -s -v html htm
  ln -s -v markdown md

  # TODO: make your own png plugin, should show metadata, etc.
  # "file" shows dimensions, colormap, etc. of png
  ln -s -v Rplot.png png
  popd
}

"$@"
<commit_msg>Preview jpg in webpipe.<commit_after>#!/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 main' README.md doc/*.md
}

#
# Aliases
#

make-alias() {
  pushd plugins
  # assume terminal is ansi
  ln -s -v ansi typescript
  ln -s -v jpeg jpg
  ln -s -v html htm
  ln -s -v markdown md

  # TODO: make your own png plugin, should show metadata, etc.
  # "file" shows dimensions, colormap, etc. of png
  ln -s -v Rplot.png png

  # For now, jpeg does what png does.
  ln -s -v png jpeg

  popd
}

"$@"

{'fraction_non_alphanumeric': 0.15796344647519583, 'fraction_numerical': 0.016971279373368148, 'mean_word_length': 2.733252131546894, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1898132', 'n_tokens_mistral': 1356, 'n_tokens_neox': 1262, 'n_words': 343}