Go/Golang variadic function with flags


This is how you would pass variable FlagSet variables and print defaults. #go #GoLang func PrintHelp(cmds ...*flag.FlagSet) { fmt.Println("Available commands :") for _, cmd := range cmds { fmt.Printf("\t%s\n", cmd.Name()) } fmt.Println("====== * * * ======") for _, cmd := range cmds { fmt.Printf("%s\n", cmd.Name()) cmd.PrintDefaults() } } func ProcessArgs() string { var what string…

Android disk size and wear level check


Use this command to get mount names and origins: df o get block information for data use the command: tune2fs -l /dev/block/mmcblk0p56 (example) If any block does not report “clean” then we can use e2fsck to clean them. To do a check with e2fsck without changing the file system: e2fsck -n /dev/block/mmcblk0p56 (example)

fix wordpress comment not showing on post


If you have “magazine-basic” wordpress theme, and with recent updates or for any reason; if comment is not showing up in individual posts, follow this change. Navigate from your hosting panel to file:  …/ wp-content / themes / magazine-basic / functions.php. Edit this file. Around line 351, change case statement as below: function bavotasan_comment( $comment, $args, $depth ) {$GLOBALS[‘comment’] = $comment; switch…

Print thread info Android Java


On Android java code, print stack trace of all the threads owned by current process. try { Map info = Thread.getAllStackTraces(); for (Map.Entry<Thread, StackTraceElement[]> entry : info.entrySet()) { Thread th = entry.getKey(); StackTraceElement[] elms = entry.getValue(); //print("===> Thread: {0} id:{1} prio:{2} st:{3}", // th.getName(), th.getId(), th.getPriority(), th.getState().toString()); for (int idx = 0; idx < elms.length;…

Datacenter tiering


Datacenter tiering Tier 1: – 99.671% uptime – annual 28.8 hrs downtime – full shutdown for preventive maintenance Tier 2: – 99.741% uptime – annual downtime of 22 hrs – some redundancy with single path for power, requiring shutdown for preventive maintenance Tier 3: – 99.982% uptime – annual 1.6 hrs downtime – sufficient redundancy…

Network tiering


Network tiering Tier 4: – most datacenters – owns internal network – pay other networks for IP transit outside the facility Tier 3: – regional providers – build redundancy thru’ redundant POPs (points of presence) outside facility – pay for IP transit past the POPs Tier 2: – national or international footprint – still pay…

double precision rounding


Uses my_double_greater_check from http://rutmandal.info/double-precision-comparison-in-cc/ double my_double_round( double val, int multiplier ) {          double val_adj = val * multiplier;          if ( my_double_greater_check( val_adj floor( val_adj ), 0.0 ) > 0 )                       val = round( val_adj ) / multiplier;…

double precision comparision


Checking double precision value for limits is tricky. Say, double x = 1.0; if ( x == 1.0 ) do_something();   This comparison can fail as double precision value when converted to hexadecimal (what computer can do only) representation, looses some least significant bits or positions beyond double precision digits. So, in above example if (…