Working around WordPress’ wpdb limitations with MySQL User Variables

Posted by: gdelmatto  :  Category: PHP, Programming

Think about retrieving a data set from MySQL, where you need to add distinct, auto-incremented ID to each row retrieved. Sounds easy?

Well, the ID has to be generated on-the-fly and out of nowhere. Still easy?

One might think about using MySQL user variables to accomplish this, sure. But what if your framework does not allow injecting chained queries because of SQL injection countermeasures?
Read more…

Run command in background from PHP

Posted by: gdelmatto  :  Category: PHP, Programming

While working on my newest project, a PHP- and AJAX-based network management application, I came along the need to run multiple commands on the server and track their return states (basically if they were run successful or not).

While sticking together my framework, I found that forking a process into background from PHP requires some additional steps if you don’t want to break AJAX functionality.
Read more…

Convert a Perl Hash of Hashes into XML with XML::Dumper

Posted by: gdelmatto  :  Category: Perl, Programming

For a project of mine, I wanted to convert a Perl data structure, a so called Hash of Hashes, into an XML.

The simple solution to this is to use the XML::Dumper module.
Read more…

VpnInit AppleScript: Override and Restore Default VPN-Routes on OS X

Posted by: gdelmatto  :  Category: Networking, OS X, Operating Systems, Programming, Scripting, Utilities

Years ago I wrote a small script to restore local default route after connecting the RAS VPN on Windows.

Now, I made up a similar script to do the same on OS X.
Read more…

Automating MakeMKV with AppleScript

Posted by: admin  :  Category: OS X, Operating Systems, Programming, Scripting

It’s only days since I wrote about a custom script action upon inserting a DVD in OS X, allowing me have either run the DVD Player or MakeMKV to rip the DVDs.

Now I was digging around if I could do some automation on the GUI part, which indeed turned out to work … at least to a certain degree.
Read more…

Interface-Statistiken in Cacti für Swisscom CentroGrande erstellen

Posted by: gdelmatto  :  Category: HowTo's, Networking, Programming

Als Follow-Up zu meinem letzten Post über den Swisscom CentroGrande Router, widme ich mich nun erneut diesem Gerät. Heute geht es darum, Interface-Statistiken in Cacti zu erzeugen — und das obwohl der CentroGrande den hierfür nötigen SNMP-Support schmerzlich vermissen lässt.

Read more…

Make OS X run custom actions upon DVD insert

Posted by: gdelmatto  :  Category: OS X, Operating Systems, Programming, Scripting

I’m currently ripping my complete DVD collection off to MKV (Matroska) format, so I can stream them across my home network.

So I sought a way to have my OS X give me the choice to either start DVD Player or MakeMKV upon inserting a DVD.
Read more…

Shutting Speakers on OS X when Screen Saver runs

Posted by: gdelmatto  :  Category: OS X, Scripting

Why for God’s sake would anyone even think about shutting speakers while the screen saver runs?
Don’t these thingies provide an internal mute switch to stay quiet?

Well, yes, most of the time, they do. Though in my case, I run that nice and decent System47 LCARS-style screen saver. And while it provides indeed a mute switch, it yet refuses to honor that flag and will always revert to non-muted operations. This drives me crazy, at least during the night time.

So here’s my solution to shut it quiet — really handy when I’m not along and forgot to turn volume down …
Read more…

Sleep Timeout on TCL (and Cisco too…)

Posted by: gdelmatto  :  Category: Cisco, TCL

Being used to other languages sometime leads to false assumptions, like having the same commands every now and then.
While doing some TCL scripting on a Cisco I just had the need for a ‘sleep’ command or equivalent.

Since no ‘sleep’ exists, the ‘after’ command will do. Just supply it with the timeout in milliseconds, like this for a 10-second timeout:

after 10000

Or, with a bit more overhead, but some may think it’s more readable:

after [expr {int(10 * 1000)}]

Extract and Unify Cisco Device-Types with SNMP and Perl

Posted by: gdelmatto  :  Category: Cisco, Networking, Perl, Programming

Here’s a short script which I use to extract Cisco device-types from SNMP.
Bad enough, most of these devices return their device type ID differently, e.g. sometimes prefixed with an uppercase ‘C’, sometimes without any prefix, then again sometimes we find a suffix.

So here’s a snippet, that makes them look neat, so I can work with simple and unified looking device IDs.
Read more…