Eventually I get into producing something I think is useful for others. You'll find random technical knowledge in this Blog so please be patient and use the search function. Some of these software are rather lame and old, the list is ordered by the approximate age (newest first). Unfortunately my older stuff are lost or scattered around my old CDs, not readable anymore 8(.
As an user of OpenVZ it's often my task to migrate database driven web applications to separate environments. In recent versions of OpenVZ, bind mounting of sockets between virtual environments is prohibited. I had to find a way to proxy local connections to /var/run/mysqld/mysqld.sock to the remote mysql server.
First I've created a mysql user and group:
addgroup --system mysql adduser --system --home /var/run/mysqld --ingroup mysql mysql
Then I've installed and configured the excellent socat utility using launchtool.
db.vz is the address remote database host in the following executable launchtool configuration script
#!/usr/bin/launchtool -C tag = mysql-proxy daemon = yes user = mysql command = socat UNIX-LISTEN:/var/run/mysqld/mysqld.sock,fork,mode=0666 TCP:db.vz:3306,forever start dir = /var/run/mysqld wait times = 5 infinite runs = yes stats = yes launchtool output = syslog:mysql-proxy,LOG_DAEMON,LOG_INFO launchtool errors = syslog:mysql-proxy,LOG_DAEMON,LOG_ERR command output = syslog:mysql-proxy,LOG_DAEMON,LOG_INFO command errors = syslog:mysql-proxy,LOG_DAEMON,LOG_ERR
A very small GAWK script that splits a mysql text dump to separate table dump files.
#!/bin/sh # GPLv2 by Erno Rigo <mcree_AT_tricon_DOT_hu> gawk ' BEGIN { FS=" "; dest="/dev/null" } /^(USE)/ { dir=gensub(";","","g",$2) ; dir=gensub("`","","g",dir) ; system("mkdir "dir) } /^(CREATE|USE|DROP)/ { fflush(dest); dest="/dev/null" } /^CREATE TABLE/ { file=gensub("`","","g",$3) ; fflush(dest); dest=dir"/"file".sql" } { print >> dest } '
MuddleFTPD scripting patch - This is a diff patch for muddleftpd to allow running of external scripts upon ftp events such as finished uploads. The patch has a race condition which has not been fixed. The patch was dropped by the muddleftpd team because it executes external commands (why… that's its purpose anyway). Now I recommend you to use proftpd or pure-ftpd instead…
freemail.zip - My old contribution to the web IMAP email gateway scene. Written in an early version of PHP in 2001 and it's still in use somewhere (I won't tell you: use google…).
This PHP code snippet is userful in removing accents from international (latin), especially hungarian texts.
<?PHP function unaccent($txt) { return strtr(recode("utf8..l1",strtr($txt,"őŐűŰ","oOuU")), "\xe1\xc1\xe0\xc0\xe2\xc2\xe4\xc4\xe3\xc3\xe5\xc5". "\xaa\xe7\xc7\xe9\xc9\xe8\xc8\xea\xca\xeb\xcb\xed". "\xcd\xec\xcc\xee\xce\xef\xcf\xf1\xd1\xf3\xd3\xf2". "\xd2\xf4\xd4\xf6\xd6\xf5\xd5\x8\xd8\xba\xf0\xfa\xda". "\xf9\xd9\xfb\xdb\xfc\xdc\xfd\xdd\xff\xe6\xc6\xdf\xf8"."őŐűŰ", "aAaAaAaAaAaAacCeEeEeEeEiIiIiIiInNo". "OoOoOoOoOoOoouUuUuUuUyYyaAso"."oOuU"); } function doit($dir) { foreach(glob($dir."/*") as $entry) { echo $entry." => ".unaccent($entry)."\n"; rename($entry,unaccent($entry)); if(is_dir($entry)) doit($entry); } } doit("."); ?>
<< Newer entries | Older entries >>