AutoHotkey — Toggling window transparency

Posted by & filed under Code Snippets, Software.

Everyone loves eyecandy! I was missing my transparent console windows, and found a nice way to have them again in Windows 7. It’s as simple as installing AutoHotkey and adding the below script. Let me explain…

Autohotkey has a method called WinSet that allows the manipulation of various GUI related settings. One of them being… you guessed it… transparency. Linki:….

An here is the AHK script. Once the script is added and reloaded, it is triggered with Alt+Shift+T.

WinGetActiveTitle, T
if n=0
WinSet, Transparent, 222, %T%
WinSet, Transparent, Off, %T%

Yii Components

Posted by & filed under PHP, Programming.

Yii components can be quite handy, exposing functions to the entire app. This helps keep the controller thin and adheres to the DRY methodology.

To create a “Hello World” component, first we create the component in protected/components, and populate it with:

class Hello extends CApplicationComponent
    public function init() 
        // Any needed initialization for the component goes here

    public function World() 
        return "Hello World!";

Now that we have our component, the next step is to modify our protected/config/main.php, including our new component in the components array:




In the same file, we can set our component to be preloaded. Meaning it won’t be lazy loaded on first access, but rather preloaded on the app’s init.

	// preloading components

Lastly, we can access the output from our component by using something like:


Echoing this var should display “Hello World”

//Prints "Hello World"
echo Yii::app()->Hello->World();

Xymon 4.3.4 info column bug

Posted by & filed under Server Admin.

I recently deployed a fresh installation of Xymon 4.3.4. There were a few glitches which were easily solved by looking at the xymon logs. With one exception — the info column shows a “Internal Server Error”. Thanks to the Xymon mailing list, I found that there is a known bug in svcstatus.cgi in Xymon 4.3.4. The solution is to edit the source and recompile, or just apply the handy patch below.

