Wednesday, April 18, 2012

Афоризмы успешных людей

Не бойтесь того, что ваше мнение кому-то покажется странным, ибо каждое мнение кем-либо обязательно будет принято как очень странное.
Бертран Рассел (1872 - 1970) - английский математик, философ и общественный деятель

Не будь чрезмерно робок и разборчив относительно своих поступков. Жизнь это эксперимент.
Ральф Уолдо Эмерсон (англ. Ralph Waldo Emerson, 1803 - 1882) - один из виднейших мыслителей и писателей США

Tuesday, April 17, 2012

Microsoft TechDays 2012 in Moldova Chisinau


Microsoft заинтересована в молдавских IT специалистах

В апреле 2012 года компания Microsoft провела в Кишиневе 2 конференции.
Sergiu Cibotaru  который является  Microsoft Technology adviser in Moldova (https://www.facebook.com/sergiu.cibotaru) неоднократно заявлял что Microsoft хочет чтобы в Молдове были MVP (most valuable person).  Эта награда присваивается участнику, активно проявившему себя в течение года в развитии определенной технологии. Награда требует ежегодного подтверждения.
Ранее у нас уже был MVP, но к сожалению он не подтвердил статус.
Чтож, будем ждать.

11 April 2012 - Private Cloud & Microsoft System Center 2012

Presenter: Damien Caro, Microsoft, https://www.facebook.com/damien.caro

Resources

* http://sdrv.ms/Ijr2Lu
* http://www.microsoftvirtualacademy.com/tracks/configuring-and-deploying-microsoft-s-private-cloud

12 April 2012 - Microsoft TechDays 2012

Presenters: (Karl Davies-Barrett, Microsoft, https://www.facebook.com/ikarld

Resources:

* http://sdrv.ms/HBVDp8

Agenda


Monday, April 16, 2012

Url checker with powershell


<#
.SYNOPSIS
Takes a list of urls and verifies that the url is valid.
.DESCRIPTION
The Check-Url script takes a piped list of url and attempts download the HEAD of the file from the web. If it retrieves an HTTP status of OK then the URL is reported as valid. If the result is anything else or an exception, then the url is reported as invalid.
.INPUTS
List of url's to check. Note: the url's must begin with http:// or https://
.OUTPUTS
Returns a powershell object with properties
 1. IsValid [bool] - signifies weather the url was determined as Valid or not
 2. Url [string] - the url that was checked.
 3. HttpStatus - The http status resulting from the web request.
 4. Error - Any possible error resulting from the request.
.EXAMPLE
@('http://www.google.com', 'http://www.asd----fDSAWQSDF-GZz.com') | .\Check-Url.ps1
.EXAMPLE
@('http://www.google.com', 'http://www.asd----fDSAWQSDF-GZz.com') | .\Check-Url.ps1 | where { !$_.IsValid }
Reports the Invalid url's.
#>
 BEGIN {
}
PROCESS {
  ## You have to at least make sure it's got a value
  ## Really you should check it's TYPE to make sure you can do something useful...
  if($_) {

 $url = $_;
 $urlIsValid = $false
 try
 {
  $request = [System.Net.WebRequest]::Create($url)
  $request.Method = 'HEAD'
        $request.AllowAutoRedirect=$false
        $request.Timeout = 5000
        $request.AuthenticationLevel = "None"
  $response = $request.GetResponse()
  $httpStatus = $response.StatusCode
  $urlIsValid = ($httpStatus -eq 'OK')
  $tryError = $null
  $response.Close()
 }
 catch [System.Exception] {
  $httpStatus = $null
  $tryError = $_.Exception
  $urlIsValid = $false;
 }
 $x = new-object Object | `
   add-member -membertype NoteProperty -name IsValid -Value $urlIsvalid -PassThru | `
   add-member -membertype NoteProperty -name Url -Value $_ -PassThru | `
   add-member -membertype NoteProperty -name HttpStatus -Value $httpStatus -PassThru | `
   add-member -membertype NoteProperty -name Error -Value $tryError -PassThru
 $x
  }
}
END {
}
<#
 References...

 http://stackoverflow.com/questions/924679/c-how-can-i-check-if-a-url-exists-is-valid
 http://huddledmasses.org/using-script-functions-in-the-powershell-pipeline/
#>
 

How to run from powershell console
gc .\urls.txt |  .\urlcheck3.ps1

Sunday, April 15, 2012

How to iterate through a files and directories in bat files FOR ... IN... DO

The command line contains a powerful and versatile method for carrying out this type of operation. With this method, you can automate many time-consuming tasks. The basic statement is of the form:
for {each item} in {a collection of items} do {command}
A single-letter replaceable variable is used to represent each item as the command steps through the the collection (called a "set"). Note that, unlike most of Windows, variables are case-dependent. Thus "a" and "A" are two different variables. The variable has no significance outside the "For" statement. I will be using X throughout the discussion but any letter will do. (In principle, certain non-alphanumeric characters can also be used but that seems like a bad idea to me.) The variable letter is preceded with a single percent sign when using the command line directly or double percent signs in a batch file. Thus the statement in a batch file looks like this:
for %%X in (set) do (command)
What makes the "For" statement so powerful is the variety of objects that can be put in the set of things that the command iterates through, the availability of wildcards, and the capability for parsing files and command output. A number of switches or modifiers are available to help define the type of items in the set. Table I lists the switches. They are listed in upper case for clarity but are not case-sensitive.
Table I. Modifying switches used with FOR
Switch Function
/D Indicates that the set contains directories.
/R Causes the command to be executed recursively through the sub-directories of an indicated parent directory
/L Loops through a command using starting, stepping, and ending parameters indicated in the set.
/F Parses files or command output in a variety of ways

I will consider a number of examples that illustrate the use of "For" and its switches.

Simple iteration through a list

The set of things that are to used can be listed explicitly. For example, the set could be a list of files:
 for %%X in (file1 file2 file3) do command
(Care must be taken to use correct paths when doing file operations.) A different example where the set items are strings is:
For %%X in (eenie meenie miney moe) do (echo %%X)

Wildcards can be also be used to denote a file set. For example:
for %%X in (*.jpg) do command

This will carry out the command on all files in the working directory with extension "jpg". This process can be carried further by using several members in the set. For example to carry out a command on more than one file type use:
 for %%X in (*.jpg *.gif *.png *.bmp) do command
As always, keep in mind that the command line may choke on file names with spaces unless the name is enclosed correctly in quotes. Therefore, you might want to use "%%X" in the "command" section.

Looping through a series of values

The well known action of stepping through a series of values in connection with "if" and "Goto" statements is succinctly done with the switch /l (This switch is an "ell", not a "one") . The statement has the form:
 for /l %%X in (start, step, end) do command

The set consists of integers defining the initial value of X, the amount to increment (or decrement) X in each step, and the final value for X when the process will stop. To list all the numbers from 1 to 99 we can use a "For" statement with one line:
for /l %%X in (1,1,99) do (echo %%X >> E:\numbers.txt)

The numbers in the set mean that the initial value of X is 1, X is then increased by 1 in each iteration, and the final value of X is 99.

Working with directories

If you wish to use directories in the variable set, use the switch /d. The form of the command is
for /d %%X in (directorySet) do command

An example that would list all the directories (but not sub-directories) on the C: drive is
for /d %%X in (C:\*) do echo %%X

Recursing through sub-directories

If you want a command to apply to the sub-directories as well as a parent directory, use the switch /r. Then the command has the form:
for /r [parent directory] %%X in (set) do command

Note that you can designate the top directory in the tree that you want to work with. This gets around the often cumbersome problem of taking into account which is the working directory for the command shell. For example the statement:
for /r C:\pictures %%X in (*.jpg) do (echo %%X >> E:\listjpg.txt)
will list all the jpg files in the directory C:\pictures and its sub-directories. Of course, a "dir" command can do the same thing but this example illustrates this particular command.

Parsing text files, strings, and command output

Now we come to a truly powerful switch that was not even dreamed of back in the DOS days of yore. The switch /f takes us into advanced territory so I can only indicate the many aspects of its application. Things become rather complex so those who are interested should consult programming books or the Microsoft documentation. However, here is a brief sketch of what's involved.
This version of the "For" command allows you to examine and parse text from files, strings, and command output. It has the form
 for /f [options] %%X in (source) do command

"Options" are the text matching criteria and "source" is where the text is to be found. One of the interesting applications is to analyze the output of a command or commands and to take further action based on what the initial output was.

Friday, April 13, 2012

Google charts from HTML table

gvChart plugin – jQuery with Google Charts


gvChart is a plugin for jQuery, that uses Google Charts to create interactive visualization by using data from the HTML table tag. It is easy in use and additionally it allows you to create five types of the charts.