Skip to content

Instantly share code, notes, and snippets.

View EmmanuelKasper's full-sized avatar

Emmanuel Kasper EmmanuelKasper

  • Vienna, Austria
View GitHub Profile
#!/bin/sh
# to be run as postgres user
# a database should be restored as posgres user with
# dropdb popcon
# createdb --encoding=UNICODE --owner=popcon popcon
# psql popcon < popcon.psql
set -e
do_bkp() {
/usr/bin/pg_dump -U postgres --column-inserts --file=/var/backups/postgres/$i.psql $i
@EmmanuelKasper
EmmanuelKasper / backup_postgres
Last active December 27, 2015 09:09
cron.daily entry for postgres backup all
#!/bin/sh
su -l postgres -c /usr/local/sbin/backup_postgres
# a nice comment
@EmmanuelKasper
EmmanuelKasper / backup_vhosts
Last active December 27, 2015 13:38
Simple backup of all Virtual Hosts
#!/bin/sh
[ -d /var/backups/vhosts ] || mkdir /var/backups/vhosts
VHOST_DIR=/srv/www/
cd $VHOST_DIR
for VHOST in *; do
if [ "$VHOST" != "basebox.libera.cc" ]; then
tar cpzf /var/backups/vhosts/$VHOST.tar.gz $VHOST
@EmmanuelKasper
EmmanuelKasper / Puppet Canonical
Last active January 3, 2016 20:59
A canonical puppet deployment file, based on the package / file /service hierarchy
class amanda {
package { "amanda-client":
ensure => installed,
before => File['/etc/amandahosts'],
}
file { "/etc/amandahosts":
ensure => file,
owner => "backup",
group => "backup",
pct enter 142
ps ax
PID TTY STAT TIME COMMAND
1 ? Ss 0:00 init [2]
831 ? Ss 0:00 /sbin/rpcbind -w
951 ? Ssl 0:00 /usr/sbin/rsyslogd
1025 ? Ss 0:00 /usr/sbin/atd
1071 ? Ss 0:00 /usr/sbin/cron
1086 ? Ss 0:00 /usr/bin/dbus-daemon --system
@EmmanuelKasper
EmmanuelKasper / add-certs.sh
Last active February 14, 2016 11:47
Add a self signed certificate to Chrome / Chromium on Linux
#!/bin/sh
# you need to install the libnss3-tools package or equivalent
if [ $# -lt 2 ]; then
echo "Usage: $0 hostname port"
exit 1
fi
hostname=$1
port=$2
@EmmanuelKasper
EmmanuelKasper / create_evolution.sh
Last active May 10, 2016 18:24
Create an evolution script for the play framework based on pg_dump
# after that you need to insert # --- !Ups on top of the generated file
echo '# --- !Ups' > conf/evolutions/default/2.sql
# column inserts are needed in case of new model properties
# we keep only the insert statements, pg_dump comments confuse ebean/play
pg_dump --column-inserts \
--inserts --data-only --exclude-table=play_evolutions \
--username popcon -h localhost popcon \
| grep '^INSERT INTO' \
>> conf/evolutions/default/2.sql
@EmmanuelKasper
EmmanuelKasper / closure.js
Last active December 16, 2016 11:43
Closure Example
var loneTalker = {};
var addSpeach = function(name) {
var text = 'Hello ' + name;
var talk = function() {
console.log(text);
};
loneTalker.talk = talk;
};

commands

#client 
iperf -c pf -i 1 -t 60
#server
iperf -s

server side result vr2: VIA VT6105M Rhine III 10/100BaseTX

@EmmanuelKasper
EmmanuelKasper / vmake.pl
Created October 13, 2017 11:19
Make wrapper to execute make file in a sandbox VM
#!/usr/bin/perl
use strict;
use warnings;
use English;
use Sys::Virt;
use Net::OpenSSH;
use File::Spec;
use File::Basename;
use Cwd 'realpath';