Recreate original PHP array from print_r output [duplicate]

function print_r_reverse($in) { $lines = explode(“\n”, trim($in)); if (trim($lines[0]) != ‘Array’) { // bottomed out to something that isn’t an array return $in; } else { // this is an array, lets parse it if (preg_match(“/(\s{5,})\(/”, $lines[1], $match)) { // this is a tested array/recursive call to this function // take a set of spaces … Read more

weird delay of the output of an object when followed by start-sleep (or until script end)

tl;dr If a command’s output results in automatic tabular display (implicit Format-Table), display output can situationally be delayed for up to 300 ms. (see below for why and when), which can have two unexpected effects: As in the question, a subsequent Start-Sleep submitted before the delay has elapsed further delays output for (at least) the … Read more

How to display progress of scipy.optimize function?

As mg007 suggested, some of the scipy.optimize routines allow for a callback function (unfortunately leastsq does not permit this at the moment). Below is an example using the “fmin_bfgs” routine where I use a callback function to display the current value of the arguments and the value of the objective function at each iteration. import … Read more

How to clear previously echoed items in PHP

<?php ob_start(); echo ‘a’; print ‘b’; // some statement that removes all printed/echoed items ob_end_clean(); echo ‘c’; // the final output is equal to ‘c’, not ‘abc’ ?> Output buffering functions The output buffering functions are also useful in hackery to coerce functions that only print to return strings, ie. <?php ob_start(); var_dump($myVar); $data = … Read more

Powershell Join-Path showing 2 dirs in result instead of 1 – accidental script/function output

As T-Me correctly inferred before you posted the CreateDatedFolder source, the problem is that the function inadvertently outputs 2 objects, and Join-Path accepts an array of parent paths to each join with the child path. Specifically, it is the New-Item call that accidentally creates an additional output object, just before your return $datedDir call. New-Item … Read more