Counting weekdays between dates

Need a method to accurately count the number of weekdays between two days? [The key here is "accurately", it is a bit harder than it seems at first]. In Python there are several ways to do this, but most involve some iteration or list comprehension. In my opinion, if you have to do that, you are probably violating the Python idiom of "use the batteries".

If a record exists

A common action when synchronizing data between some source and a database is to check if such-and-such record already exists and needs to be updated or if a new record needs to be created. The SQLAlchemy's one() method [of the query object] provides an easy way to check to see if such-and-such record exists; but it doesn't return either an ORM object or None - if no record is found it raises an exception. This is surprising at first as x=do;if-not-x is possibly the most common of all Python constructs.

Recovery From Half An MD Mirrored Pair

In the process of decommissioning an old physical server I wanted to recover some data from the server's drives. The failing server was configured with a SATA RAID1 pair that contained a logical volume group (LVM). So I could either boot up the old server, change it's IP address, and recover the data over the network.... or I could just recover the data directly from one of the drives [they are a mirrored pair after all]. But only having a USB caddy for one SATA drive the trick was to get the RAID1 array to come up on my laptop with only one drive.

A JSONDateTime TypeDecorator

JSON doesn't provide a date or date-time construct; therefore every application is burdened with implementing a solution of it's own for receiving date-time information over the wire. On common issue receiving JSON and serializing that data into some type of database - but the database knows the value is a date-time and you want to be able to perform date-time like operations on the value (locally).

Discovering DLL Version With pefile

A Microsoft KB article claimed that if a specific DLL was at least a certain version that a bug reported by one of my users would be resolved. But the user was using their computer and I dislike interrupting people's work (I know how annoying it is when someone interrupts me). No problem; I can just grab the named DLL off their machine over the network and copy it to my home directory. But I'm not running Windows and all file tells me is that the DLL is a 32-bit PE file.

Identifying The Hottest Tables (Informix)

Yesterday I posted about how to identify the hottest table in a PostgreSQL database. Pretty much the same functionality is available for administrators of Informix databases as well; this kind of information is found in the sysmaster database which is the database engine's own database.

Identifying The Hottest Tables (PostgreSQL)

In recent versions of PostgreSQL there is a magical view called pg_stat_user_tables which provides per table information on usage; there is one row per table and eight counters per row.

Fields

Tags: 

Converting M4B's to MP3

I ended up with some M4B audio files; these are "MPEG v4 system, iTunes AAC-LC" files. In order to reliably manage these files along with every other audio file [all of which are MP3] the simplest solution is just to convert them to MP3. In order to accomplish that I dumped them back out to WAV using mplayer and re-encoded them to MP3 using lame.

Where and what is /var/run/named?

    # service named start
    Starting name server BIND checkproc: Can not stat /var/run/named/named.pid: Too many levels of symbolic links
    - Warning: /var/run/named/named.pid exists! start_daemon: Can not stat /var/run/named/named.pid: Too many levels of symbolic links                                                          done

Changing Your FreeNode Password

There is no shortage of documentation for common IRC operations like registering your nick and managing channels. But I had quite the time figuring out the syntax for changing my password; turns out it's obvious:

    /ns set password new_password

There is no password confirmation - so make sure you type it correctly.

On a related note, for anyone new to IRC, it is possible to bind multiple nicks to your FreeNode account. Just switch to the nick you want to bind and then issue the "group" command.

Pages

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer