Latest Entries »

Apt-Get has come to Windows. Just as the Greek gods were renamed when they were adopted by the Romans, Linux’s apt-get on Windows is known as “Chocolatey”.

If you are a developer, you can think of Chocolatey as Nuget for your machine. If you are unfamiliar with nuget or apt-get, Chocolatey is simply an independent repository of software installation scripts, allowing you to install apps such as Firefox, Visual Studio, or Resharper on your machine with a single command line. Even better, you can create your own powershell scripts that can install a multitude of apps in unattended bliss.

For example, if you wanted to setup a new development workstation, a script like the one shown below would eliminate a lot of boring desktop admin work, installing all your favorite development tools automatically. It even installs Chocolatey for you. Checkout chocolatey.org for the full list of apps available and their command lines.

NOTE: the command “cinstm” means “install if it isn’t already installed”

NOTE: don’t forget to set your script execution policy to Unrestricted before you run this powershell script
(from a command line run in Admin mode)

Set-ExecutionPolicy Unrestricted

Here is the powershell script, which you can save as “SetupDevEnviron.ps1″:

# This script was based off these samples: https://github.com/chocolatey/chocolatey/wiki/DevelopmentEnvironmentSetup

function Install-NeededFor {
param(
   [string] $packageName = ''
  ,[bool] $defaultAnswer = $true
)
  if ($packageName -eq '') {return $false}
  
  $yes = '6'
  $no = '7'
  $msgBoxTimeout='-1'
  $defaultAnswerDisplay = 'Yes'
  $buttonType = 0x4;
  if (!$defaultAnswer) { $defaultAnswerDisplay = 'No'; $buttonType= 0x104;}
  
  $answer = $msgBoxTimeout
  try {
    $timeout = 10
    $question = "Do you need to install $($packageName)? Defaults to `'$defaultAnswerDisplay`' after $timeout seconds"
    $msgBox = New-Object -ComObject WScript.Shell
    $answer = $msgBox.Popup($question, $timeout, "Install $packageName", $buttonType)
  }
  catch {
  }
  
  if ($answer -eq $yes -or ($answer -eq $msgBoxTimeout -and $defaultAnswer -eq $true)) {
    write-host "Installing $packageName"
    return $true
  }
  
  write-host "Not installing $packageName"
  return $false
}

#install chocolatey
if (Install-NeededFor 'chocolatey') {
  $downloadUrl = 'http://chocolatey.org/install.ps1';
  $webclient = new-object net.webclient;
  $webclient.proxy.credentials = [system.net.credentialcache]::DefaultNetworkCredentials;
  $webclient.downloadstring('http://chocolatey.org/install.ps1') | iex;
}

Write-Host 'Installing utilities...'
cinstm Firefox
cinstm GoogleChrome
cinstm 7zip.install
cinstm Console2
cinstm fiddler

Write-Host 'Installing Visual Studio...'
cinstm VisualStudio2012Ultimate

Write-Host 'Installing Visual Studio packages...'
if (Install-NeededFor 'VS2012 Update 2', $false) {
	cinstm Dogtail.VS2012.2
}
cinstm resharper
cinstm NugetPackageManager
cinstm nuget.commandline
cinstm tfs2012powertools
cinstm tfsSidekicks2012

BundleConfig

Bundle virtual-paths should not be duplicated, otherwise the dupe will overwrite the contents of the previous entry. To add more than one file to a bundle, wrap them in the params in the Include method.

For example, in BundleConfig.cs RegisterBundles, this:

bundles.Add(new StyleBundle("~/bundles/css").Include("~/Content/xxx.less"));
bundles.Add(new StyleBundle("~/bundles/css").Include("~/Content/yyy.less"));

Needs to be this:

bundles.Add(new StyleBundle("~/bundles/css").Include(
                    "~/Content/xxx.less",
                    "~/Content/yyy.less"
                ));

Also, the bundle virtual path depth should be the same as the depth of the file you are referring to (4 in the example below). If you don’t do this, relative paths in your less/css will fail.

	bundles.Add(new LessBundle("~/Content/xxx/less/yyy").Include("~/Content/xxx/less/yyy.less"));

I’ve written about micro generators that harvess ambient energy from their environment, now the first ones are coming to market this summer.

Microgen’s new BOLT MicroPower Generator harvests tiny mechanical vibration and turns it into electrical power stored in ultra-capacitors  or thin-film batteries, effectively creating an infinitely charged battery about the size of today’s coin batteries.

Able generate enough power to replace coin batteries, it can be used in a huge variety of devices.  In an automobile’s tire pressure sensor, for example, this device collects the vibrations from the tires meeting the road and offers unending power for the sensor.  Additional applications include machinery monitoring, lighting control, wireless price tags at stores, and smart utility metering — eliminating the 164 million depleted coin-cell batteries in the U.S. and Europe each year that would otherwise need to be recycled.

Like a windmill snags the breeze, ambient vibration causes the tiny micro flap shown here to swing back and forth. This generates electrical current, which is harvested for the rechargeable thin-film battery.

Output voltage is OCV > 10 Volts, and output power Pload >100 uW @ f1 and G > 1.0 g

Amazon has dumped the model of having rich old guys decide what we see and hear on TV and has crowdsourced picking which series to fund.  “To pick just one show would mean that we’re rejecting many other shows,” said Roy Price, Director of Amazon Studios. “We’re doing it this way presumably because we don’t believe in the guru model of television where we should just make decisions using our great wisdom. When you have the internet as a platform for your service, the right way to do this is to give people a sample and see what they like.”

Watch the pilots and vote which ones will be created into original series on Amazon.  Currently there are 6 kids shows and 8 comedies (including Zombieland).  They’re also using “internet chatter” to decide which ones to fund, so be sure to reply with comments here.

Every programmer has heard of the SOLID programming principles (+10pts if you can regurgitate all 5, verbatim, on a job interview in under 60 seconds), but  despite being neatly wrapped up in a marketable acronym that would make Ian Fleming proud, the mnemonic benefits of SOLID are still questionable.  I mean, what part of “Liskov substitution principle” is not clear to you?

Ignoring the marketing gimmick, the implementation of these principles is often a point of contention.  One of the principles in particular is often hotly argued over in forums, blogs, and yes, even job interviews.  I’m talking about the Open-Closed Principle, which states “software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification” (as per Bertrand Meyer via Wikipedia).  I’ve heard a range of answers to how this principle should be practiced in code projects.  I’ve worked with people who insist that under the Open-Closed Principle, the source code itself should never be changed except for bug fixes, basically using class inheritance as a substitution for source control.  The class structure that way of thinking produces a huge mess, as you can probably imagine, with classes named like XYZ, XYZWithABC, XYZWithDEF, XYZWithABCAndDEF, etc. and without multiple inheritance, code duplication was common, almost inevitable really.

Jon Skeet has a refreshingly sober view of the Open-Closed Principle on his blog.  He quotes Craig Larman and Alistair Cockburn regarding a more clearly defined principle, Protected Variation, in which we identify points of predicted variation and create a stable interface which is neither too constrictive for implementations nor too hairy for clients.   This allows many different concrete subclasses, and code which only depends on the parent class doesn’t need to know about the subclasses in order to use them when they are presented as the parent class.  Furthermore, no existing functions can be removed (as they may be relied on by existing clients) and no new pure virtual functions can be added (as they will not be implemented by existing subclasses).

Phil Haack, being a Microsoft veteran, astutely retorted that ”SPLID” just doesn’t have that same marketable ring to it.

© 2013 Robert Corvus