Wednesday, July 31, 2013

WinMerge

WinMerge is the best graphical diff program that I've found for Windows. 
 
For those unfamiliar with diff:  this is handy for any time you need to compare two files or two folders to see in detail what is different between the two.

http://winmerge.org/

templify

If you're working on Windows, I recommend checking out templify:

http://opensource.endjin.com/templify/

You can read more about what it is and what it does here:

http://blog.endjin.com/2010/10/introducing-templify/

But the general idea is that it lets you set up a directory structure with subfolders and files that represents a template of similar directories that you are going to set up later.  When creating this template, you can pick one (and only one!) phrase or word that will be replaced when you use the template to create a new project.  The placeholder phrase or word will be replaced in both the file/folder names and in the contents of any files in the template.

This is a really easy to use utility and it is extremely handy.  Especially for web work.

Tuesday, July 30, 2013

posh-git

If you use git in windows at all and are a command-line junkie, I highly recommend that you check out posh-git:

https://github.com/dahlbyk/posh-git

Very good stuff.  It adds a bit to your prompt noting what branch you are on and what your current commit/push status is. (Outstanding adds, changes, removals.)

Here's a simple session (Click it to make it big):


An N-Gram Parser in F#

This is a very basic n-gram parser in F#. It takes an IEnumerable containing the word tokens that you want N-Grams for, a number indicating the n-gram order, and a delimiter for the output. It returns an IEnumerable with each string containing a single n-gram with the words separated by the delimiter provided in the third parameter. For example:
NGramParsing.GetNGrams(new [] { "This", "is", "a", "test" }, 2, "|");
Would yield:
{ "This|is", "is|a", "a|test" }

Tuesday, March 12, 2013

Powershell Working with Running Processes

Line/Word Counting Files with Powershell



Line Counting a file
(gc ./myfile.txt | measure -line).Count

Word Counting a file
(gc ./myfile.txt | measure -word).Count

Character Counting a file
(gc ./myfile.txt | measure -char).Count

White Character Count for a file
(gc ./myfile.txt | % { [char[]]$_ | ? { $_ -match ‘[\s]’ } } | measure).Count

Black Character Count for a file
(gc ./myfile.txt | % { [char[]]$_ | ? { $_ -match ‘[\S]’ } } | measure).Count

Line counting many files (recurse from curdir) and getting the Sum
                (ls -recurse *.hl7 | % { (gc $_ | measure –line).Lines } | measure –sum).Sum

Line counting many files (recurse from curdir) and getting the Average
                (ls -recurse *.hl7 | % { (gc $_ | measure –line).Lines } | measure –average).Average

Count all lines containing “error” or “Error” in all log files from curdir down and getting the Sum
                (ls -recurse *.log | % { (gc $_ | ? {$_ -match ‘[Ee]rror’ } | measure –line).Lines } | measure –average).Sum

Restarting a service on a remote machine

If you have Windows Servers that you need to do any admin on, you should already have set them up with powershell and enable remoting.

If you need to restart a service from your own box, do not be a monkey and RDP into the machine and go to control panel, etc.

Open powershell on your own machine and type this:

icm SERVERNAME { net stop 'Service Name'; net start 'Service Name'; }

If you find yourself doing this a lot, open up your profile script at "~/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1"  (If it doesn't exist, make it) and define this as a function that you can easily remember:

function restart-jira() { icm SERVERNAME {  net stop 'Atlassian JIRA'; net start 'Atlassian JIRA'; }

Restart your shell (or reload profile script) and from now on you can just type e.g. "restart-jira" and it will restart the remote service.