Monday, December 14, 2015

Pictures from Austin .Net Meeting December 14, 2015

Justin Self gave a very informative talk to 30 developers at  about css positioning.
Here's a few pics of the evening.

Justin describing CSS
Panorama of the crowd
Justin used the tool "Bracket" by Adobe to give a live preview of changes.

My unordered list of jumbled notes:

border: 10px solid blue; #order doesn't matter
border-bottom:... #only for the bottom
margin property can be negative.
"auto" centers element horizontally only.

line height specifies vertical distance between lines of text in container.
line-height: [number | length | % ]
line-height: 4;
line-height: 30pt;

display:block; # default width is 100%. Always on same line
display:inline; # width is only based on content. You cannot set a width on it. Can do margin-left and right, but not top and bottom.
display:inline-block; # may have width. operates like a magic block inside inline element. display:none; # hides the element and its space. triggers a reflow.
float:left; float:right; #pushes element left or right. Treated as "display: block" except you can set the width.
clear: left #
clear: both #
visibility: hidden; #like display:none, but does not cause a reflow, keeps its place
position: static; # default, puts the element in the flow
position:relative; #moves element, but does not reflow
position: absolute; # positioned from positioned-ancestor with things like "top: 200px"
position: fixed; # takes it out of the flow, positioned in viewport
top, right, bottom left, only works for positioned elements
z-index # determines the depth position of stacked elements, only works for positioned elements, ie, not "position:static".
to center vertically:
position:absolute; top:50%; margin-top:10px;
margin-left: -25px;
left: -25px; # only on positioned elements

Justin did mention that most developers never sit down to learn CSS, we just learn tiny bits as needed.  I feel the same way, so it was great to get a full 2 hour overview of how positioning really works.

NuGet Package Manager Introduction

NuGet is a popular .Net package manager.  .Net was late to the party for package managers (see RubyGems and apt-get), but it's here and been gaining traction the last few years.

 NuGet relieves the developer from searching the web for common libraries and provides a single place to download most libraries.  NuGet also has a common file structure so it helps to standardize the file structure across projects.

Adding a Library

