Saturday, October 31, 2015

Netflix

I signed up for a Netflix account today for the first time in many years, not since Netflix was nothing more than that we-will-snail-mail-you-DVDs alternative to Blockbuster video. I have been under the impression that I needed a TV to watch Netflix and that the streaming service somehow jived exclusively with the modern TVs that I don't understand as I don't have a TV... but I don't! It works great on my laptop and costs very, very little to enjoy. I christened the account by watching "Circle" which is a fourth example of cheapo science fiction. Happy Halloween!

 
 

Addendum 10/31/2015: Alright, I want to write a second time. I am already frustrated with the limited selection. It's really not like going to a video store. I remember dropping the old school snail mail service I once had over this very reason.

The charm bar won't show up at the desktop anymore in Windows 8.1???

Well, a restart fixed the problem in my case.

Rally has a REST API.

You may talk into it and do things like communicate that a build number has been incremented. Enjoy.

Friday, October 30, 2015

Make ReSharper green!

Click on all of the yellow ticks at the right edge of a file's display in Visual Studio (at the vertical scrollbar) to address each one. When you visit each one there will be a tooltip icon of some fashion (perhaps a lightbulb) at the opposite side, the left edge. When you click there will be a menu which appears which gives you options for cleaning up the problem and, yes, there is an option to just ignore the problem. The last option will have a wrench icon and read: Inspection "Assignment is not used" or some similar error message and this will expand yet another menu with: Disable once with comment ...as an option. Hopefully you won't just comment out everything. Hopefully this keeps you out of trouble.

I really hate that ReSharper encourages you to use the var keyword, but I seem largely alone in my opinion. I guess this is just modern C#, huh? Nuts.

Make ReSharper wrap lines at 200 characters instead of 120.

RESHARPER > Options... > Code Editing > C# > Formatting Style > Line Breaks and Wrapping

plus equals string concatenation

Strings are immutable in C# and whenever you appear to be modifying one you are in fact just creating a new string and putting it on the heap.

string foo = "foo";
foo += "bar";

 
 

Using a StringBuilder takes away some of the overhead of constantly growing a string by making new objects (strings) and letting old ones be dealt with by garbage collection. This is a talking point that was the fodder for interview questions ten years ago. A bigger thing to worry about in terms of optimization however would be traffic to and from the database. Don't stress the string concatenation. It probably isn't the real source of your woes. Note that strings are immutable in a weird way. They aren't value types, they are reference types that live on the heap... and yet when you "change" one the pointer for the string changes to look to the new string that is placed on the heap. This unintuitive behavior is a must for this one type given how much you use it and some of the things it has to do. It's not realistic to make a string a value type and give it a fixed-sized of memory on the stack, not when a string could contain one letter or could contain the Magna Carta. The footprint would be huge and mostly largely wasted in most scenarios.

Restrain how long an input is at an XSD?

As given in my enum example here, you have to explicitly make a restriction to sanity check the length of a string or an integer in an XSD. I think that would look like so:

<xs:simpleType name="Email">
   <xs:restriction base="xs:string">
      <xs:minLength value="13"/>
      <xs:maxLength value="42"/>
   </xs:restriction>
</xs:simpleType>

 
 

I'm not positive because when this came up today we became hesitant to do the work given the nasty mess we'd have to make of an otherwise terse XSD file. We're shelving the to-do for now.

isCrazy versus hasCraziness

is and has are both good ways to start Boolean variable names in C#, not just is.

Proxies

As a concept, a "proxy" is a layer of obfuscation to mask your browsing history. The only one I have any experience with is Megaproxy which was used at this place I worked eleven years ago by people who hated their jobs and were always searching for jobs online. Those individuals didn't want the router recording monster.com, for example, so they went to Megaproxy to go to monster.com and the router would just see megaproxy.com in the history. Basically, and you can try for yourself, you go to Megaproxy and then it will ask you for a URL and it will reach out that URL and sort of display what is at that other site in its own site. (Some formatting gets lost.) It's like a browser nested in a web site. As you click on links you to do not navigate to other sites but instead what would be at the other locales is scrapped in too. I guess under the hood, Megaproxy is scrapping the other location and doctoring up the HTML to remove stuff it doesn't like and to rewrite hyperlinks appropriately. Of course, if the man is watching you with a keylogger he will still know that your darkest workplace secrets. You've been trolling for vaporwave haven't you? Naughty.

Thursday, October 29, 2015

Mishmash instance and static in C#? What happens?

First of all, this will not compile!

namespace Whatever.Models
{
   public static class Flapdoodle
   {
      public string Bar()
      {
         return "Bar";
      }
   }
}

 
 

Static classes must have to have static methods, but what if we have something like this instead for our Flapdoodle class?

namespace Whatever.Models
{
   public class Flapdoodle
   {
      public static string Foo()
      {
         return "Foo";
      }
      
      public string Bar()
      {
         return "Bar";
      }
   }
}

 
 

Some observations about this are...

  1. Alright, this cannot compile.
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using Whatever.Models;
    namespace Whatever.Tests
    {
       [TestClass]
       public class UnitTest
       {
          [TestMethod]
          public void Test()
          {
             Assert.AreEqual(Flapdoodle.Bar(), "Bar");
          }
       }
    }


     
  2. And, neither can this:
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using Whatever.Models;
    namespace Whatever.Tests
    {
       [TestClass]
       public class UnitTest
       {
          [TestMethod]
          public void Test()
          {
             Flapdoodle bosh = new Flapdoodle();
             Assert.AreEqual(bosh.Foo(), "Foo");
          }
       }
    }

     
  3. This compiles and the test passes too.
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using Whatever.Models;
    namespace Whatever.Tests
    {
       [TestClass]
       public class UnitTest
       {
          [TestMethod]
          public void Test()
          {
             Assert.AreEqual(Flapdoodle.Foo(), "Foo");
             Flapdoodle bosh = new Flapdoodle();
             Assert.AreEqual(bosh.Bar(), "Bar");
          }
       }
    }

     

By the way, you cannot have a static struct but you can put static methods in a struct that is not static. The behavior is the same as what is documented above for a similar situation with an instance class (Flapdoodle) which has a mix of static and instance methods.

When making a new file in Visual Studio 2013 an "XML Schema" file is the type to pick to make an XSD.

