Pages

10/18/2014

Windows Server 2008R2 Disk Cleanup Utility

Disk Cleanup, like in Win7 is available by installing the Desktop Experience feature.
You can run it without installing Desktop Experience feature by doing the following:

Copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.1.7600.16385_none_c9392808773cd7da\cleanmgr.exe C:\Windows\System32\
copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.1.7600.16385_en-us_b9cb6194b257cc63\cleanmgr.exe.mui C:\Windows\System32\en-US\
cleanmgr.exe /verylowdisk
You can put the above in a BAT file and it will copy the files and run without user intervention. Or just copy the files and run it to select options. run using cleanmgr.exe /? to see interesting switches for saving your selected options.

Calculating the past growth rate

I want to be able to determine the annual growth rate of data in a directory structure. I know it was created at a certain date and only "new" data was written there -- nothing was migrated from another directory structure.


Mathematically
the total $lastyear would be  $now  / (1 + $growthrate)
so the total  $pastyear $num years ago would be  $now  / (1 + $growthrate)^$num  .
but I am not sure if that would work all the way back to the first year when the total was 0 (if I use 1 GB to approximate zero, especially if the number of years is short, for example 2-3)


Solving for $growthrate:


    $pastyear = $now / ((1 + $growthrate)^$num)


    $pastyear * ((1 + $growthrate)^$num) = $now


    ((1 + $growthrate)^$num) = $now / $pastyear


    1 + $growthrate = ($now / $pastyear)^(1/$num)


    $growthrate = (($now / $pastyear)^(1/$num)) - 1


looking at the above if the $pastyear is very small to approximate zero and $num is pretty small this looks like it will be much bigger than is reasonable.


Subtly
For this specific purpose I could attempt to take a file listing of all the files in the directory structure.  Using Excel for instance:
- import the file listing above, use text to columns to split into fields, hide or delete all but date & file size
- create a 3rd column in between with formula calculating just the year of the date
- sort them by year newest to oldest
- group by year & subtotal the file size
this will tell me how much was there the first year
**when I ignore "growth" during the first year and use the amount at the end of the first year in the above formula it seems to be much more reasonable.

10/09/2014

Don't pad number strings, use modular arithmetic to calculate each digit

Example in Python:
// = integer division
% = remainder

# given t in tenths of seconds, 
# return a string of format string A:BC.D
# A = minutes, BC = seconds, with leading zero if needed, D = tenths of seconds
def format(t):
    tenths = t % 10
    t = t // 10
    sec = t % 60
    min = t // 60
    sec_ones = sec % 10
    sec_tens = sec // 10
    display = str(min) + ":" + str(sec_tens) + str(sec_ones) + "." + str(tenths)
    return display