Index: web/svcstatus-info.c
--- web/svcstatus-info.c        (revision 6723)
+++ web/svcstatus-info.c        (revision 6724)
@@ -568,7 +568,7 @@
        /* Years */
        addtobuffer(buf, "<SELECT NAME=\"year\" onClick=\"setcheck(this.form.go,true)\">\n");
        for (i=beginyear; (i <= endyear); i++) {
-               char istr[3];
+               char istr[5];

                sprintf(istr, "%d", i);

Patch the source & recompile as usual:

cd xymon-4.3.4
patch -p0 < /tmp/infocolumn-crash.diff
make clean

At this point if I was doing a fresh install, I could simply do a make install, but since I already have Xymon installed and working perfectly, I opted to simply copy over the newly patched svcstatus.cgi:

cd web
sudo cp svcstatus.cgi /usr/lib/xymon/server/bin

And done!
Thanks to Lubos & Henrik

Xymon Addons that caught my eye

Posted by & filed under Server Admin, Uncategorized.

I was browsing Xymonton and found a few addons that I may be able to make use of.

IAX2 –
Mail Graphs –…
Windows Update/Reboot Test –
APC UPS Monitoring & Temperature –
HP Proliant HW RAID Monitoring –

Xymon – drop a test or host

Posted by & filed under Server Admin.

Straight from the manpage:

Deleting a test:

For Xymon use the command:

/server/bin/xymon “drop HOSTNAME ftp”

For BigBrother use the command

~/server/bin/bb “drop HOSTNAME ftp”

to permanenly remove all traces of a test. Note that you need the quotes around the “drop HOSTNAME ftp”.


For Xymon: Deleting a host

First, remove the host from the /etc/xymon/hosts.conf file. Then use the command

server/bin/xymon “drop HOSTNAME”

to permanently remove all traces of a host. Note that you need the quotes around the “drop HOSTNAME”.


For Big Brother: Deleting a host

First, remove the host from the ~/server/etc/bb-hosts file. Then use the command

~/server/bin/bb “drop HOSTNAME”

to permanently remove all traces of a host. Note that you need the quotes around the “drop HOSTNAME”.


Updated 03/24/14 w/ Xymon specific syntax.

.htaccess and Windows — oh noes!

Posted by & filed under Server Admin.

Windows sucks. But sometimes I have to deal with an even bigger abomination — Linux software on a Windows boxen! Today I had to get a .htaccess file working, and since unix paths can get a bit tricky on windows, I figured I’d jot down the steps:

In the htaccess.conf we need to do the following:

  1. Enable mod_rewrite in the LoadModule section
  2. Set “AllowOverride All”

I was using vhosts in this instance, so I needed to add the following to the appropriate <VirtualHost> section:

	    AllowOverride All
	    Options None
	    Order deny,allow

So now the entire <VirtualHost> block looks like:

    DocumentRoot "D:/htdocs/some.server"
    ErrorLog logs/
    CustomLog logs/ common

	    AllowOverride All
	    Options None
	    Order deny,allow


Lastly, my .htaccess file is pretty much setup like normal:

AuthUserFile "d:/secure/.htpasswd"
AuthType Basic
AuthName "Restricted Area -- All access is logged and monitored." 

require valid-user

The .htpasswd file can be generated using htpasswd — Apache packages the htpasswd in the bin directory. It will likely be somewhere like: C:\Program Files\Apache Software Foundation\Apache2.2\bin

htaccess -c -b .htpasswd username password

Toss the resulting file int he path defined by AuthUserFile in the .htaccess file and you are done!

Finished up another Supra…

Posted by & filed under Automotive, Toyota.

Pretty cool… the 2JZGTE Twin Turbos has been replaced with a larger ball bearing Single Turbo. A MapECU2 ECU has been installed to tune the vehicle along with the usual BPU upgrades…

Matt's Single Turbo Toyota Supra

PHP Tenary Operator Examples

Posted by & filed under Uncategorized.

Tenary operators, also knows as shorthand If/Else Statements make for short conditional code blocks that is easy to read. recommends avoiding nesting Tenary operators as it can become confusing FAST!

Basic True/False Declaration:

$is_admin = ($user['permissions'] == 'admin' ? true : false);

Conditional welcome message:

echo 'Welcome '.($user['is_logged_in'] ? $user['first_name'] : 'Guest').'!';

Conditional items message:

echo 'Your cart contains '.$num_items.' item'.($num_items != 1 ? 's' : '').'.';

Conditional reporting level:

error_reporting($WEBSITE_IS_LIVE ? 0 : E_STRICT);

Conditional basepath:

echo '';

Nested PHP shorthand:

echo 'Your score is:  '.($score > 10 ? ($age > 10 ? 'Average' : 'Exceptional') : ($age > 10 ? 'Horrible' : 'Average') );

Leap Year Check:

$is_leap_year = ((($year % 4) == 0) && ((($year % 100) != 0) || (($year %400) == 0)));

Conditional PHP redirect:

header('Location: '.($valid_login ? '/members/index.php' : 'login.php?errors=1')); exit();

Examples shamelessly ripped from David Walsh’s blog:…

PHP Forms Framework – jFormer

Posted by & filed under Programming.

jFormer is a form framework written on top of jQuery that allows you to quickly generate beautiful, standards compliant forms. Leveraging the latest techniques in web design, jFormer helps you create web forms that:

  • Validate client-side
  • Validate server-side
  • Process without changing pages (using AJAX)

I recently used it to retrofit a old site I developed with some slick forms. This worked well and I’m happy! Definitely a nice way to collect and validate data.

RoundCube — GPL Mail Server

Posted by & filed under Uncategorized.

This project is a free and open source webmail solution with a desktop-like user interface which is easy to install/configure and that runs on a standard LAMPP server. The skins use the latest web standards such as XHTML and CSS 2. Roundcube includes other sophisticated open-source libraries such as PEAR, an IMAP library derived from IlohaMail the TinyMCE rich text editor, Googiespell library for spell checking or the WasHTML sanitizer by Frederic Motte.

Xymon script testing/debugging

Posted by & filed under Server Admin.

This is a follow-up to a older post I made about Hobbit/Xymon and testing alerting (

I have needed to write a few Xymon scripts and in order to test them outside of Xymon, but with the Xymon environment variables which most scripts depend on. In order to do this we use the xymoncmd command like so:


This works for a client script, but I wanted the server env vars, so I added one additional option:

./xymoncmd --env=/usr/lib/xymon/server/etc/xymonserver.cfg ../ext/

Also one note on older compatibility: As of the (slightly outdated) version I am currently running, xymoncmd is just a alias of bbcmd, So this should apply to older hobbit stuff too.

Exim Useful Commands

Posted by & filed under Uncategorized.

I. Useful Commands (do not include brackets!)

See the mail queue count:


exim -bpc

View the mail queue with email IDs:


exim -bp

Force delivery of specific email by ID:


exim -M [email id]

Force a queue run:


exim -qf

Force a queue run and attempt to flush frozen emails:


exim -qff

View log of email by ID:


exim -Mvl [email ID]

View body of email by ID:


exim -Mvb [email ID]

View header of email by ID:


exim -Mvh [email ID]

Remove message without error code (no bounce) by ID:


exim -Mrm [email ID]

Fail a message from the queue (with bounce) by ID:


exim -Mg [email ID]

II. Configuring A Better “log_selector” In Exim Configuration For Extended Logging!

By default Exim on cPanel does not come with a very extensive logging setup enabled (log_selector) in it’s /etc/exim.conf. Generally without reconfiguring this line you will not be able to easily figure out most of the issues going on with your mail. It’s very hard to find a spammer or source of a particular email from your server. The reason for this default is probably because cPanel developers figure most people won’t need to parse logs as their target administrators are relatively “green” to Linux and the default also keeps log sizes very small. I recommend editing /etc/exim.conf and replacing the existing “log_selector” line (or adding it if none exists) with:


log_selector = +address_rewrite +all_parents +arguments +connection_reject +delay_delivery +delivery_size +dnslist_defer +incoming_interface +incoming_port +lost_incoming_connection +queue_run +received_sender +received_recipients +retry_defer +sender_on_delivery +size_reject +skip_delivery +smtp_confirmation +smtp_connection +smtp_protocol_error +smtp_syntax_error +subject +tls_cipher +tls_peerdn

Then you should run:


service exim restart

This will restart exim and you should see much more detailed logs in /var/log/exim_mainlog!

III. Exim Tips & Tricks.

Many of these tips and tricks should be used with the extended logging setup discussed in section II.

Show exim queue stats by domain:


exim -bp | exiqsumm | grep -v ‘\-\-’ | grep -v ‘Volume’ | grep -v ‘^$’ | sort -bg | awk ‘{print “Volume: ” $1 ” \t Domain: ” $5}’

SMTP connection counter:


grep ‘SMTP connection’ /var/log/exim_mainlog | grep ‘TCP/IP’ | awk ‘{print $7}’ | cut -d [ -f 2 | cut -d ] -f 1 | sort -bg | uniq -c | sort -bg

Find spammers sending mail from their /home/ directory (through a script):


grep ‘cwd=/home’ /var/log/exim_mainlog | awk ‘{print $3}’ | cut -d / -f 3 | sort -bg | uniq -c | sort -bg

Flush the exim queue (empty it!):


for i in `exiqgrep -i`; do exim -Mrm $i; done

IV. RBL and Whitelist Filtering bypass.

To bypass RBL filtering for a specific domain you can add that domain to /etc/rblbypass. You can add a remote IP address of a host that is being rejected by a RBL to /etc/whitelist to bypass RBL filtering for a specific incoming IP.

V. Open Extra SMTP Port via cPanel.

You may find that a customer’s ISP blocks port 25 to prevent outbound spam from their network. In this case you could open a second port for him or her to use to get around the ISP.

  1. In your WHM go to Service Configuration -> Service Manager.
  2. Scroll to the bottom where you will see: Exim on another port.
  3. Check both boxes (Enable and Monitor) and fill in the box for port 26 (or your other port of choice!)
  4. Save the configuration and you should be set!

You can test it out with telnet or an email client that sends through SMTP.

VI. Where to go from here.

Aside from this guide I also recommend studying the Exim documentation and learning everything you can about how email works and to make sure you are fully understanding how to read email headers. It’s simple to read headers, but from my work as a systems administrator I know a lot of admins (even good ones) fail to do so properly or are unsure of their conclusions!

WordPress Posting Code

Posted by & filed under Uncategorized.

To post code use:


Where brushtype is one of the following:

actionscript3 as3
bash shell
coldfusion cf
cpp c
c# c-sharp csharp
delphi pascal
diff patch pas
erl erlang
jfx javafx
js jscript javascript
perl pl
text plain
py python
ruby rails ror rb
sass scss
vb vbnet
xml xhtml xslt html