This was NOT intuitive for me. Therefore, it merits a blog post. I guess XSD stands for "XML Schema Definition" so maybe I "should have known better" huh?

SmartBear Collaborator‎

...is the name of the SmartBear code review tool. You can "poke" someone in their interface. The poke icon looks like an asterisk with the center missing where the lines are all to touch. I don't know what the "poke" does yet. You may pull in a list of subversion changes to this tool and it will allow an aggregate of the changes to be broken out into code blobs which may be marked up by a reviewer.

Wednesday, October 28, 2015

Get IntelliSense when crafting an XSD in Visual Studio 2013!

Go to "Schemas..." under the "XML" menu for this. You'll see a grid of potential XSDs to use and you will need to have a checkmark in the "Use" column to get the IntelliSense. The "Add..." button should help you find XSDs not in the list, but if you added an XSD to your solution yourself I think it should just be in the list. Anyways, on the other side of this stuff, make an new XML file and type an open angle bracket followed by the name of your XSD element. You should get IntelliSense help going forward.

Compare with base

When committing in TortoiseSVN, when you see a list of files to be committed, before you click "OK", right-click on each file and pick "Compare with base" to see highlights of your changes so that you may catch something obviously awful. This came up in the context of a conversation today in which it was asserted that the farther upstream a problem might be caught the less money it costs a business entity. I've heard this theory before and have seen data points to back it up before. It would cost my employer less for me to catch my own bug than for a code review to catch it which for cost less than the bug being found in production and then dealt with. They chain to production has more than these three steps in this model. I can't recall what all of the steps are in the example I saw. Whatever. Anyways, the cost to the business balloons exponentially the farther the bad is allowed to progress along the chain.

Everything goes into getsetters on the partial classes made with Xsd2Code++ as a string.

The "type" handling is done by way of attributes like so:

[System.Xml.Serialization.XmlElementAttribute(DataType = "integer")]
public string Item_Price_X
{
   get
   {
      return this._item_Price_X;
   }
   set
   {
      this._item_Price_X = value;
   }
}

 
 

The exception to this rule is other types in other elements such as in this enum example will end up as tucked away in the Designer.cs file that's rendered out and will be used in assignments when newing up the "greater" , main type in C# in lieu of just plain Jane strings.

Tuesday, October 27, 2015

The formal way of doing code reviews per IEEE ten years ago...

...required that the code reviewer be able to explain the code reviewed to other out-of-the-loop devs.

PMD, Checkstyle, and FindBugs are audit-as-you-go ReSharperesque tools for the Java space that check code quality.

I think they will squawk if you nest switch/case statements eight levels deep inside of each other and that sort of thing. I'm not sure what PMD stands for. Links:

Corel Paradox

...was a rival to Microsoft Access back in the 1990s. Once Microsoft starting bundling Access as part of Office it could not complete and it died by way of being undercut. You could make corny forms and reports with it just like Access. It was awful. I think it was Borland Paradox for a while too. I don't know who owned it first or last. Corel Draw, an Adobe Illustrator rival, was really the thing Corel got right, but you don't hear about it anymore either. Whatever. Corel Paradox came up in a conversation today so I thought of it anew.

make an enum in an XSD?

I think it goes something like this:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
      xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <xs:element name="Whatever">
      <xs:complexType>
         <xs:sequence>
            <xs:element name="Name" type="xs:string" />
            <xs:element name="Animal" type="WhateverAnimal" />
            <xs:element name="Age" type="xs:integer" />
            <xs:element name="Price" type="xs:decimal" />
         </xs:sequence>
      </xs:complexType>
   </xs:element>
   <xs:simpleType name="WhateverAnimal">
      <xs:restriction base="xs:string">
         <xs:enumeration value="bat" />
         <xs:enumeration value="cat" />
         <xs:enumeration value="rat" />
      </xs:restriction>
   </xs:simpleType>
</xs:schema>

 
 

I got the idea from this.

Sunday, October 25, 2015

Tweetbot disenchantment

Today Tweetbot just stopped working on my iPhone 4S running iOS 8.1.3 (12B466). It failed to connect to Twitter and started telling me that I needed to update to version 4. Supposedly (or so it said) I could go into the app store and go to "Updates" and then to "Purchased" to finally click on Tweetbot 3 to upgrade it, but when I do all that the app store just spins and spins, struggling. Grrr. I could just buy version 4 for five dollars, but who cares? I don't see why I can't just use Twitter's mobile-friendly web site at my iPhone instead of Tweetbot. Tweetbot is no TweetDeck after all. (I miss you TweetDeck.) You know, I work with someone who has a Windows Phone and when I've asked him about dealing with the lack of apps for Windows Phone he has just sort of shrugged as though it were not a problem and responded by saying "I just go to the web" or something similar. I'm starting to know how he feels. Who cares about smartphone apps? Open your eyes Tom.

Saturday, October 24, 2015

CSS tabbing misadventure

I tried to rewrite this such that I didn't have to have styles for specific tabs and that I could instead have a stylesheet applicable to all tabs. The best I could do was:

<!DOCTYPE html>
<html>
   <head>
      <title>Whatever</title>
      <style type="text/css" media="all">
         body {
            background-color: #DDEEEE;
         }
         #innerWrapper {
            height: 37px;
            width: 190px;
            margin: -37px 0 0 10px;
            border-left: 1px solid #000000;
         }
         #innerWrapper section {
            float: left;
            border-right: 1px solid #000000;
            border-top: 1px solid #000000;
            border-bottom: 1px solid #000000;
            height: 30px;
            padding: 5px 5px 0 5px;
            background-color: #F2F2F2;
         }
         #innerWrapper section article {
            display: none;
         }
         input[type=radio] {
            display: none;
         }
         input[type=radio]:checked + section {
            background-color: #FFFFFF !important;
            border-bottom: 1px solid #FFFFFF !important;
         }
         input[type=radio]:checked + section article {
            display: block !important;
            width: 180px;
            position: absolute;
            left: 40px;
            margin-top: 20px;
         }
         label {
            cursor: pointer;
         }
         #outerWrapper {
            margin: 71px 20px 20px 20px;
            border: 1px solid #000000;
            background-color: #FFFFFF;
            height: 80px;
            width: 200px;
         }
      </style>
   </head>
   <body>
      blood stains, ball gowns, trashin' the hotel room...
      <div id="outerWrapper">
         <div id="innerWrapper">
            <input name="tab" id="foo" type="radio" checked />
            <section>
               <label for="foo">foo</label>
               <article>My friends and I, we've cracked the code.</article>
            </section>
            <input name="tab" id="bar" type="radio" />
            <section>
               <label for="bar">bar</label>
               <article>We count our dollars on the train to the party.</article>
            </section>
            <input name="tab" id="baz" type="radio" />
            <section>
               <label for="baz">baz</label>
               <article>And, everyone who knows us knows that we're fine with this.
                     </article>
            </section>
            <input name="tab" id="qux" type="radio" />
            <section>
               <label for="qux">qux</label>
               <article>We didn't come from money.</article>
            </section>
         </div>
      </div>
      ...jet planes, islands, tigers on a gold leash
   </body>
