VMGuru.com - Home of the Virtualization Gurus

Our Books REALLY are Available Now!

Don’t become overwhelmed by your VMware Infrastructure project. Use the books that tens of thousands of others have used to design, plan, and implement their virtual infrastructures.Download Now!

Articles
Fun with PowerShell - Calculate Permutations PDF Print
Written by Scott Herold   
Saturday, 13 June 2009 22:17

I got sidetracked on Twitter tonight with a conversation between @jasonboche and @vmdoug, and since my wife is out of town visiting family I figured what better way to spend a Saturday night than to write a quick PowerShell script that can calculate the number of unique permutations based on 2 criteria.

First is the total number of available elements.  in this case, we were looking at the number of available URL combinations on bit.ly before they would "run out".  Without spending any more than 15 seconds investigating, I determined that bit.ly uses only alphanumeric keys, but is case sensitive.  That means we have 26 uppercase letters, 26 lowercase letters, and 10 integers (0-9).  That gives us 62 total elements.

The second criteria is the number of total elements used in the combination.  In this case, bit.ly still uses 5 character URL strings.

The math behind this is something that I actually still remembered from high school oh so many years ago and is P = n!/(n-r)! where P is the number of Permutations, n is the total number of available elements, and r is the number of elements used in the combination.

Borrowing a function from stackoverflow.com (The nested loop calculation was pissing me off so I had to cheat), I was able to put together the following PowerShell script that can rather quickly do basic permutation calculations.

function factorial( [int] $f ) 

$result = 1
if ( $f -gt 1){
$result = $f * ( factorial ( $f - 1 ) )  
}
$result
}
 
function permutation( [int] $n, [int] $r )
{
(factorial $n) / (factorial ($n - $r) )
}
[int] $n = Read-Host "Total number of available elements:"
[int] $r = Read-Host "Total number of elements in combination:"
 
if ($n -ge 1 -and ($n - $r) -ge 0) {
permutation $n $r
}
else{
Write-Host "Invalid input parameters"

 

So, when all is said and done, by using this script we can determine that when using 62 total elements in 5 element combinations, bit.ly currently has 776,520,240 URL combinations available.  if they were to change to a 6 character URL, the number jumps to 44,261,653,680, in addition to the 776,520,240 combinations from their 5 character URLs.  I think its safe to say that as long as the bit.ly database can handle the load, we don't need to worry about them running out of URLs any time soon.

 
Chapters 7 and 8 and Permutational Math PDF Print
Written by Scott Herold   
Saturday, 13 June 2009 21:29

I want to give a special thank you to Jason Boche for getting me all wrapped up in permutation calculations around the number of possible bit.ly permutations before they will need to add a 6th character to their strings (776,520,240 for those interested).  He through out a tweet mentioning my math skills and to check out my free chapters.  At that point I quickly got that sinking feeling in my stomach which quickly reminded me "Holy crap I'm behind".  Without further ado, I give you a two-for and introduce Chapters 7 and 8 from books 1 and 2.

 

 
More Chapters Coming Soon PDF Print
Written by Scott Herold   
Monday, 25 May 2009 02:36
So, I'm sitting here in the Quest Denmark office in Copenhagen, and suddenly remembered "Oh yeah, I'm supposed to be releasing free chapters".  Unfortunately, I only have Acrobat installed on my desktop computer at home and do not have it installed on my laptop.  After I complete my current tour of Europe on the 30th of May I will make sure I post the next few sets of chapters that I have fallen behind on.  Since I can't PDF the individual chapters, I guess there is nothing to do but have some Carlsberg (Yes, I can see their corporate offices from my office window) and enjoy my first visit to Copenhagen.
 
Resolving Improper Memory Limits on your Virtual Machines PDF Print
Written by Scott Herold   
Monday, 11 May 2009 12:14

Last week I posted an article that talked about what happens on an ESX Server when a virtual machine has a memory limit set lower than the amount of memory assigned to that virtual machine.  Sound confusing?  If so, head over and read the original blog post.

The short version is that the situation is simply not good, and has major performance implications across the ESX Host, and potentially across the whole infrastructure.  Today, I want to show how you can simply identify and resolve this significant VMware Infrastructure issue using some simple PowerShell commands.

 
IT Knowledge Exchange Blogger of the Week PDF Print
Written by Scott Herold   
Monday, 27 April 2009 14:35

I'm way behind on just about everything due to some travel last week, but while I was gone, I was actually honored with the IT Knowledge Exchange "Featured IT Blogger of the Week" award.  I'm still waiting for my trophy and pile of cash to show up, but in the meantime at least I have some bragging rights!

Thank you IT Knowledge Exchange!

 
<< Start < Prev 1 2 3 4 5 6 7 8 9 10 Next > End >>

Page 1 of 12

Syndication

feed-image RSS Feed

Buy on Amazon