Skip to content

Instantly share code, notes, and snippets.

View sepastian's full-sized avatar
💭
\_ . |‾‾‾| o-`o

Sebastian Gassner sepastian

💭
\_ . |‾‾‾| o-`o
View GitHub Profile
@sepastian
sepastian / gist:5695396
Last active December 18, 2015 00:18
Compiling Ruby 1.8.4 with Tcl/tk support and Rubygems-0.9.0 (plus several ancient gems) under Ubuntu 13.04
# Compiling Ruby 1.8.4 with Tk from source under Ubuntu 13.04
# Install Rubygems 0.9.0 from source and various gems
# Download sources
~$ cd build
~/build$ wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.4.tar.gz
~/build$ wget http://prdownloads.sourceforge.net/tcl/tcl8.5.14-src.tar.gz
~/build$ wget http://prdownloads.sourceforge.net/tcl/tk8.5.14-src.tar.gz
~/build$ wget http://rubyforge.org/frs/download.php/11289/rubygems-0.9.0.tgz
~/build$ tar xf ruby-1.8.4.tar.gz
@sepastian
sepastian / zebra.rb
Last active January 15, 2018 07:28
Print a label on a Zebra TLP 2844 in Ruby. The printer is EPL/2 capable and connected via USB.
# Print a label on a Zebra TLP 2844 in Ruby.
# The printer is EPL/2 capable and connected via USB.
# EPL/2 reference: http://www.zebra.com/apps/dlmanager?dlp=-227178c9720c025483893483886ea54a70963bb77ca94fcc1d65ce9394326ed960e43d023beba35831d5d9bfc1740296347157b5024977a&c=gb&l=en
# https://github.com/larskanis/libusb
require 'libusb'
# Select the printer by vendor ID and product ID.
# To get a list of connected devices, use 'lsusb'.
# 0a5f:0x000a identifies the Zebra TLP 2844.
@sepastian
sepastian / postgres_restore_binary.sh
Last active December 20, 2015 03:09
Restore a binary dump in PostgreSQL.
# In /etc/postgresql/9.1/main/pg_hba.conf, change
#
# local all all peer
#
# to
#
# local all all md5
#
# and restart the Postgres server:
@sepastian
sepastian / brother_mfc-8460n_ubuntu_13.04
Last active December 20, 2015 10:09
Install the Scanner of a Brother MFC-8460N in Ubuntu 13.04. The printer is connected via network.
# Based on http://wiki.ubuntuusers.de/Brother/Scanner and http://ubuntuguide.org/wiki/MFC-7820N
#
# System information.
$ uname -m
x86_64
$ cat /etc/issue.net
Ubuntu 13.04
# Download and install the driver.
@sepastian
sepastian / solarize
Created July 30, 2013 21:33
Shell script for setting the the solarized theme to use, either 'dark' or 'light'.
#!/bin/bash
#
# Shell script for setting the the solarized theme to use,
# either 'dark' or 'light'.
#
# If no argument has been given, toggle between 'dark' and 'light'.
#
# Adapted from https://github.com/jouberthenk/dotfiles/blob/master/solarize.sh
#
# Solarized theme: http://ethanschoonover.com/solarized
@sepastian
sepastian / avonv_images_to_video.sh
Last active December 22, 2015 07:28
Convert multiple images into a video using avconv. NOTE that the image names must be numbered! (avconv did not accept images named "DSC_2XXX.JPG".)
# Copy and rename images to "%04d.jpg"
i=0; ls /CAMERA/*JPG | while read f; do cp "$f" "./$(printf '%04d.jpg' $i)"; let i=$(($i+1)); done
# Convert all images named "%04d.jpg" to a video.
avconv -f image2 -r 12 -i %04d.jpg -vcodec libvpx -deadline good -cpu-used 0 -b:v 500k -qmin 10 -qmax 63 -vf scale=1024:-1 RESULT.webm
@sepastian
sepastian / im_montage.sh
Last active December 23, 2015 16:49
Imagemagick recipies.
# Arange several images into a single images consisting of 1 tile per image.
# The final image will consist of a single row of 4 images,
# each 1200x in size, with 20 pixels padding around each border.
# The background color of the output image is black.
$ montage -tile 4x1 input_image_1 input_image_2 input_image_* -geometry 1200x+20+20 -background black output.jpg
# Center an original image above a white background that is larger than the original image.
$ convert -gravity Center INPUT.png -background white -extent 600x650 OUTPUT.png
@sepastian
sepastian / OpenWRT_TP-LINK_MR3220_V2.2.md
Last active September 29, 2022 14:27
Installing OpenWRT on a TP-LINK MR3220 V2.2.
@sepastian
sepastian / gst_tools_examples.sh
Created October 7, 2013 12:10
Use gst-launch (gstreamer-tools) to capture single images and stream video from the command-line.
# Capture a single image and save it in JPEG format.
$ gst-launch v4l2src num-buffers=1 ! jpegenc ! filesink location=/tmp/test.jpg
# Stream video from a webcam.
$ gst-launch v4l2src ! xvimagesink
@sepastian
sepastian / multi_cartesian_product.rb
Last active January 11, 2023 09:26
Build the cartesian product of multiple arrays in Ruby.
# Given an array of arrays s = [ [1,2,3], [4,5,6], ... ]
# compute the Cartesian product among the elements of s.
require 'pp'
s = [[1, 2], [3, 4, 5], [6, 7, 8, 9]]
pp s[1..-1].inject(s[0]){ |m,v| m = m.product(v).map(&:flatten) }
[[1, 3, 6],
[1, 3, 7],
[1, 3, 8],