</html>

 
 

There are a couple things that are bad about this. First of all, the absolute positioning unfortunately brings with it an inability for the content to push the bottom of the content box downwards on the page. The content thus can only be as tall as I've set the faked content box to be or it will run beyond it. Honestly, this isn't the end of the world as one could just slap a vertical scrollbar on the content if need be. However, the use of "left" is really, really bad. This isn't going to work well in modern web sites wherein all of the content sits inside of a centered div. One could, I suppose, put all of this stuff inside of an iFrame and then summon it into a centered page but if you are going to the lengths of undertaking such a hack you might as well just call out the tabs by id in CSS, you know? If you don't know how many tabs there will be and thus find yourself struggling to write some CSS for it you could make the CSS bubble up inside of style tag inside of the rendered HTML. That way the styles could be calculated on the server side and bubble up to the markup the same way the number of tabs might. You'd number the ids as tab01, tab02, etc. in this paradigm. Anyways, my flawed mess above looks like so:

 
 

Addendum 10/25/2015: I slept on it and realized that one could approach the "left" problem like so:

left: calc(50% - 13px);

 
 

The fifty definitely needs to be a fifty in the name of centering off the center edge but the thirteen should be replaced with whatever number suits your purposes for positioning. You probably would need an offset. I checked and this worked in three of the four browsers shown above. The outlier was the Safari browser (for PC) which hasn't been updated since 2012.

Xui

As mentioned, I went to this tech talk and learned of this GitHub project, Xui! (You won't be likely able to follow that link. It's private.) Interesting things to say about Xui (pronounced ex you eye) are:

  • The team develops using JetBrains WebStorm as the IDE. Again, all of the work is AngularJS frontend work, only touching the backed through ASP.NET Web API calls for data marshalling (which may be easily mocked/stubbed in testing), so there is not an immediate need for Visual Studio though all of the team members, who have C# backgrounds, found WebStorm easy to pick up and warm up to. A beta of WebStorm 11 is available.
  • The team embraces TypeScript, now on version 1.6, in the name of gleaning insights from compilation errors. The team's build process first runs a task that compiles the TypeScript to JavaScript and then follows up with a task that minimizes the JavaScript. GruntTS is a task that compiles TypeScript to JavaScript. It is recommended that you filter d.ts files out. Source Maps in TypeScript are simple files which may be generated with your JavaScript-from-TypeScript JavaScript which allow you to, when debugging JavaScript, figure out what line of TypeScript is responsible for creating a particular, questionable line of JavaScript. This allows you to debug TypeScript in a roundabout way. Yes, you may also just debug it directly with Visual Studio 2015.
  • This is an AngularJS project! Angular 2.0 will be built on TypeScript. I remember hearing that there was a memory leak in the two-way binding in Angular and that, thus, the Angular team was just going to pull it out of version 2.0, but apparently it will remain. Instead of memory just being kept in $scope, the data will make its way back to the controller when applicable. Also, there is just now a maturing understanding in this space that you don't want to just two-way data bind everything. In a ridiculous example, if you had a form with one thousand form fields, you would want to cherry pick what really needs to be two-way databound. A better alternative to making a form with one thousands field though is to break the content up into a wizard format. That too helps with the two-way databinding data manipulations. (Some of what I offer in these notes comes not directly from the speaker giving the talk but instead from chitchat I had with others in the audience before the talk began.) Directives will not exist in Angular 2.0. The framework moves to a purely component-based model. Angular Materials seems immature. The team needs its own thing to keep reusable components and it has to be downwards compatible to IE9 and not just one browser version less than the current version which seems to be the trend across similar projects. The lack of IE9 support in similar existing tools (AngularUI Bootstrap is an example) puts the Xui team in a situation where they have to roll their own animal, namely Xui itself.
  • Bootstrap is also used for layouts, grids, and responsiveness.
  • Bower, kinda like NuGet in that it pulls dependencies, is used to pull dependencies from GitHub repositories. You may specify what particular versions to pull from the GitHub repositories with Bower so that new stuff doesn't surprise/sabotage you.
  • NodeJS is used mildly in that it runs Grunt scripts. (I learned that WebPack is an alternative JS build tool. Er, I suppose I learned as much for a second time that is.)
  • A lot of core concerns that are used over and over in the team's apps have become components in Xui. Diagnostics, dialogs, UI notifications, and even just a button are examples. You don't want a button looking six different ways across six different forms rights? Each component has basically three parts:
    1. a .html file
    2. a .less file (LESS is compiled to CSS)
    3. a .ts file (the TypeScript is referred to as the "code behind" in their paradigm)
    4. Unit tests are the fourth of the three pieces. They sit in the same folder with the rest of the code side by side with everything else. Protractor is used for end-to-end testing, yes, but in these cases, Jasmine is used for the unit tests. Karma runs the Jamine tests.
    <xui-button...
    ...is an example of how one of the components would be called out to in markup. grunt-ngdocs is a Grunt task that builds the components (and this tool is also used by the Angular team itself to do their documentation). Like AngularUI Bootstrap, this framework handles the "maybe for mobile" possibility by being responsive design-friendly.
  • What are Angular watches? Angular has a loop for dirty checking. This loop is always going on in the back of your AngularJS app. (Always monitor your watches.) The Xui guys rewrote the loop for each component and now they have their own, independent watches.
  • Plunker is a website that allows you to test and run JavaScript. The team has developers play with their components here before putting them into applications and grunt-ngdocs pushes to Plunker.
  • grunt-html-to-js is going to crawl all the .html files and put routes to them in a .js file. This is a template cache.
  • Jenkins is used for build facilitation. Source files are uploaded to it and it builds to a GitHub repository.

