Wednesday, February 27, 2013

Corporations Should Not Drive National Politics - Bring back the Tillman Act

In addition to bringing back section 16 of the Glass-Steagall Act prohibiting investment banks from gambling with tax payer money, we need to bring back the Tillman Act of 1907 forbidding corporations from funding politics.
Teddy Roosevelt in his 1904 address to Congress said,
"All contributions by corporations to any political committee or for any political purpose should be forbidden by law; directors should not be permitted to use stockholders' money for such purposes;"

In 1907 Congress passed the Tillman Act which stated "... it shall be unlawful for any national bank, or any corporation organized by authority of any laws of Congress, to make a money contribution in connection with any election to any political office."
The part of corporations funding politics that bothers me is not the presidential election candidates, but to congressmen writing laws for corporations to follow.  It's too easy for a corporation to tell a congressman they would like her to support a bill, like extending copyright way beyond its usefulness to encouraging people to create works of art.  The congressman gets paid tens of thousands of dollars, and the corporation reaps millions of dollars profit at the expense of the American people.
 If she doesn't support the law, the corporation can threaten to fund her opponent.
That's just too much leverage against the interests of the people.

System.Net.WebException : Cannot handle redirect from HTTP/HTTPS protocols to other dissimilar ones.

Currently I am writing an integration test that enters a scenario into the database, then invokes a url on my web site, and then checks to make sure the database has been updated properly.   While doing this I ran across this error:
System.Net.WebException : Cannot handle redirect from HTTP/HTTPS protocols to other dissimilar ones.
My C# code looked like this:

string webPageText;
 using (WebClient client = new WebClient())
    webPageText = client.DownloadString("");

It took me too long to understand the error message.  The real problem is that my app was issuing a 302 redirect and my C# code doesn't know how to handle that.  It failed the unit test, which is what it should have done.  Once I corrected my input, the redirect to an error page was not raised, and my test passed.

Thursday, February 21, 2013

Upgrading from .Net 3.5 to 4.0

I'm upgrading an old ASP.Net app from .Net 3.5 to 4.0.  Here were some of my issues:
1.  Compile error CS0234: The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?)
This is error is from the build machine using the old 3.5 libraries.  We have to tell it to use the 4.0 libraries in nant.  I added this to my nant build script:
<property name="nant.settings.currentframework" value="net-4.0" />

2. The automatic upgrade did not switch all the versions, I had to manually change the version number for many of my projects from:
<add assembly="System.Core, Version=, Culture=neutral, PublicKeyToken=B77A5C5619000000"/>
<add assembly="System.Core, Version=, Culture=neutral, PublicKeyToken=B77A5C5619000000"/>

3.  Menu Items from Web.sitemap disappered
The orginal code looked like this:
if (SiteMap.CurrentNode != null && SiteMap.CurrentNode.IsDescendantOf(node))
                    Repeater repeater = (Repeater)e.Item.FindControl("repeaterBar");
                    repeater.DataSource = node.ChildNodes;

I added one new condition to see if the current node was the node:
                if ((SiteMap.CurrentNode != null)
                     && (SiteMap.CurrentNode.IsDescendantOf(node) ||
                    SiteMap.CurrentNode == node))
                    Repeater repeater = (Repeater)e.Item.FindControl("repeaterBar");
                    repeater.DataSource = node.ChildNodes;
Then it worked like it did in 3.5.

4.  A form submission gave this error:  "A potentially dangerous Request.Form value was detected from the client"
This was fixed by adding  "<httpRuntime requestValidationMode="2.0" />" to the web.config under "<System.Web>"

Overall the upgrade was not too bad.

Tuesday, February 05, 2013

The Coming Collapse of Gold

Photo by Bjørn Christian Tørrissen
 Gold has been a store of value since the dawn of civilization, but that's about to change.  Gold prices are going to plummet in the future - permanently.  I can't give you  a date, but I can tell you how it will happen.

In all of human history we have managed to pan, blast, and pry about 176,000 metric tonnes of gold from mother earth.  While the oceans are estimated contain about 20 million tons of dissolved gold.  The gold is very low in concentration, about one milligram in a ton of sea water.

Although many people have tried to extract the gold from the sea, none have done so successfully.  The most famous was German chemist Fritz Haber who tried to pan the oceans for gold to repay Germany's war debt.  Many swindlers have tried to sell the idea, but only succeeded in mining gullible rich people.

