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: www.autohotkey.com/docs/commands/WinSet….

An here is the AHK script. Once the script is added and reloaded, it is triggered with Alt+Shift+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:

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.

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

Echoing this var should display “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.

Patch the source & recompile as usual:

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:

And done!
Thanks to Lubos & Henrik lists.xymon.com/pipermail/xymon/2011-Aug…

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 – www.xymonton.org/monitors:asterisk-iax2
SIP – www.xymonton.org/monitors:asterisk-sip
Mail Graphs – www.bakarasse.de/pages/en/xymon-monitori…
Windows Update/Reboot Test – www.xymonton.org/monitors:winupd
APC UPS Monitoring & Temperature – developer.sysco.ch/hobbit/
HP Proliant HW RAID Monitoring – code.google.com/p/hphwraid/

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 127.0.0.1 “drop HOSTNAME ftp”

For BigBrother use the command

~/server/bin/bb 127.0.0.1 “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 127.0.0.1 “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 127.0.0.1 “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:

So now the entire <VirtualHost> block looks like:

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

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

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. PHP.net recommends avoiding nesting Tenary operators as it can become confusing FAST!

Basic True/False Declaration:

Conditional welcome message:

Conditional items message:

Conditional reporting level:

Conditional basepath:

Nested PHP shorthand:

Leap Year Check:

Conditional PHP redirect:

Examples shamelessly ripped from David Walsh’s blog: davidwalsh.name/javascript-shorthand-if-…

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.

www.jformer.com/

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.

roundcube.net

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 (natesbox.com/blog/?p=378)

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:

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:

View the mail queue with email IDs:

Force delivery of specific email by ID:

Force a queue run:

Force a queue run and attempt to flush frozen emails:

View log of email by ID:

View body of email by ID:

View header of email by ID:

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

Fail a message from the queue (with bounce) by 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:

Then you should run:

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:

SMTP connection counter:

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

Flush the exim queue (empty it!):

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:


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