Abstract away the object prep work.

It occurs to me that a good use for the factory pattern might be to serve for building out go-to wrappers around the instantiation of objects of third party libraries a developing team does not control itself, and especially so if these objects need to be prepped a little bit after instantiation. Example: I make a Foo and then set the Bar getsetter on it in a second line of code immediately after. Maybe you don't want something like that sprinkled all over your code. Maybe it should be driven from one place.

Friday, October 23, 2015

FTE stands for full-time employee.

I know this is a rather pedantic blog post. I'm crossing the ts and dotting the is, right?

Thursday, October 22, 2015

Mojis are short video clips one may use in lieu of Emoticons in Skype.

In that box you type in, click at the smiley at the upper right. This unlocks a tabbed menu full of distractions. The Mojis are in there somewheres.

You have to bind on every callback at a DevExpress ASPxGridView or else certain operations won't work.

An operation that adds a column with a link like this should happen on Page_Load not Page_Init.

Turn on file versioning to keep a history of file changes in SharePoint.

  1. go to your "Shared Documents"
  2. pick "Document Library Settings" from "Settings"
  3. click the link for "Versioning settings"
  4. tweak

How to emulate a DataItemTemplate effect when adding a column to a DevExpress ASPxGridView at the C# side.

Per this you may add a hyperlink at a column, sort of like this one (but without the conditional logic for this example), like so:

protected void AddLinkColumn(string name, string caption)
{
   var column = new GridViewDataTextColumn
   {
      FieldName = dbName,
      Caption = caption
   };
   column.DataItemTemplate = new HyperlinkTemplate();
   MyGrid.Columns.Add(column);
}

 
 

We need an implementation of ITemplate like so:

using System.Web.UI;
using DevExpress.Web;
namespace Whatever
{
   public class HyperlinkTemplate : ITemplate
   {
      public void InstantiateIn(Control container)
      {
         ASPxHyperLink link = new ASPxHyperLink();
         GridViewDataItemTemplateContainer gridContainer =
               (GridViewDataItemTemplateContainer)container;
         link.NavigateUrl = Utilities.GetBaseLinkUrl() + gridContainer.KeyValue;
         link.Text = gridContainer.Text;
         container.Controls.Add(link);
      }
   }
}

 
 

.KeyValue is going to use the unique key for the recordset for the grid as defined by...

MyGrid.KeyFieldName = "WhateverId";

 
 

...while .Text is the value that would typically display for the cell at hand for the column.

at least I haven't gone here before now

https://friendorfollow.com/ is a service I've often heard about but never used for determining who unfollowed you and other insights that Twitter doesn't reveal about itself out of the box. I'm trying to chill out on all of the silly things I say over social media so I am sort of proud that I've never sunk to this low now that I'm thinking of it.

Exception from HRESULT: 0x862EC67C

I was seeing this whenever I saved a file in Visual Studio 2015. To make the problem go away I restarted the VM running Windows Server 2012 R2 where Visual Studio lived.

Be mindful of the Law of Demeter when using Eval in a DevExpress ASPxGridView.

What if you bind a list of Foo to a DevExpress ASPxGridView and each Foo has another object, a Bar, at a getsetter also called Bar? Also, what if you reach out to a property on Bar (the Bar object instance) like so?

<%# Eval("Bar.BarId")%>

 
 

Alright, if you want your girlfriend to give you aspirin you should ask her to go into her purse for them. You should not go into her purse yourself to get the aspirin. That's respectful, right? Sidestepping logical boundaries is asking for trouble, no? We should not just ask Foo for Bar's Id because what if Bar is null. I have just fought with a hard-to-troubleshoot error in which an ASPxGridView loaded just fine, but upon column filtering produced this error message which could not be pinpointed in the debugger:

Callback request failed due to an internal server error.

 
 

You fix this, you will need to make a getsetter on Foo to call instead of calling out to Bar.BarId. It can hold mechanics to compensate for Bar maybe being null.

break on all exceptions in Visual Studio 2015

  1. go to "Exception Settings" under "Windows" under "Debug"
  2. check all the checkboxes
  3. debug!

Wednesday, October 21, 2015

transclude

SolarWinds is moving away from the ASP.NET web forms driven web interfaces it has built up over the past ten years to a modernized AngularJS-overtop-of-ASP.NET-MVC-Web-API-calls-to-a-backend UI. This new, decoupled UI may sit on top of a mocked API making it easy to test and I saw a Mr. Rob Stovenour speak on it tonight at SolarWinds' facility. It is all encapsulated in a currently private yet soon to be public GitHub project called Xui and I'll soon offer the notes I took up here at this blog. In the meantime, here is a teaser: A concept I learned of tonight is transclude, and it is an AngularJS space concept. In this concept one may put a component inside of HTML tags and the outside tags wrapping the element may be included, sucked into the component as part of its boundaries. I don't know how it works yet. I imagine that if a component sits within a section tag within an article tag within a body tag that there is some means to look up two levels and pull the article tag in, for example. Do I have this right?

Tuesday, October 20, 2015

__proto__

First, let's consider...

var foo = {
   bar: "foo"
}
 
var baz = {
   bar: "baz"
}
 
var qux = Object.create(foo);
 
alert(foo.isPrototypeOf(qux));
alert(baz.isPrototypeOf(qux));
alert(qux.bar);

 
 

this & OBJECT PROTOTYPES, a book on JavaScript by Kyle Simpson, reveals that the means of fudging inheritance above is both easily chain-of-parent-to-child-reverse-engineering-interrogation-friendly and, yes, legitimate as the above will return three alerts reading (for me in Google Chrome):

  1. true
  2. false
  3. foo

 
 

And then, moreover, consider...

var foo = {
   bar: "foo"
}
 
var baz = {
   bar: "baz"
}
 
var qux = Object.create(foo);
 
alert(Object.getPrototypeOf(qux) === foo);
alert(Object.getPrototypeOf(qux) === baz);
alert(qux.bar);

 
 

