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(.
parancssori_leckek_2009-04-21.tgz - a basic step-by-step shell environment I'm using for teaching Linux commandline basics.
In my opinion awstats is THE apache log file analyzer solution. Unfortunately it does not support automatic configuration based on the webserver configuration, which is a great feature to miss IMHO. The following shell script has 3 different sections:
#!/bin/bash apacheconf="/etc/apache2/apache2.conf" awstatsconf="/etc/awstats/awstats.conf" indexfile="/home/ideart/public_html/awstats-index.html" urlbase="http://www.ideart.hu/awstats?config=" lockfile="/var/run/$0.pid" ############################################################################# #locking if [ -f "$lockfile" ]; then ps -p `cat "$lockfile"` >/dev/null || rm -f "$lockfile" # rm stale lockfile exit 0 fi trap "rm -f '$lockfile'" exit echo $$ > "$lockfile" awstatsdir=`dirname "$awstatsconf"` cat_apacheconf() { #echo "catting $1" >&2 depth=$(( $2 + 1 )) if [ $depth -ge 1000 ]; then return fi if [ -f "$1" ]; then # arg is a file cat "$1" | egrep -i '^[^#]*include[[:space:]]' | awk '{ print $2 }' | ( while read conf; do cat_apacheconf "$conf" $depth done ) cat "$1" elif [ -d "$1" ]; then # arg is a directory pushd "$1" > /dev/null ls -1 . | ( while read conf; do cat_apacheconf "$conf" $depth done ) popd > /dev/null else # arg is a glob pattern dir=`dirname "$1"` base=`basename "$1"` pushd "$dir" > /dev/null ls -1 $base | ( while read conf; do cat_apacheconf "$conf" $depth done ) popd > /dev/null fi cat_apacheconf "$apacheconf" | gawk -v awstatsdir="$awstatsdir" -v awstatsconf="$awstatsconf" -v indexfile="$indexfile" -v urlbase="$urlbase" ' BEGIN { IGNORECASE=1 servername=default virtualhost=default serveralias="" print "<h1>awstats index file</h1>" > indexfile } /^[^#]*virtualhost[[:space:]]/ { virtualhost = $2 gsub("[*<> ]","",virtualhost) } /^[^#]*servername[[:space:]]/ { servername = $2 } /^[^#]*serveralias[[:space:]]/ { serveralias = serveralias " " $2 } /^[^#]*transferlog[[:space:]]/ { transferlog = $2 print "<a href=\"" urlbase servername "_" virtualhost "\">" servername "_" virtualhost "</a><br />" >> indexfile newconf= awstatsdir "/awstats." servername "_" virtualhost ".conf" cmd="test -f " newconf if ( system(cmd) == 0 ) { #print newconf " exists already - skipping" } else { #print newconf " did not exist - creating" print "# autogenerated config file" >> newconf print "Include \"" awstatsconf "\"" >> newconf print "SiteDomain=\"" servername "\"" >> newconf print "HostAliases=\"" serveralias " 127.0.0.1 localhost\"" >> newconf print "LogFile=\"" transferlog "\"" >> newconf print "LogType=W" >> newconf print "LogFormat=1" >> newconf } serveralias="" } ' [ -f /etc/awstats/awstats.conf ] && /usr/lib/cgi-bin/awstats.pl -config=awstats -update >/dev/null for cfg in `find /etc/awstats -name 'awstats.*.conf' -printf '%f\n' | sed 's/^awstats\.\(.*\)\.conf/\1/'`; do /usr/lib/cgi-bin/awstats.pl -config=$cfg -update >/dev/null done exit 0
Apparently, IE7 fails to submit the form with the default button if the form only contains one text input box. Here is the fix for that. Just create a text input in a hidden div on the page. This will circumvent the IE bug.
Example div:
<!-- Fix for IE bug (One text input and submit, disables submit on pressing "Enter") --> <div style="display:none"> <input type="text" name="hiddenText"/> </div>
Also see: http://stackoverflow.com/questions/270494/enter-button-does-not-submit-form-ie-only-asp-net
I use this code to enhance photographs or other image files taken from black and white text. Does great job for optical character recognition, printing and other purposes. This script is using ImageMagick to do the actual job.
#!/bin/bash mkdir "bw" for x in *.jpg ; do b=`basename $x .jpg` echo $x convert -noise 1 -unsharp 10x5+10 -threshold 20% "$x" "bw/$b.pbm"; unpaper "bw/$b.pbm" "bw/unpaper_$b.pbm" convert "bw/unpaper_$b.pbm" "bw/$b.png"; rm -f "bw/$b.pbm" "bw/unpaper_$b.pbm" done
Recently I've been figting with IE7 to act like Mozilla Firefox and allow position:fixed CSS properties to work properly. As I'm using PHP, I had to come up with a complex solution that worked correctly on both modern browsers. Since the CSS fix for IE7 is incompatible with Firefox I had to split the CSS in two by testing the user agent in PHP. The details are in the code:
<?PHP // this script simply searches for a substring in HTTP_USER_AGENT function inAgent($agent) { global $HTTP_USER_AGENT; $notAgent = strpos($_SERVER['HTTP_USER_AGENT'],$agent) === false; return !$notAgent; } ?> <HTML> <HEAD> <!-- I'm using inline CSS here - for convenience --> <style type="text/css"> /* universal for both MSIE and Firefox */ body { background-color:#AAFFAA; background: #AAFFAA url(foo) fixed; } <?PHP if(inAgent("MSIE")) { // MSIE CSS follows ?> * html div#fixme { /* this div ID sticks to the top of the browser window */ position: absolute; top:expression(eval(document.compatMode && document.compatMode=='CSS1Compat') ? documentElement.scrollTop : document.body.scrollTop); background-color:#AAFFAA; width:110%; height:160px; overflow:auto; margin:0; padding:5px; left:0; right:0; } * html div#fixme2 {/* this div ID also sticks to the top of the browser window */ position: absolute; top:expression(eval(document.compatMode && document.compatMode=='CSS1Compat') ? documentElement.scrollTop : document.body.scrollTop); z-index:100; right:0 } * html div#fixme-bottom {/* this div ID sticks to the bottom of the browser window */ position: absolute; top:expression(eval(document.compatMode &&document.compatMode=='CSS1Compat') ?documentElement.scrollTop+(documentElement.clientHeight-this.clientHeight) : document.body.scrollTop+(document.body.clientHeight-this.clientHeight)); left:0; background-color:#AAFFAA; width:100%; height:30px; overflow:auto } <?PHP } else { // now the same CSS definitions for Firefox... ?> html div#fixme { position:fixed; top:0; background-color:#AAFFAA; /*width:100%;*/ height:160px; overflow:auto; margin:0; padding:5px; left:0; right:0; } html div#fixme2 { position:fixed; z-index:100; top:0; right:0 } html div#fixme-bottom { position:fixed; bottom:0; left:0; background-color:#AAFFAA; width:100%; height:30px; overflow:auto } <?PHP } ?> </style> </HEAD> <BODY> <DIV id=fixme2> <!-- a simple persistent logout button --> <FORM method=POST> <INPUT type=submit name='logout' value='Kilépés X'> </FORM> </DIV> <div id=fixme> <!-- instructions for the exam comes here --> </div> <div style='z-index:-1;position:absolute;top:160px;left:0;background-color:#EEFFEE;width:100%;padding:5px;'> <!-- the exam questions, positioned to fit under the instructions --> </div> <div id=fixme-bottom> <!-- simple post button goes here and stays on the bottom of the screen --> </div> </BODY>
Also see:
<< Newer entries | Older entries >>