Skip to content

Instantly share code, notes, and snippets.

View gwpl's full-sized avatar

Grzegorz Wierzowiecki gwpl

  • Europe - usually: Zürich, Warsaw or Berlin
View GitHub Profile
@gwpl
gwpl / README.md
Last active July 28, 2020 20:23
Bash script that generates tex with barcode containing data from commandline. gen_barcode.sh - has "preview|save|print" options and is tailored to be used with Dymo 450 LaberWriter printers. Self-link: https://goo.gl/QCqrOj

This gist consist of tex templates for making barcodes using \psbarcode command using pst-barcode package: https://www.ctan.org/pkg/pst-barcode?lang=en .

Scripts and templates are tailored for use with label printer. I use Dymo 450 LabelWriter under Linux systems (Arch, Ubuntu, Raspibian) without hassle.

However it's easy to modify templates below to work with A4 sheets of label stickers for oridinary ink printers using labels - here is example: http://tex.stackexchange.com/a/289151/7128 .

  • standalone_code128_special_chars.tex - base template
  • standalone_code128_special_chars.sh - base for crafting bash script. It outputs same tex as standalone_code128_special_chars.tex
  • standalone_code128_gen_latex.sh - more generic generator. You can modify output by providing between 0 and 4 optional parameters.
  • gen_barcode.sh - most comprehensive script. It's standalone_code128_gen_latex.sh extended by options : `p
[color]
branch = auto
diff = auto
interactive = auto
status = auto
grep = auto
[alias]
st = status
ci = commit
br = branch
wget -A pdf -c -r -l 1 -nd https://www.raspberrypi.org/magpi-issues/
@gwpl
gwpl / depend_on_hour.sh
Last active May 21, 2017 22:27
Handy snippet to depending behaviour on hour in bash
echo 'Current hour'
hour=$(date +%H);
if [ $hour -gt 9 -a $hour -lt 23 ]; then echo -n '*'; else echo -n '#'; fi; echo ' '$hour;
echo 'Test around the clock:'
for hour in {0..23} {0..23}; do
if [ $hour -gt 9 -a $hour -lt 23 ]; then echo -n '*'; else echo -n '#'; fi; echo ' '$hour;
done
echo 'If you need to depend on UTC, just add `-u` flag to `date` command'
@gwpl
gwpl / PrintTextFitToLabel.sh
Created August 1, 2016 15:02
# type "My\nmultiline\nlabel" and see it printed on 32x57 mm Dymo 450 via network ;) # based on http://unix.stackexchange.com/a/298020/9689
# type "My\nmultiline\nlabel" and see it printed on 32x57 mm Dymo 450 via network ;)
# based on http://unix.stackexchange.com/a/298020/9689
cd /tmp
read -r -p 'Label:' label && convert -background white -fill black -density 600x600 -size 1346x756 -font 'DejaVu-Sans' -gravity center label:"${label}" label.pdf && xpdf label.pdf && lpr -P DYMO_LabelWriter_450_RPi2_B_1st -o raw -o scaling=100 label.pdf
@gwpl
gwpl / glabels-3-fetch_and_print.sh
Created October 12, 2016 20:42
glabels-3-fetch_and_print.sh # wrapper around https://github.com/barcode-utils/glabels-3-templates fetching from given google_spreadsheets sheet
#!/bin/bash
# Usage:
# optionally you can provide .csv file as parameter
# if GLABELS3TEMPLATESDIR= is pointing to directory with glabels-3-templates, then it's copied from there
orig_dir="$PWD"
tmpdir="$(mktemp -d)"
if [ -r "$1" ]; then
@gwpl
gwpl / ubuntu_purge_non_active_kernels.sh
Created November 22, 2016 20:58
/boot full on ubutu! Use last line or full script! Thanks: http://askubuntu.com/a/90219/31300 !
#!/bin/bash
echo Current active: "$(uname -r)"
echo Remove rest:
set -x
sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")
#!/bin/bash
# based on tutorial :
# "How To: Use Your Raspberry Pi as a Proxy for Google Chrome" https://mpacewriting.wordpress.com/2014/01/09/how-to-use-your-raspberry-pi-as-a-proxy-for-google-chrome/
# Notes in : https://docs.google.com/document/d/1NZ1o6HiyqVCgAiScDd0SDJIGR-aon13e6ojh9AjwOa8
select cfg in no_proxy via_p; do break; done
case "$cfg" in
no_proxy)
exec chromium --user-data-dir=/home/${user?}/.config/chromium_p
;;
via_p)
@gwpl
gwpl / boxes.csv
Last active January 31, 2017 15:51
csvsql_query.sh is example usage of `csvsql` direct sql execution on `.csv` files examples, inspired by https://source.opennews.org/en-US/articles/eleven-awesome-things-you-can-do-csvkit/
id name description
33 Music CDs Box with "Music CDs"
44 Movies "Box" Box with Movies
55 Toys Toys
@gwpl
gwpl / csvsql_inventory_join.output.csv
Created January 31, 2017 16:17
csvsql_inventory_join.sh example of csvsql sql query joining scanned barcodes with bardcodes database into more meaningful output
id name
23 Toy T
44 Movie M2
68 Music CD 2