Alright, both the blob of code above and the blog of code below return the same three alerts. (The only things that vary across all three blobs of code is the first two alerts.) What is below shows off how the wacky __proto__ setting behaves. Kyle cautions that this is not really standardized before ES6 however.

var foo = {
   bar: "foo"
}
 
var baz = {
   bar: "baz"
}
 
var qux = Object.create(foo);
 
alert(qux.__proto__ === foo);
alert(qux.__proto__ === baz);
alert(qux.bar);

 
 

Addendum 10/23/2015: The double underscore is unoffically referred to as a "dunder" in the JavaScript community per Mr. Simpson!

integration token

It's a trinket. You pass it amongst team members. The person holding the trinket may integrate code and check in (in the model with this convention) while others need to chill out and wait for their turn to hold the trinket.

Add conditional logic to an Eval in a DataItemTemplate in a DevExpress ASPxGridView.

Herein, we may or may not show a hyperlink:

<dx:GridViewDataColumn FieldName="Name" Caption="Name">
   <DataItemTemplate>
      <%# Eval("Id").ToString().Equals("0") ? Eval("Name") : "<a href='" +
            Utilities.GetBaseLinkUrl() + Eval("Id") + "'>" + Eval("Name") + "</a>" %>
   </DataItemTemplate>
</dx:GridViewDataColumn>

 
 

This had the how-to.

Monday, October 19, 2015

Variables in Sass stylesheets are defined with dollar signs.

$zombie-skin:#BEDEAD;

 
 

...may be used in a style like so:

.zombie {
   color: #FF0000;
   background-color: $zombie-skin;
}

 
 

In the app I am immediately looking at there is a stylesheet with all of the common styles that is imported into the other stylesheets to allow them to use the reusable variables.

You can't have two constructors with the same signature in two different partial classes for the same class in C#.

They can't both run and do two different things.

You can't grab Request.QueryString variables from the constructor of a web form's code behind.

You will need to use an event like Page_Load or Page_Init.

OnPreInit is a page lifecycle event that happens even before Page_Init in web forms.

