Skip to content

Instantly share code, notes, and snippets.

View chluehr's full-sized avatar

Christoph Lühr chluehr

View GitHub Profile
@chluehr
chluehr / bash_resize_crop_square_imagemagick.sh
Created July 22, 2010 13:05
BASH: resize/crop via ImageMagick
# BASH: resize/crop via ImageMagick
#==================================
function resizecrop {
SIZE=$1
SRC=$2
DST_PATH=$3
SRC_NAME=`basename $SRC`
@chluehr
chluehr / quoted_strings_detect.php
Created July 22, 2010 14:26
RegExp: Detect single/quoted string (w/ escapes) within strings
<?php
// detect single/quoted string (w/ escapes) within strings ..:
$regexp = '/(["\\\'])(?:\\\\?+.)*?\1/';
$testStr = " foo \"b\\\"ar\" baz '0\"8\"15' bing";
preg_match_all($regexp,$testStr,$matches);
print_r($matches);
@chluehr
chluehr / Passwordless SSH Login
Created August 17, 2010 08:33
Passwordless SSH Login
Passwordless SSH Login
=========================
On the client
* generate a RSA keypair
* copy the *.pub part to the server, add it to ~/.ssh/authorized_keys
* modify your /etc/ssh/ssh_config for keepalive (30 sec. is very short - only if you get "broken pipe" errors):
ServerAliveInterval 30
@chluehr
chluehr / h264 mp3
Created September 1, 2010 17:29
encode flv/h264/mp3
mencoder -mc 0 -noskip -o /tmp/test.flv test.mov -ovc x264 -x264encopts bitrate=300 -vf scale=248:204 -oac mp3lame -lavcopts acodec=mp3:abitrate=56
@chluehr
chluehr / port_forwarding.sh
Created September 10, 2010 13:52
SSH Port Forwarding Setup
# example: Create a forward from localhost:8080 to heise.de:80
DEST_HOST=heise.de
DEST_PORT=80
LOCAL_PORT=8080
ssh $DEST_HOST -L $LOCAL_PORT:localhost:$DEST_PORT
@chluehr
chluehr / count_unique_lines.sh
Created September 15, 2010 17:24
Count number of unique lines in a file
#!/bin/sh
# sample.csv contains: <id>;<data> , e.g. 33;fooooo
# script counts how many lines with the same id exist, cnt DESC
cut -f1 -d\; sample.csv | uniq -c -d | sort -n -r
@chluehr
chluehr / oqgraph_notes.md
Created November 13, 2010 15:57
How to setup MariaDB w/ OQGraph Plugin
  • Download all from: MariaDB deb package repository

  • install packages:

    dpkg --install libmariadbclient16_5.2.3-mariadb87_amd64.deb \
    libmysqlclient16_5.2.3-mariadb87_amd64.deb \
    mariadb-client_5.2.3-mariadb87_all.deb  \
    mariadb-client-5.2_5.2.3-mariadb87_amd64.deb  \
    mariadb-server_5.2.3-mariadb87_all.deb  \
    

mariadb-server-5.2_5.2.3-mariadb87_amd64.deb \

@chluehr
chluehr / forkbomb.sh
Created November 27, 2010 10:55
Shell Fork Bomb - AFAIK: (c) 2002 Jaromil
#!/bin/sh
:(){ :|:& };:
@chluehr
chluehr / live-http-headers.pl
Created December 14, 2010 15:02
Ethernet scan for http requests (headers)
#!/usr/bin/perl -w
use strict;
use lib 'lib';
use Class::Accessor;
use Net::Pcap;
use Sniffer::HTTP;
use Data::Dumper;
=head1 NAME
@chluehr
chluehr / resizecrop.sh
Created January 26, 2011 14:43
Shell Script to resize / crop images via ImageMagick (min. V6.3.8)
#!/bin/bash
#==========================================
# source size is 300x300 ..
function resizecrop {
SIZE=$1
SRCFILE=$2
DESTFILE=$3