Author Archive for garth

Hooking into Widget Delete Action in WordPress

The title of this post is technically a lie, since there is no widget delete action (that I’m aware of anyway).  However if you want to hook into the action that occurs when a widget is deleted you can use the following code in your functions.php :

add_action( 'sidebar_admin_setup', 'my_sidebar_admin_setup' );

function my_sidebar_admin_setup() {

     if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) ) {

          $widget_id = $_POST['widget-id'];

          if ( isset( $_POST['delete_widget'] ) ) {
               if ( 1 === (int) $_POST['delete_widget'] ) {
                    // Widget deleted; do something
               }
          }

     }

}

The ‘sidebar_admin_setup’  action gets triggered, seemingly, anytime a change occurs on the Widget screen.  Dragging a widget, saving a widget, deleting a widget – all of these trigger this action.  It’s a pretty handy hook to know.

Commuting

I was having a conversation about commuting time earlier tonight, and I just decided to do the math.

Let’s assume an 8 hour work day.

For every 12 minutes you save on your commute in each direction (24 minutes per day), you get the equivalent of a day off each month.

Did you catch that?  12 mins off your commute equals 12 extra vacation days per year!

Admittedly, it’s not chunked together like vacation days would be, but there is a tangible value to the extra time before and/or after work.  Extra time to spend with your family, your friends… hell, yourself!  It’s a ton of free time.

Commuting sucks.  Don’t trade your life for a commute.

Math (for those that care):

8 hours = 8 * 60 minutes = 480 minutes

Assuming 20 work days in a month, one day off, in minutes per day, equals 480 divided by 20.

480 / 20 = 24

Which, when divided by two, equals 12 minutes per direction.

Hacked!

So it seems that this site was hacked. .htaccess hack of some sort. Big pain in the ass. This also means that things will be broken for awhile. I’ve recreated the site and imported the content, but I don’t trust any of the old php files, so I’m going to have to go through and add plugins, theme, etc. So in the meantime, enjoy TwentyEleven :)

Diablo 3 Keep Alive and Error 3007 Fix

A lot of people are getting disconnected from Diablo 3 with Error 3007.  One of the fixes listed on the forums seems to be sending a message to Global Chat every few seconds / minutes.  So, since a buddy of mine was experiencing exactly this issue, I wrote a script which will do this automatically for him.  The first time he used it he ran for 1.5 hours with no disconnects.  He turned off the script and was dropped at the 3 minute mark.  Logged back in and was dropped after 5 minutes.  Ran the script again and had no more drops.  So, anecdotally, it works.  However your mileage may vary.

Click here for the BitBucket repo and instructions.

Click here to download d3chat.exe.

Leave a comment here if you have any questions / comments / concerns.  Or feel free to buy me a beer if this script finally lets you play D3 :)

Google is the new Smurf

Google-LogoTonight a buddy of mine was helping me put together a Frankenrig from spare parts I accumulated over the weekend. I’d looked something up and he came over to look at pictures of it and said to me “Turn up the google”, and I immediately knew he meant “brightness”.