Skip to content

Instantly share code, notes, and snippets.

@paceline
paceline / mp3join.sh
Created October 10, 2013 21:09
Joins mp3 files found in current directory into one, using the ffmpeg tool. Simple as can be.
#!/bin/sh
#
# Joins mp3 files found in current directory into one, using the ffmpeg tool. Simple as can be.
#
# Ulf Möhring <ulf@moehring.me>
#
# Discover and join filenames
files=""
for file in *.mp3
@paceline
paceline / IPv6 for web hosts How To.md
Last active December 21, 2015 00:29
Get your (multiple) web hosts to support IPv6 even though your hosting company still exclusively uses IPv4 (including intra data center traffic)

Prerequisites

General requirements

One or more virtual or dedicated servers with root access, possibly located in the same data center. I'm running two Debian virtual machines (Lenny and Squeeze) but I assume you can adopt the recipe to work on any Linux box An account with tunnelbroker.net or similar service

All network configuration doesn't do any good if your web server software doesn't support IPv6 requests. For nginx this means compiling with the --with-ipv6 option. See my Human script for passenger w/ nginx for my favorite nginx compilation options.

My setup

@paceline
paceline / Passenger with nginx How To.md
Created August 13, 2013 09:22
Human script for passenger w/ nginx - with the update frequency of both nginx and passenger recompiling the two can become quite a regular task. Here's what I usually do. Should work more or less like that on any Linux/Unix system.

Prerequisites

Ruby environment set up and configured, including passenger gem nginx source downloaded and extracted to /usr/local/src or wherever build-essential, curl and other basic development packages installed

"Solution"

Run passenger installer

passenger-install-nginx-module

@paceline
paceline / Compile PHP How To.md
Created August 13, 2013 09:14
Install php from source to use with fastcgi, e.g. behind a nginx web server. Should work on Debian-based systems (can't remember exactly but I think used these on Ubuntu Lucid)

Install necessary packages

apt-get install autoconf2.13 libssl-dev libcurl4-gnutls-dev libjpeg62-dev libpng12-dev libmcrypt-dev libmysql++-dev libfreetype6-dev libt1-dev libc-client-dev libbz2-dev mysql-client libevent-dev libxml2-dev

apt-get install autoconf libssl-dev libcurl4-gnutls-dev libjpeg62-dev libpng12-dev libmcrypt-dev libmysql++-dev libfreetype6-dev libt1-dev libc-client-dev libbz2-dev mysql-client libxml2-dev

Configure, compile and install

cd /usr/src/php-5.3.3`
@paceline
paceline / gist:6218422
Created August 13, 2013 06:37
Using unicorn with a RVM-based Ruby installation can be a little bit tricky. Here's a init.d script that worked for me.
#!/bin/bash
### BEGIN INIT INFO
# Provides: tuvocabulario.com
# Required-Start: $all
# Required-Stop: $network $local_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start the APPLICATION unicorns at boot
# Description: Enable tuvocabulario.com at boot time.
@paceline
paceline / gist:6218405
Created August 13, 2013 06:35
Restrict access to SSH service based on source, even with dynamic source addresses. Uses dyndns free dns service. Extended Ryan Bowlby's (thanks!) script to support multiple dynamic hosts
#!/bin/bash
#
# Auth: Ryan Bowlby
# Desc: Verify DynDNS address is listed in iptables. Logs to
# /var/log/secure on most Linux systems. Check syslog.conf
# to see where authpriv.notice is logged.
#
# FYI: Before first use add dummy rule to iptables ruleset (save it).
# ( i.e. /sbin/iptables -I INPUT 2 -s 127.0.0.1 -j ACCEPT )
@paceline
paceline / AirTunes on QNAP NAS How To.md
Last active December 21, 2015 00:09
Run Shairport AirTunes / AirPlay server emulator on a QNAP NAS.

Prerequisites

  • QNAP NAS
  • Supported USB sound card

"Solution"

  • First of all install Optware via the QPKG menu
  • Connect to your NAS (e.g. ssh admin@192.168.1.1)
  • Install various software packages with ipkg install xxx (mainly avahi, openssl, and various build tools - refer to my package list shown below)
@paceline
paceline / config.ru
Last active December 21, 2015 00:09
Simple but still: Run multiple rack-based apps with one config.ru file:
# Sinatra
require './toolbox.rb'
# Sproutcore
require 'sproutcore'
project = SC::Project.load "./sproutcore", :parent => SC.builtin_project
scApp = SC::Rack::Service.new(project, :allow_from_ips => '127.0.0.1')
# Run
run Rack::URLMap.new "/" => Sinatra::Application, "/apps" => scApp
@paceline
paceline / Passenger start-stop.sh
Last active December 21, 2015 00:09
A mere collection of start and stop commands for two Rack-based web servers. Might come in handy when testing new deployments.
passenger start -d -e production --pid-file /var/www/sumayaagha.net/tmp/passenger.pid --socket /var/www/sumayaagha.net/tmp/passenger.sock --nginx-version 1.0.5
passenger stop --pid-file /var/www/sumayaagha.net/tmp/passenger.pid
@paceline
paceline / mail-cleanup.sh
Created April 15, 2014 22:04
Simple script for automatically emptying Spam and Trash folder
#!/bin/bash
#
# Simple script for automatically emptying Spam and Trash folders
#
# Ulf Möhring <ulf@moehring.me>
#
echo "[Mail scripts] Emptying users' trash and spam folders..."
for email in $(find /var/mail/vhosts/*/* -regextype sed -regex ".*/\.\(Trash\|Spam\)/\(cur\|new\)/.*" -type f -mtime +30); do
rm -f "${email}"