Recently I found the need to create an init.d script and since I had a hard time finding an example elsewhere1, here’s the overly simple script I came up with to get the job done: #!/bin/bash # myapp daemon # chkconfig: 345 20 80 # description: myapp daemon # processname: […]

Simple init.d script template

One of the strengths of CSS and jQuery is that it provides a common and powerful mechanism known as a selector language for referencing bits of data, especially data whose structure is not exactly known at runtime which makes such an addressing scheme a perfect fit for the often lumpy […]

Fun with jsonselect

When writing reports I’ve often come across the need to find the unix timestamp beginning and end of a day. Here is a Python snippet that does just that. yesterday = datetime.datetime.now() - datetime.timedelta(days = 1) yesterday_beginning = datetime.datetime(yesterday.year, yesterday.month, yesterday.day,0,0,0,0) yesterday_beginning_time = int(time.mktime(yesterday_beginning.timetuple())) yesterday_end = datetime.datetime(yesterday.year, yesterday.month, yesterday.day,23,59,59,999) yesterday_end_time […]

Finding yesterday’s beginning and ending unix timestamp

Here is a simple script I’ve found to be quite helpful for monitoring the status of background index builds across shards on a system: var currentOps = db.currentOp(); if(!currentOps.inprog || currentOps.inprog.length < 1) { print("No operations in progress"); } else { for(o in currentOps.inprog) { var op = currentOps.inprog[o]; if(op.msg […]

MongoDB script to check the status of background index builds

Here is a simple function to check an array to see if it contains all null values. function allNulls($arr) { if(is_array($arr) && count(array_diff($arr, array(null))) == 0) { return true; } return false; } echo (allNulls(array(null,null,null)) ? "true" : "false") . PHP_EOL; echo (allNulls(array(null,1,null)) ? "true" : "false") . PHP_EOL; echo […]

Check an array for all null values