To add a package to a project, right-click on the project and select "Manage NuGet Packages..."
(If you don't see that on the context menu, you may need to download the NuGet extension on older versions of VS).

Set the source to "Online" and search for your package.  Let's install Json.NET.

At this point the Package Manager does the following:
  1. Creates a solution\packages directory and a "repositories.config" file if not already there

  2. Downloads, typically from,  the *.nupkg file into the solution\packages directory and unzips contents including the dlls needed.

  3. Adds a "packages.config" file to project if not already there

  4. Adds references in the project to the libraries in the solution\packages directory

  5. Updates the web.config if needed

Json.Net is now a part of our project.

Removing a Project

The VS GUI for NuGet will also let you uninstall a package.  Removing a package should remove references, package.config entries, but may not remove web.config settings or dependencies.  Always check to make sure all items are removed.

The Package Manger Console

To access the command-line go to Tools/NuGet Package Manager/Project Manager Console

Here are a few common powershell commands for the console
  • PM> Get-Package # gets all packages in solution or project
  • PM> Get-Package -ListAvailable Elmah # all available named Elmah
  • PM> Install-Package elmah # install elmah and all its dependencies
  • PM> Uninstall-Package elmah #uninstalls library, but not necessaily its dependencies
  • PM> Uninstall-Package elmah.corelib # uninstalls dependency
  • PM> Install-Package jquery -Project MyProject3 # install in specific project regardless what dropdown says
  • PM> Install-Package jquery -Version 1.5 # not in GUI
  • PM> Get-Package -Updates # show updates available
  • PM> Update-Package jquery # updates all packages in solution regardless of scope dropdown
  • PM> Update-Package jquery -Version 1.5 -Project MyProject2 #changes version just for a specific project
  • PM> Update-Package -reinstall jquery -Project MyProject2 # re-adds references
More command-line docs at

Version Control

We check in our "packages.config" file in each project to our version control system, Perforce. But sometimes Perforce does not see that a "packages.config" file has changed and we manually add it to Perforce.

We don't checkin any of the packages in our packages directory, and rely on the build system to grab the missing libraries from the NuGet repository. Also the "packages/repository.config" is not checked in, but rebuilt each time.

Friday, December 04, 2015

What3Words, A Great Idea to Share Locations is a wonderful idea to bring rational addressing to the world.
What3Words divides the world into 3 meter by 3 meter grids and assigned each grid square a triplet of words, like "browser.bride.uniforms".  Now, to identify a place in the world you use their three words.  You could use lat/long, which is more specific, but is harder to memorize.

I can see this saving a lot of energy and reducing the carbon footprint of delivering packages in parts of the world where addresses are not easy.  Tokyo is notorious for having complex addressing.  With What3Words, a taxi cab or ups driver would know exactly where to go.

Especially in rural areas or camp sites, What3Words would be helpful. You could tell your late Boy Scouts to come which is easier than go 200 yards down the stream from campsite 12, then 50 yards to the South.

My office is at 206 East 9th, Austin TX. The lat/long is 30.270568/ -97.739911,
but its easier to remember "quirky.together.styled".
Or a few grid squares over we have "provider.indeed.sensual" which could be more memorable.
(Perhaps if What3Words catches on, office rental space with catchy 3 words would command a premium)

What3Words really has a potential if Google and Apple will integrate it into their mapping products.

Tuesday, November 24, 2015

Termites and the Coming Nuclear Holocaust

Once upon a time in the American West lived some pioneers, the Hooper family.  They lived in a comfortable log cabin with a lovely straw roof on the edge of the forest.  Let's listen in as the Hoopers have dinner:

Sallie:  We learned today in school about how termites can destroy a house.
Mr. Hooper:  Yep, that's the reason every Friday night we take our kerosene lanterns and spend a few hours searching through the roof thatch to look for those pesky pests.Brother Jed coming in the door:  I just chopped down the Christmas tree - it's a bute!
Sallie:  It is beautiful Jed! Let's check it for termites now - I'll run get a candle.
Mrs. Hooper:  Jed, just put the tree down next to the bale of hay on the other side of the fireplace - next to the barrel of kerosene.
Jed: Ok, Mom.
Mrs. Hooper: Hey, let's decorate the tree now!  Here's a bunch of small candles.  Let's tie them on the tree and light up this room.
[Later that night]
Sallie:  The tree is so beautiful with all the candles burning bright!  Can we let them burn all night to  keep the termites away?
Mrs. Hooper:  Of course!

The Hoopers are obsessed with termites destroying their home, yet are oblivious to the real threat to their lives.
In the same way the media and politicians today are obsessed with Global Warming Climate Change, but devote little attention to the real existential threat to all life on earth - a nuclear exchange between the US and Russia.

We have had many close calls when due to equipment malfunction or human error, the missiles almost launched - seriously.  Sometimes the launch was prevented by a lone individual who just refused to push the button.

Our leaders need to be obsessing on ways to reduce the likelihood of an accidental launch of missiles that could destroy all human life on earth.

Oh, yeah, the Hoopers?  Thanks to Jed's quick thinking later that night, they all escaped the inferno that was their home with only minor injuries.

And for your viewing pleasure, a related video from the 80s at no charge:

Monday, November 02, 2015

FTP through proxies, Filezilla, AdWare, and WinSCP

While trying to ftp some files through a proxy, I reached for my old friend Filezilla and downloaded a copy to my new windows 7 box.
Afterwards my browsers' home pages and search engines changed - arrrrrgggggghhhhhhh!!!!! - unanticipated adware choking my machine.
After an hour or so of trying to remove the adware - scanning, rebooting, scanning, rebooting - it was almost gone.  That was an expensive "free" program.  Oddly enough it loaded the Adware but not Filezilla.

After a wee bit of research, I downloaded WinSCP  to ftp through a proxy.  WinSCP read my putty settings and automagically loaded ftp sites.  It works like a charm without the AdWare bloat.
Thanks WinSCP!

Saturday, October 24, 2015

9 Amazing Facts About the Osage Orange Tree

The Osage Orange is a beautiful tree with a  fascinating story.

1.  The seeds of the Osage Orange tree are designed to be spread by an extinct North American Megafauna.  No living animal can fully digest the fruit of the Osage Orange.  Scientists think an extinct North American camel or ground sloth digested the fruit 10,000 years ago and spread the seeds.
Once common throughout the Southeast United States, its range had shrunk to just a stretch of land around Texas and neighboring states when Europeans arrived due to the extinction of its primary seed disperser.

2.  The Native Americans highly prized the wood for making bows.  Meriwether Lewis said the Osage Indians, who gave their name to the tree, traveled hundreds of miles to find it.

3.  Its wood is the densest of all the trees, which is not surprising since it must support its numerous 3-5" two pound fruit.

4.  In the age before barbed wire, the trees were planted to create living fences .  The thorny limbs of the trees, planted in a row, would be weaved together to form an implementable wall to keep livestock in and predators out.

5.  Since the wood is amazingly resistance to pests and rotting, it was popular for barbed wire fence posts.

6. Its distinctive yellow-orange colored wood can be used to make a dye.

7.  The wood burns at the highest temperature of all trees.

8.  Although its botanical name is Maclura pomifera, it is also called bois d'arc (French for "wood of the  bow"), or a corruption of that, bowdark or bodark.  Its fruit is also called a horse apple or hedge apple.

9.  The trees are male or female.  Only the female trees produce fruit.

Squirrels eat the seeds, but are not ideal seed dispersers
Bonus Fact:  The Osage Orange tree can live to be 400 years old.

Saturday, October 17, 2015

Every Drone Strike is Another Boston Massacre

File:Boston Massacre.jpg
Paul Revere's slanted depiction of events

On March 5, 1770, Boston colonists attacked British soldiers with snowballs, stones, and sticks.  The overwhelmed soldiers fired into the crowd, killing five.
The Colonial patriots used what they christened the "Boston Massacre" to fan the flames of resentment against the British.

Today, US Drone strikes in the Middle East are fanning the flames of resentment against the United States.  Instead of weakening our enemies by removing leadership, the indiscriminate killings of civilians are making our enemies stronger and more numerous.

Newly released secret documents show that 90% of the deaths from drone attacks in Yemen from 2011 to 2013 were civilians.

To kill Ayman Zawahiri, drones had to kill 128 innocent people, including 13 children.

Every drone strike killing innocent people is another Boston Massacre to that community, rallying the people against the US. We are making enemies faster than we can kill them.

It's time to stop the drone attacks.

Tuesday, October 13, 2015

Photos from Austin .Net Users Group October 12, 2015 - What's New in C# 6.0

Jimmy Bogard addressed 35 people at the Austin .Net Users Group on C# 6.0 and the new C# compiler.  The original C# compiler was written in 2000 in C++.  Roslyn, a completely rewritten compiler coded in C# is currently available.
Roslyn is only usable from VS 2015.

Roslyn being developed in the open at by Microsoft.

It is multi-threaded.

Roslyn makes implementing new language features much easier.
Jimmy showed how C# 6.0 is used in his project AutoMapper.

Here are my unedited random notes on new features in C# 6.0:

0. private setter:
public Type SourceType {get; } //implies setting only in constructor

1. auto-initialize
public string FirstName { get; set; } = "Joe";
public string CreationDate {get;set;} = DateTime.Now;

field or property?  if using variable outside a class use property

2. Expression Body Function Members:
public string FullName { get { return FirstName + " " + LastName; }
replaced with 
public string FullName => FirstName + " " + LastName;
Can be used for methods as well:
public string GetFullName() => FirstName + " " + LastName;

3. Using Static - pulls in all possible methods from class to be used in class
using static System.Console;
 using static system.math;
using System.Linq.Enumerable

4. Null Propagating Operator (The Elvis Operator) ?.
var x = source?.GetType() ?? sourceType;

5. String Interpolation - use instead of string.Format()
return $"Trying to map {SourceType.Name} to {DestinationType.Name}";

6. nameof()
throw new ArgumentNulException(nameof(context));

7. Index Initializer
static Customer() {
Dictionary customers = new {
[0] = new Customer(),
[10] = new Customer()

8. Exception Filter

catch(Exception ex) when System.Threading.Thread.CurrentPrincipal.Indent.Name != "asdf"

9. await/catch/finally