protected override void OnPreInit(EventArgs e)
{

...shows off its shape. Is is great for a middleman base page for all of your other pages in that this provides an event the base page may undertake before Page_Init on any one page inheriting from it. Don't expect Response.Redirect to work here. :(

you can right-click on a hyperlink in Google Chrome and pick "Open link in new tab"

...or even "Open link in new window"

Sunday, October 18, 2015

Favor

I have, for some time, seen people roaming Austin in blue Tshirts with a tuxedo pattern on them (as if the wearer is faking wearing a tuxedo) and I had sort of assumed it was some new trend I just didn't get. Just a moment ago I was in line at a Freebirds and a woman behind me was in one of the shirts and I asked about it. She said that she was a delivery person for an app called Favor. You can get this app at the app store for an iPhone and I have it now. I haven't used it yet but supposedly you may use it to have "anything but alcohol" (her words) delivered to you. I know it is significant and has a big footprint based solely on how many of those Tshirts I've seen around town. This woman I ran into said that the app started here in Austin.

I saw James Chambers speak on MVC6 at MeasureUP.

This new version will be lightweight (think OWIN) with things being filled out by components which are brought in. In the vNext way of doing things Visual Studio is to become a metamanager for Visual Studio packages. The new MVC, now on its seventh beta, will include both MVC and the Web API but web forms and VB.NET will not be invited into this framework. Maybe one day SignalR and the "web pages" thingy of WebMatrix will be included but as of right now there hasn't been enough cry out for either to merit their inclusion. There will be no more bin and obj folders. These concerns will now be kept in memory. One of the biggest changes is that there is now no longer a Web.config file and instead we will have project.json which is kinda like packages.config in modern JS projects. project.json has inside of it, you guessed it, JSON. The example that James showed off had subsections for webroot, userSecretsId, version, dependencies, commands, frameworks, exclude, bundleExclude, and scripts. The version of .NET we are running will be kept in frameworks and dependencies such as Entity Framework are listed under commands. Do "dependencies" fill in the gaps for "commands" perhaps? I'm not sure. Child actions, which are bit like partial views, which take a shape like @Html.Action("SomeActionName", "SomeController") for example, are being replaced in MVC6 with something called view components. @await Component.InvokeAsync("ProfileLinks") is an example of what they will look like. One may, yes, use the await keyword to bring in components asynchronously. @Component.Invoke("Notifications") is another example of new Razor markup for including abstracted-away content. Tag helpers and view helpers are other newish concepts. Expect also improvements in identity including OAuth 2.0 bearer tokens! https://github.com/aspnet and https://docs.asp.net/ and https://live.asp.net/ were offered at the last slide as some helpful links. Expect MVC6 to be out of beta and in your hands around November of this year! w00t!

Saturday, October 17, 2015

MS Ajax in MVC1

You never hear about this anymore. This was the official way to do AJAX in MVC when Microsoft first came out with ASP.NET MVC. I never tried it. The jQuery way really took off and became embraced instead. Whatever.

Friday, October 16, 2015

Now that the credit card on file has stopped working, should our app just give up?

Visa has an API to allow you to get the updated card information for a credit card that is expired or perhaps might be expired if you need to ask.

Set the filtering at a DevExpress ASPxGridView to filter by "Contains" instead of "Begins with" in C#.

As this and this suggest, there is a way to set the default operator for filtering like so:

protected void ReviseColumnFilterOperators(ASPxGridView grid)
{
   foreach (GridViewColumn column in grid.Columns)
   {
      ReviseColumnFilterOperator((dynamic)column);
   }
}
 
private void ReviseColumnFilterOperator(GridViewColumn column)
{
}
 
private void ReviseColumnFilterOperator(GridViewDataColumn column)
{
   column.Settings.AutoFilterCondition = AutoFilterCondition.Contains;
}
 
private void ReviseColumnFilterOperator(GridViewDataTextColumn column)
{
   column.Settings.AutoFilterCondition = AutoFilterCondition.Contains;
}

 
 

For string data, the default operators are:

  1. Begins with
  2. Contains
  3. Doesn't contain
  4. Ends with
  5. Equals
  6. Doesn't equal

 
 

I'm not yet sure how to change these but for the string scenario these seem like pretty good choices. One may toggle to "Begins with" that key icon at the right of a filter box and one may then toggle back to "Contains" easily enough. For numeric data however, the defaults seem to be:

  1. Equals
  2. Doesn't equal
  3. Is less than
  4. Is less than or equal to
  5. Is greater than
  6. Is greater than or equal to

 
 

...and yet, if one picks a different way to filter and then clears the field and leaves it and returns the filtering will fall back to "Contains" as it just takes a little more work to clear a setting in this regard. (well, reset by callbacks perhaps... it all depends how you do this) There are ways to conditionally check to see if a column's data point of a particular type (if you want to exclude the "Contains" logic at the numeric columns) as suggested here here and here, and that may come in handy if you are like me and are not making a different column type for each different type of data point. I didn't know there was such a thing as a GridViewDataDateColumn until I started researching all this.

Thursday, October 15, 2015

immediate children selector in CSS

This is a newish selector not unlike the ~ sibling selector and the + next sibling selector as detailed here, only it uses a greater than sign instead of a tilde or a plus symbol. This has this example:

<div class='a'>
   <div>
      <div>...</div>
   </div>
</div>

 
 

...in which this...

.a > div { ... }

 
 

...would affect the divs immediately inside of the div with the a class slapped upon it but not the divs nested a level deeper inside of those divs. The "cascading" part of "cascading stylesheet" is effectively turned off and neutralized in this trick.

The whole art of right-clicking upon something and picking "Go To Declaration" in Visual Studio 2015 will work with stylesheet styles!

You may just jump into a stylesheet class from a web form for example. This alleviates the headache of trying to hunt down which of many stylesheets is being used.

Wednesday, October 14, 2015

A .webm file is for video.

Embed one like so in HTML?

<div style="width:400px;">
   <video autoplay="" loop="" muted=""
         poster="http://i2.cdn.turner.com/cnn/2015/images/10/14/handshake2.jpg"
         style="border: 0; height: auto; width: 100%;">
      <source src="http://i.cdn.turner.com/cnn/.
            e/interactive/videos/2015/10/14/handshake2.webm" type="video/webm">
      <source src="http://i.cdn.turner.com/cnn/.
            e/interactive/videos/2015/10/14/handshake2.mp4" type="video/mp4">
      <img src="http://i2.cdn.turner.com/cnn/2015/images/10/14/handshake2.jpg"
            data-demand-load="loaded">
   </video>
<div>

Tuesday, October 13, 2015

gSOAP

...looks like a tool to interpret packets from web services where they might otherwise be tricky to handle or not have out of the box support. (in Linux perhaps)

Sunday, October 11, 2015

What one type does every other type subclass?

object is the answer to this classic C# interview question. Note that object may yet be upcast to dynamic and a dynamic object may be upcast to object. Both things don't make the compiler trip.

Duh!

When this is called out as an error line at Web.config...

<compilation debug="true" targetFramework="4.0"/>

 
 

...you are running the wrong version of the .NET framework at the app pool for an ASP.NET web site in IIS.

I saw Peter Siri speak at MeasureUP too.

This talk was all over the place. It had to do with getting developers and operations to get along instead of being in separate teams. It also had to do with trying to drive positive change at your organization and how one might go about doing it. The example of President Kennedy's pitch to the U.S. Congress to ask for billions to fund a manned mission to the moon was demonstrated, but it kinda makes me wonder if mankind has ever really visited the moon. (Forgive me.) Anyways, the thing I liked the best in this talk was the suggestion that, in complete contrast to the JFK approach, when starting to push for change a shaker/rainmaker should get a quick win under his belt upfront to inspire confidence.

I saw Troy Vinson speak on security and vulnerability assessments at MeasureUP.

He went over a bunch of pen testing tools like Metasploit. Anyways, the most interesting thing to me in this talk was the concept of port scanning. If you bombard every possible port at an IP with a packet you will be able to figure out what is open and what is not and that is called port scanning. If port 80 and 443 are open that suggests that there is a web server up and running and if 3389 is open that suggests that remote desktop stuff exists. If you do this fact finding you will come away with a topographical map of what is at a network which will be useful in your sinister malicious nastiness as a hacker. Even more interesting yet, something that really surprised me, is that this sort of let's-see-what's-out-there discovery is illegal in America. I don't see how this is particular different than driving around a bank and taking photos of it and its security guards with a camera (legal), but I do suppose there is only one reason for casing a joint. Obviously, it's not illegal to do a whois lookup on a domain name, but there is at some point a line one may cross in the sand where one is collecting too much publicly available information it seems.

Saturday, October 10, 2015

I saw Allen Hurst speak on velocity/agile at MeasureUP.

The most interesting thing in this talk was the suggestion that a burndown chart should include time for unanticipated work!

I saw Justin Mason speak on enabling continuous delivery at MeasureUP.

He said aloud that small frequent commits are good. I totally agree but have worked with others that don't, so I was glad to get the affirmation. I guess some of the criticisms against small commits are that it is harder to peer review or code review. That's the push back I've bumped into. Another thought is that nothing should be committed that isn't fully functional even if it is partially working in a harmless way that sabotages nothing else. For me this goes to that rock climbing analogy of only being able to fall to the point where you last planted a spike. I don't want to get something working and then self-sabotage downstream without a way to get back to where I was. I guess I could copy folders around locally in my own environment to make the rock climbing safe, but what if my VM dies. Maybe I'm paranoid.

Friday, October 9, 2015

Grabbing ahold of a resource in regular web forms varies from grabbing a hold of a resource in DotNetNuke implementations.

string value = GetLocalResourceObject(myMagicString)?.ToString();

If you have SomethingFunAndMagic.Text as a line item in your resource then "SomethingFunAndMagic.Text" needs to be in the myMagicString variable here to retrieve a resource in the traditional web forms flavored way. The DotNetNuke way of doing things would allow you to just hand in "SomethingFunAndMagic" and it would append the ".Text" for you.

the [DefaultConstructor] attribute for StructureMap

...will allow you to specify the constructor for a controller which StructureMap tries to hydrate with dependencies. Without this specification StructureMap will just pick the constructor with the most parameters, which may not be desired. This attribute goes at the constructor. A different, hacky way to approach this to put something like this in AssemblyInfo.cs in the Properties folder of a .NET project:

[assembly: InternalsVisibleTo("MyTests")]

 
 

...to expose the UI project's internal constructors to other projects (in this example they would be exposed to a test project) as needed. Admittedly, this may not be needed at all depending on what is dependent on what. Anyhow, you would, in this hack, slap internal on controller constructors that are longer in terms of number of parameters than the constructor you want to serve as a StructureMap default (which would get the public accessibility). My superior suggests the conditional open up of internal is the closest thing C# has to the concept of a friend in C++.

CQRS, DDD, and Event Sourcing (ES)

...was the name of another talk I saw by Gabriel Schenker. In CQRS, conceptually you are changing a system much less than you are reading from it and thus a distinction may be made between commands and queries. Commands are the writes. You send them to the backend and you, at most, get back a pass or fail feedback affirmation/rejection. You do not need these to be particularly snappy in terms of performance. Queries are the reads. These are expected to have no side effects in the system. They should be nullipotent. Carrying this on to event sourcing, a model may be drawn in which there is a triangle wherein the points are the UI (called "the client" in Gabe's slides), the domain, and the read model. A fourth point on our triangle, making it sort of a diamond, would be the event store which keeps a history of what happened. Sequentially what happens between the actors is:

  1. A command comes from the client to the domain.
  2. Three things happens here. There are three arrows out from the domain to the three other pieces.
    • Acknowledge or not acknowledge is sent back to the client. I suppose in the event of not acknowledge the other two things herein don't occur and we are at the end of our process already. Yet, assuming acknowledge...
    • The read model is updated.
    • The event store is updated.
  3. Next...
    • The client queries the read model and...
    • The event store acknowledges or not acknowledges the update from the domain.
  4. A DTO (data transfer object) or DTOs are sent from the read model to the client.
  5. Events from the event store may be replayed to the read model to get the history and big picture of what has gone on later on downstream of the process above.

The DDD part of the talk focused on Eric Evans ubiquitous language concept and in particular determining what the aggregates are in a domain which are sort of parallel to what the objects are in code... um, really they should be parallel. Your code should use the language you iron out in domain modeling. Aggregates have IDs and they can have simple properties such as string values. A customer, for example, can also have subobjects so to speak such as name, address, and phone number which are more than simple strings and perhaps get their own database tables, but these subordinate actors are only to be accessed by going through their parent and hence they are not aggregates in and of themselves. Aggregates will not have other aggregates nested inside of them.

Thursday, October 8, 2015

Get rid of ambiguity at a using directive in C#.

using Environment = MyApp.Core.Environment;

...would alleviate ambiguity between your own Environment type and System.Environment for example.

Wednesday, October 7, 2015

Snagit

...is a tool for grabbing screenshots and drawing on them some. Whatever

the "Sync with Active Document" icon in the Solution Explorer of Visual Studio 2015

It's to the left of the "Refresh" icon. It looks like an arrow pointing left with an arrow pointing right parallel beneath it. If you are in a file and you click this arrow, the file you are in will be found in the Solution Explorer and highlighted. If it is nested inside a bunch of closed folders, the closed folders will get expanded open for you.

Tuesday, October 6, 2015

GridViewCommandColumn performance hit at a DevExpress ASPxGridView!

<dx:GridViewCommandColumn Width="150px" ShowClearFilterButton="True"
      ShowEditButton="True" ShowNewButton="True" ShowDeleteButton="True" />

...may be expensive. If you are showing all rows this column will make the grid load slow. There will be a blob of JavaScript inside a script tag for each row. The fix is to have a paginated grid and the option for showing all rows. Showing all rows after the page loads causes less heartache to the whole of the page loading as it struggles through all of the HTML. By the way, I noticed that the JavaScript in the script tags is wrapped inside of an HTML comment. This does not comment out the JavaScript. This is an old school practice from twenty years ago for making sure that browsers which cannot interpret a script tag do not display the JavaScript as copy.

KILL is a keyword in T-SQL!

It will stop a process by a SPID (Server Process ID) and...

KILL 55

 
 

...seems to stop a rollback. (I think.)

My mind associates extreme programming with continuous integration.

The Wikipedia write up here suggests it's vaguely about getting responsive feedback on your progress quickly, and has this image:

...but I am hung up on some of the CI magic. Every time you check in the build runs all the unit tests and complains loudly if a unit test is broken. This keeps team members from sidestepping test driven-development and sabotaging everyone else's tests by checking in code that breaks tests without consequence, er, immediate consequence. The build is pushed to a dev server that everyone may look at to see the progress, etc. There are engineering specifics which separate XP from just Agile. I guess the image I included doesn't show up too good.

I guess one may use BEGIN TRAN instead of BEGIN TRANSACTION in T-SQL.

It's legit.

Make two different queries with similarly structured results come back in one dataset with UNION ALL in T-SQL.

This has the following pseudocode which shows off how to use UNION ALL:

SELECT expression1, expression2, ... expression_n
FROM tables
WHERE conditions
UNION ALL
SELECT expression1, expression2, ... expression_n
FROM tables
WHERE conditions;

Keep a DevExpress ASPxGridView from sorting when one clicks on a column header.

<SettingsBehavior AllowSort="false" AllowGroup="false" />

...need to go inside of the dx:ASPxGridView tag.

Every time I try to work with NServiceBus I get a little bit closer to success.

The MeasureUP talk I liked the best was by a Mr. Justin Self and it was a very entry level how-to on NServiceBus. I came out of the talk with a basic understanding of how to set up a project that used NServiceBus and I then wrote some silly (you'll see how silly) code of my own. I'm pretty sure that the code I have would work if I could figure out how to get NServiceBus to see MSMQ. I "put my hand up" (well, I opened my big mouth) during the talk and asked if there was something akin to the connection string in a Web.config that finds the database for an elementary web site that specified where to look to for MSMQ and how to connect to it. Justin said that there is something like that if you use RabbitMQ, but if you are just using MSMQ at the same server that you are running the app with NServiceBus it will just be found. I turned it on and I can't see it however. Anyways, my message object looks like this:

using System;
using NServiceBus;
namespace SomethingFun.Models
{
   public class Chicken : ICommand
   {
      public DateTime Hatching { get; set; }
   }
}

 
 

"Install-Package NServiceBus" as a NuGet command loops in the NServiceBus namespace here. That and just turning on MSMQ (and yes you have to explicitly turn it on as a service) should be all of the prep work you have to do. In Windows Server 2012 R2 , if you go to the Server Manager, and pick "Computer Management" from the "Tools" menu at the upper right, you should be able to see "Messaging Queuing" beneath "Services and Applications." I think "Add Roles and Features" beneath "Manage" back at Server Manager is where you add in MSMQ to begin with. My idea was to make an ASP.NET MVC application that, upon spin up, asynchronously reached out to ipchicken.com and scraped the page to sniff out the IP address which it would then write off to a text file. I didn't really get that far however because I, again, hit the brick wall of not being able to speak to MSMQ. You are going to need an implementation of IHandleMessages and mine looked like so:

using System;
using NServiceBus;
using SomethingFun.Models;
namespace SomethingFun
{
   public class ChickenScraper : IHandleMessages<Chicken>
   {
      public void Handle(Chicken message)
      {
         throw new Exception("whatever");
      }
   }
}

 
 

When I actually run my application the error I get specifically suggests that I cannot find a queue at MSMQ for my implementation of IHandleMessages. Rats! Anyways my HomeController just looks like this:

using System;
using System.Web.Mvc;
using NServiceBus;
using SomethingFun.Models;
namespace SomethingFun.Controllers
{
   public class HomeController : Controller
   {
      public ActionResult Index()
      {
         var bus = Bus.CreateSendOnly(new BusConfiguration());
         Chicken chicken = new Chicken();
         chicken.Hatching = DateTime.Now;
         bus.Send(chicken);
         return View();
      }
   }
}

 
 

Your configuration file needs some love to get this all working. Well, heh, I don't have it working, but at least I have it a little ways along. To get to the point where you cannot talk to MSMQ you will need something like the following in the configSections portion of Web.config or app.config or whatever:

<section name="MessageForwardingInCaseOfFaultConfig"
      type="NServiceBus.Config.MessageForwardingInCaseOfFaultConfig,
      NServiceBus.Core"/>
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig,
      NServiceBus.Core"/>
<section name="AuditConfig" type="NServiceBus.Config.AuditConfig,
      NServiceBus.Core"/>

 
 

Finally, the end of the configuration file should look like...

   <MessageForwardingInCaseOfFaultConfig ErrorQueue="error" />
   <UnicastBusConfig>
      <MessageEndpointMappings>
         <add Assembly="SomethingFun" Type="SomethingFun.Models.Chicken"
               Endpoint="SomethingFun.ChickenScraper" />
      </MessageEndpointMappings>
   </UnicastBusConfig>
   <AuditConfig QueueName="audit" />
</configuration>

Saturday, October 3, 2015

reshape

One of the talks I saw at MeasureUP was called "Reshaping the Company" and it was put on by a Mr. Gabriel N. Schenker. It was about making your company better and less sick. He suggested that a team is like a chain in that it is only as strong as its weakest link (weakest employee) and that for continuous deployment everyone has to be an engineer. Most companies are in firefight mode and firefighting is a grave evil for a company as there are no budget or resources planned for it. At Microsoft they stopped all development to create Service Pack 2 for Windows XP in the name of stabilizing it. This took a problem out of firefight mode and into formal plans. Heroes also do a lot of unplanned work. If someone is producing more than may be consumed downstream, send them home early to spend time with their family. What if your hero was hit by a bus? IT needs to be involved in strategic decisions and not just treated as a cost center. Many places give names to their servers and give them special treatments like pets. "I have this server, Billy, and I give it special treatment, and I have a patch installed on it..." etc. When Billy dies one day it is sad just like when your dog dies. You need to get out of thinking that your servers are special and need to be loved. In lieu of having pets, have a herd of cattle. They should really all be largely the same, and if one of them dies one day it should just be a cost, not a devastatingly sad gut punch to cry about. If you are building features which are not being put into production you are building waste.

Friday, October 2, 2015

ABCs of Windows Authentication in IIS

Well, first of all, you need to explicitly turn it on by enabling it. You'll find it by visiting the Authentication settings for a web site like so:

And then this needs to go in Web.config:

<authentication mode="Windows" />
<authorization>
   <deny users="?" />
</authorization>

 
 

Specifically this stuff needs to go inside system.web and not system.webServer. I recall once being told that system.web was for IIS6 while system.webServer was for IIS7, but that doesn't seem to be universally true. The authorization piece here doesn't need to be added for IIS6 to deny unknown users and force them to login, but you need it later versions of IIS. The "force them to login" thing looks like this:

Don't let Google confuse you here. In this example I am leaving Google in attempt to log onto an intranet app that needs the logging onto. The "Authentication Required" box appeared for me in Safari where I struggled to log in and in Firefox where I logged in just fine but not in IE or Chrome which seemed to just log me in, allowing me to sidestep the need to enter credentials. The login takes my active directory username and password. You're only gonna use this stuff for in-house intranet stuff. I really haven't researched how to interface with it from C# yet, but if you want to just show the name of who is logged in on the screen in a web forms app you may do so with a tag like this:

<asp:LoginName ID="Whatever" runat="server" />

Use COALESCE in T-SQL to have a fall over to value should an assignment be null.

SELECT @foo=COALESCE(@bar, 'baz')

"bang" is slang for exclamation mark

This comes up in conversations about passwords.

Thursday, October 1, 2015

nameof in C#

...is going to return a stringification of a variable name. The following test passes:

[TestMethod]
public void Test()
{
   Tuple<string,int> foo = new Tuple<string,int>("lucky",13);
   Assert.AreEqual("foo", nameof(foo));
}

explicitly permission the IIS_IUSRS group to access file folder permissions?

I used to think this was a must. I thought that when a user at large hits a web site that they are generically connecting as this group, but instead this group probably contains the App Pool users. You "hit" a web site as if you were the particular App Pool user for the site or application at hand.

Wacky awfulness happens when trying to interface with IIS6 at Windows Server 2003 with IE 10 and IE 11.

This has a write up... but maybe you should just get off of Windows Server 2003.

If you accidentally create a story instead of a defect in Rally there doesn't seem to be a way to convert it into a defect.

The gear symbol at the upper right will let you upgrade a defect into a story and a story into something called a "Portfolio Item" but to cannot walk in the other direction. Stories can have defects, etc. That's why.