Photo by US Mint
 But that will change in the future.  A few methods may be possible to rob Poseidon of his wealth.
1.  Microbes are known to take dissolved gold and produce solid gold.  Pedomicrobium 
is an example as is Delftia acidovorans . These could be genetically altered to increase their yield.

2.  Designing sheets of materials that have an affinity for gold and placing those in ocean currents.  The sheets are anchored to the sea floor and recovered months later after filtering the precious metal.  Japan has used a process like this to test the recovery of Uranium..  Uranium is much more abundant in ocean water, 4.5 billion metric ton, but the concept is the same.
3.  Plants like kelp could be genetically engineered to have an affinity for gold and then be harvested.  Although this solution has many obvious issues.  Otters with gold-capped teeth anyone?
Photo by Bullion Vault

As material science progresses, it is just a matter of time before we can start to pan the oceans for gold.  It may take 10 years, or 50, but eventually someone will crack the code.  When they do, vast new quantities will pour into the world's markets permanently depressing the gold market.

Saturday, February 02, 2013

Pictures from HTML5.tx 2013 in Austin TX Feb 2

I was fortunate enough to attend the sold-out HTML5.tx conference in Austin today.  Here's a few photos I shot and a few of my jumbled, unedited notes.

Embedded JavaScript, HTML5 and the Internet of ThingsJesse Cravens

Ace editor
Node.js communicates with Arduinos with web-sockets
node-serialport Node.js 
BeagleBone by TI, fully functional Linux board $100
Node running on BeagleBone
firmata protocal
multiple arduinos talking to BeagleBone central hub
Raspberry Pi used instead of laptop
Node.js used on small devices as webhosting 
konectic canvas library
ember.js is extremely impressive for single page app

Backbone: 3 Ways
Pamela Fox

push state to pretend to change url
single page web app
used Knockout
requireJS used for dependencies
before interview, look at web page and help them debug problems
no HTML - every element for javascript
directories are used for catagorizing becuase we don't have a tag based file system
django admin
you never want to delete stuff, add Delete column instead
add change log table
as you grow you need to change backend to scale, but not the front end
don't return php code, cause you can't change easily
only update partial 
good frameworks:  ember, spine, angularJS, enyou
start with Backbone tutorals, not the docs

Arduinos, BeagleBones, and Raspberry Pi, Oh My!

The New Rules of The Responsive Web
Matthew Carver
Laptops and desktops for creating, phone and tablets for consuming
Responsive web is more than squishy

Foundation or Bootstrap for prototyping
Style Tiles
css preprocessors,  scss, sass, or less
SMACSS Scalable and Modular Architecture of CSS book
Embrace unpredictability.

Lighting Talks:
The Softer Side of HTML5
Tony Farnsworth, Anne Epstein, William Moner

Foundation or Bootstrap for prototyping
Style Tiles
css preprocessors,  scss, sass, or less
SMACSS Scalable and Modular Architecture of CSS book 
Embrace unpredictability.

parseInt(010) is octal 8
parseInt('010') is 10 in chrome and 8 in Firefox
javascript == is type coersive
=== is really equals
false == 0 // true
false === 0 //false
put comments inside function for debugging instead of on top

Open Spaces group led by Eric Anderson on testing javascript

Austin Hallock
16ms to do something for 60 frame per second
use window.requestAnimationFrame instead of setInterval or setTimeout

Unfolding the Box Model
Chris Ruppel

10 things you didn't know a browser could do
Estelle Well

document.querySelectorAll("#foo .bar")
every element has "classList" with functions .add(), .remove(), 
live node list, static node list
getElementByClassName is live, constantly updated

Rapid Templating: "Designing in the Browser" with Sass, Compass, and Serve
Nathan Smith
Marcotte Responsive Web Design, fluid grids and media queries
compass is an example of using Sass, Compass and Serve
apache .htaccess     Options +multiview finds close file names

One last note:  Every presenter I saw was using a mac.

Friday, February 01, 2013

On Windows 2003, file copy, getting "access denied" under file share

Filed under "things I should have thought at the very beginning": 
On windows 2003 it is not enough to grant permissions to a subdirectory under a file share, you have to remember the grant permissions to the share itself.