Here’s a simple shell script to stream data to multiple processes. It has many applications, but the reason I wrote it is to stream the same data to multiple netcat processes on remote machines. Here’s the code: #!/bin/bash usage() { cat <&2 usage : multi-fifo target0 [target1 [target2 …]] Where each targetN is a program …
Read More…Tags: Programming
SOUNDEX(), triggers, and stored procedures
MySQL provides a SOUNDEX() function, which returns the soundex of a given string. For details, refer to the manual, but to put it simply, it allows you to compare strings based on how they sound, hence letting you do proximity searches on your database. If you’re just querying for a word, it’s usage is pretty …
Read More…Coding Buddies
Coding Horror always has insightfull articles, and this one on code peer reviews is no exception. Why is it that writers, musicians and, well, any respected and professional artist or scientist gets his/her work reviewed before it’s published, but the same isn’t true in IT? My guess? Most programmers aren’t neither artists, nor scientists. They’re …
Read More…Generating random salts from bash
From the ‘just because it can be done’ column, here comes a handy shell script to generate random salts. So, without further ado, here it goes: #!/bin/bash [ $# -eq 0 ] && { echo “usage: salt <length>”>&2 exit } strings </dev/urandom | while read line; do echo $line | tr ‘\n\t ‘ $RANDOM:0:1 >> …
Read More…Rewriting Highbase in Erlang
Why? Highbase is currently comprised of several shell scripts and some C code. It’s actually a good project (talk about self promotion) that hasn’t reached a stable release yet just because It hasn’t been tested enough in production environments I’ve been amazingly busy during the last years. Lots of work, and lots of parenting in …
Read More…Intrusion detection at the application level, for PHP
Here’s phpids, an Intrusion Detection System for PHP. According to the site, it aims to counter XSS, SQL Injection, header injection, directory traversal, RFE/LFI, DoS and LDAP attacks, and unknown attack patterns, through it’s Centrifuge component. Installation is simple. Just download it, copy the lib directory to a directory in your project structure, or add …
Read More…Symbolics Lisp Machine
Wanna have your own Symbolics Lisp Machine? Here’s the info. I have enough room, I just live a few thousand miles too far, and have to deal with very picky Customs officials.
Read More…Top 25 most dangerous programming errors
Most people make at least 8 or 9 of these in a new project, and this alone is a good reason to use a programming framework, unless you know what you’re doing. The problem is, sometimes, people who skip on frameworks, don’t know what they’re doing. Or, as the Tao of Programming says: There once …
Read More…Running commands from the shell with a timeout (pt 2)
Here’s an improved version of the safecmd script. This one doesn’t always wait for $timeout seconds even if the command you’re running exits successfully. In that case, it kills the monitor script and ends at the proper time. Here’s the code: #!/bin/bash timeout=$1 command=$2 shift 2 check_pid_name() { command=$1 childpid=$2 [ -d /proc/$childpid ] || …
Read More…Running commands from the shell with a timeout
Sometimes, in a shell script, you need to run a command that might go on forever (or an amount of time long enough to be called forever) due to poor coding of the software and wrong external conditions (network down or overloaded, overloaded system, a changed private key, etc). In order to avoid this situations, …
Read More…