Tuesday, March 31, 2015

If you don't yet see a .config file for your web site in the temp directory for application pools...

...it likely means that you have just restarted the VM and nothing has hit the web site yet to wake it up and make it write a file into the temp directory. This has to do with this error.

delta

Does it mean the difference between two things or does it mean something bad? Neither meaning is really of the formal definition, but both of these shapes keep coming up in conversation. My brain hurts. Handjam is another fun geeky term.

Right-click on a Service Reference in Visual Studio 2013 and pick "View in Object Browser" to get a breakdown on the "classes" the web service uses.

cool stuff

BIOS

...is the basic input/output system that looks like a blue screen with white text which allows one to do some rudimentary stuff before the operating system starts to run. If you want to boot from the CD/DVD drive instead of the C drive, you may set that, etc. When you are first boot up, you will see white text scroll on a black background as the box tries to find the operating system and you'll need to hit a hotkey in this window of time before you see that familiar four panel flag of Microsoft Windows in order to break into BIOS and this suggests the common modern day hotkeys for this are: F1, F2, F10, Delete, and Esc ...any one of these should do

Alipay started in China and my superior mentioned that it still rides atop Chinese currency.

One may take an Alipay payment in U.S. dollars and it will be translated into the Yuan of the Renminbi money system of China. Part of the Alipay infrastructure compensates for the wild exchange rate fluxuations of the Yuan so that one hundred dollars inbound will yeild the appropriate amount of Yuan on both Tuesday and Wednesday when two different values apply.

pre-auth as a concept

This is for situations where one is submitting credit card data for reoccurring monthly payments (or some other interval of time) and the first charge is not to happen until the end of the first month (period). In these circumstances there will be an upfront auth to make sure the card specs are good for either zero dollars or one dollars. Sometimes a dollar auth is required.

passing C# DateTime types in XML

var x = DateTime.Now.ToString("o");

...in C# is going have a shape like 2013-01-13T04:47:34.7559072Z which is how DateTime values should be passed in XML.

super simple XSD example

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
      xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <xs:element name="Person">
      <xs:complexType>
         <xs:sequence>
            <xs:element name="Name" type="xs:string" minOccurs="1" />
            <xs:element name="Birthday" type="xs:dateTime" minOccurs="1" />
            <xs:element name="LikesCats" type="xs:boolean" minOccurs="1" />
            <xs:element name="NumberOfCats" type="xs:int" minOccurs="0" />
         </xs:sequence>
      </xs:complexType>
   </xs:element>
</xs:schema>

 
 

...should demand XML like of a shape like this:

<?xml version="1.0" encoding="utf-8" ?>
<Person>
   <Name>Carlos</Name>
   <Birthday>2009-06-15T13:45:30.0900000</Birthday>
   <LikesCats>true</LikesCats>
   <NumberOfCats>2</NumberOfCats>
</Person>

Monday, March 30, 2015

consuming a WSDL that is not of a WCF web service in an ASP.NET application

You should be able to do this with the URL that ends in ?wsdl the same way you would otherwise latch onto a URL ending in .svc without issue. When you new up the client in C# there will just a client to instantiate and not an interface abstraction.

Keep Windows Server 2012 R2 from logging you off whenever you leave it be for a few minutes???

Well, this and this suggested:

  1. type "regedit" while running Powershell (probably best to do so as Administrator) to bring up the "Registry Editor" dialog box
  2. navigate the "folder structure" of sorts at the left navigation to "8EC4B3A5-6868-48c2-BE75-4F3044BE88A7" inside of "7516b95f-f776-4464-8c53-06167f40cc99" inside of "Power Settings" inside of "Power" inside of "Control" inside of "CurrentControlSet" inside of "SYSTEM" inside of "HKEY_LOCAL_MACHINE" beneath "Computer" and then right click on "Attributes" in the right pane to pick "Modify..." to change "Value data:" from 1 to 2
  3. type "Control Panel" at the search at the charm bar to bring up the "Control Panel" dialog box
  4. change the "View by:" menu at the upper right to "Large icons"
  5. pick "Power Options" and then "Change plan settings" by "High performance" and then "Change advanced power settings" on the other side of that
  6. in the "Power Options" dialog box which appears expand "Display" and then expand "Console lock display off timeout" and right click on "1 Minute" to change the value to zero minutes

 
 

...but I found myself unable to change the setting! Instead if I pick "Change settings that are currently unavailable" where I might otherwise pick "Change advanced power settings" I can set the "Turn off the display:" setting from "15 minutes" to "Never" ...and yet that seems NOT to do the trick. Grrr. I don't know what to do.

Addendum 4/20/2015: This actually worked just fine. I don't know why it seemed not to work at first. Maybe I needed to restart or something.

Jing

...is a record-your-desktop tool. It is free and it lets you make five minute long movies which get saved out in the .swf (Adobe Flash) format.

When you do an "auth" on a credit card you are doing an authorization and not an authentication.

What I offer here is wrong. The distinction between authentication and authorization is discribed at the bottom of this blog posting.

Sunday, March 29, 2015

If you want to have a solution named Whatever and a UI project named Whatever.UserInterface as the startup project in Visual Studio 2013...

I recommend creating a new solution/project named Whatever.UserInterface in Visual Studio 2013, then closing Visual Studio, and then manually changing the name of the .sln file in Windows Explorer to be Whatever.

Friday, March 27, 2015

When you consume a WCF web service in a C# app you may use a using statement with the client you "new up" in code.

Instantiate like so:

using System.Web.Mvc;
using WebApplication1.LocalServiceReference;
namespace WebApplication1.Controllers
{
   public class HomeController : Controller
   {
      public ActionResult Index()
      {
         using (ConnectivityTesterClient x = new ConnectivityTesterClient())
         {
            x.ClientCredentials.UserName.UserName = "HelloNasty";
            x.ClientCredentials.UserName.Password = "br@ssMonkey";
            x.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode =
                  System.ServiceModel.Security.X509CertificateValidationMode.None;
            ViewBag.PassOrFail = x.Test();
         }
         return View();
      }
   }
}

 
 

It didn't even occur to me that the client might implement IDisposable until a coworker said something today. (embarrassing!) When I had to think about it I found some interesting stuff in Googling...

Who does OCP in a purist sense?

I recall a conversation I had with Tim Tonneson in which he spoke of C# project he had heard of secondhand in which the developers embraced the Open/Closed Principle completely, authoring classes, getting them under test, rolling them out in deployments, and then never altering them again in any way. All "revisions" were done through extensions which I'd imagine took the shape of making child classes and having them warp the parent's behavior with inheritance tricks. At some point a child instance would have to replace what was handed into methods in lieu of a parent instance I guess. But Tim didn't suggest firsthand experience with this sort of disciplined approach and I don't have any experience with it either. At all of the places I've yet worked, no one does this. I can remember a presentation I saw John Teague give wherein midstream into a process of steps, whilst showing everyone a projection of his work in Visual Studio, he said something like: "I do have to break the Open/Closed Principal a little here and change this line." That seems like a pretty normal thing to do. A strict adherence to OCP seems almost detrimentally challenging.

Delete a Windows Service without using the installer that made it to do an uninstall.

As this suggests, it's pretty easy. Just run a command like this from the command prompt:

sc DeleteService "My Console Application"

 
 

I suppose I should qualify that I got this to work at Windows Server 2008 R2.

Thursday, March 26, 2015

What is fraud processing as opposed to payment processing and what is authentication as opposed to settlement?

While payment processing suggests running a credit card's specs to get an authentication, fraud processing entails running the specs to get a numeric grade for legitimacy versus shadiness. In an online process a web presence may fraud process a card and then decide whether or not to go forward with an authentication or may alternatively authenticate a card and then decide whether or not to go through with a settlement based upon a fraud processing following the payment processing. Authentications do not necessarily have to be settled. When I give my credit card specifications and they are successfully authenticated for $17.32 for iced tea and lasagna at WINFLO I am giving the restaurant permission to take money from me, but they have not taken money from me at that point. They may later settle and at this point they may take money from me and not necessarily the amount of the authentication. If I authenticate at $17.32 and then write a five dollar tip on the receipt I will end up seeing a settlement for $22.32 at my bank records. Alternatively one may authenticate for getting $5,000 dollars of product from a distributor and when the distributor turns out to only have $3,000 in stock a circumstance could occur wherein $3,000 is settled for and a separate authentication and a separate settlement for another $2,000 is just going to have to happen later. A reason to not settle at all for what appears to be legitimate credit card specs that authenticated just fine is a suspicion of the order be challenged after it arrives by an unscrupulous party, I suppose. Here comes in the fraud processing. CyberSource and ReD (Retail Decisions) are examples of providers for this sort of grading service.

Addendum 3/30/2015: This copy has a big mistake in it. You are doing an authorization and not an authentication when you do an "auth" on a credit card. See: this

PCI security expects modern operating systems with appropriate security patches.

I learned of this in another FAQ (Frequently Asked Questions) I found online. This suggests, for example, that Windows XP has been unacceptable for just shy of a year now.

Break the Law Of Demeter and reach into a nested enum in C#!

public void Report(List<Tuple<decimal,Measurement.TemperatureGauge>>)
{
   
//whatever

 
 

...should let you just have at...

public class Measurement
{
   public enum TemperatureGauge
   {
      Celsius,
      Fahrenheit,
      Kelvin
   }

 
 

...but I don't really recommend it. It you're gonna use nested classes and enums they should probably be private so that only the class wrapping them may mess with them. This is kinda like JavaScript encapsulation where one puts a function inside of a function so that only the wrapping function may use the encapsulated thing. Until now I've always thought nested classes/enums were pretty ghetto, but I suppose they can have their place. They suddenly seem more legit as I've typed what I've typed above. You'd want to make them private.

Why can't I see the menu bar at Windows Explorer in Windows Server 2008 R2?

Problem: You just spun up Windows Server 2008 R2 and you want to unhide file extensions and show hidden files and the like at the "View" tab at the dialog box one gets when one goes to...

Tools > Folder Options

 
 

...and yet there is no "Tools" menu to be found. Well, you may unhide the proper menu bar from that button that says "Organize" on it next to a down arrow like so:

Organize > Layout > Menu bar

Wednesday, March 25, 2015

There is a Payment Card Industry Security Standards Council which defines the PCI-DSS.

https://www.pcisecuritystandards.org/ is their web site and https://www.pcicomplianceguide.org/pci-faqs-2/ is the specific web site where I learned about them which suggests that Visa, MasterCard, American Express, Discover and JCB came together to form this organization on 9/7/2006. By the way, JCB and Discover are not the same thing. http://en.wikipedia.org/wiki/Japan_Credit_Bureau suggests they have had an alliance since 8/23/2006 right before the PCI SSC was set up, but Japan Credit Bureau does not own Discover.

FDMS would stand for First Data Merchant Services which is owned by First Data, I think.

"FDMS North" is a flavor of credit card transaction processing. See:

"No connection could be made because the target machine actively refused it." versus "The wait operation timed out."

These are two very different things. The second suggests an explict failure in interacting with SQL Server but the first doesn't really get that far. It suggests that there was nothing listening on the port specified or that the firewall is blocking you! These two different circumstances came up when experimenting with turning off a database needed by two different web services in two different environments to see how the web service would react in logging the error. It turns out it acted two different ways. The second was ideal. The first came up somehow by way of database mirroring and failover. You may do that sort of thing in a connection string like so:

Data Source=myServerAddress;Failover Partner=myMirrorServerAddress;Initial Catalog=myDataBase;Integrated Security=True;

how to get a favicon to show up in an IIS application

This is the perfect tag if you'll forgive the Razor markup.

<link rel="shortcut icon" type="image/vnd.microsoft.icon"
      href="@Url.Content("~/favicon.ico")" />

 
 

What I suggest here is not so good as it turns out.

standing desks

Seven different people at work now have standing desks. I don't get the fad. I do feel fidgety in sitting all day and I take 101 different pee breaks during my work day.

oh, you hipsters and your Macintosh laptops

I'll never need to know the Macintosh professionally as a C# developer. This is never gonna be an expectation, and yet I do see Macintoshes popping up here and there in the C# space. Some people have to be rebels and use them. They rationalize it in their own ways I guess. They sure seem like toys to me. Whatever. You're fools. I guess I have used a Mac for testing before. My superior at work uses a Mac for testing. I guess that is a legitimate reason to go into that sad little world. I loathe to wallow there. I do own an iPhone, but, you know, it's a toy, not a professional development environment.

Monday, March 23, 2015

When one drags out the handles from a vertex in Adobe Illustrator and makes a curve...

These curves are called bézier curves.

You need administrative privileges to install add-ins in Visual Studio.

...and to debug applications that run in IIS, and few other things. I think every Visual Studio jockey also needs to be an administrator on his/her box as otherwise the experience will may decay from spiffy to iffy.

vicariously experiencing SXSW

Alright, another South by Southwest has come and gone in Austin, Texas and while I didn't go this year I did get something of a vicarious experience by way of working downtown, and, more so, today my company had a let's-talk-over-pizza lunch in in which those of us who did go spoke to their experience. I come away with the following notes:

  • The bad: A lot of it was too high level to be practically applicable to one's work life which was basically what I experienced last year and what left me little incentive to return this year. At the view from 20,000 feet there was at least one talk on Artificial Intelligence with an imagine this, imagine that fluffy feel to it. Tim Ferriss supposedly gave a talk "on how to do SXSW" which recommended reading the bios of speakers when considering a session to attend and not the blurb on the session itself. Something new this year seemed to be that many sessions required a RSVP (répondez s'il vous plaît) in advance and there seemed to an inclination to wish there was more of this required instead of less of it once one was shut out from a full event where the RSVP rule did not exist. It was suggested that the JW Marriott Austin was a poor venue as it has small rooms. RSVP signups got an email asking them what they thought of their experience too. Netflix offered a slideshow as a companion to one of their talks to compensate for people being shutout. One coworker suggested that panels, for which one could not RSVP, should just have been scheduled earlier.
  • Beyond the talks: One coworker went through the trade show in the convention center on a Sunday. She said that NASA was there as were a lot of kickstarter companies. On display was a portable power supply that one could power either a laptop or a smartphone with and retractable earphone and USB cords. She said there was robot petting zoo, and she also fell victim to some social engineering in which she was tricked into posing for a photo with some people who ended up getting her to hold a "Legalize Cannabis" sign. It sounded like there was plenty of robot stuff in general.
  • I learned more about what the M-Pesa money system in Kenya is. It turns out it all comes from a tragic/comic situation in which Kenya has no strong currency and thus individuals trade cell phone minutes over the M-Pesa system as the de facto currency. M-Pesa takes a 30% cut of a transfer though making it not so practical. A Bitcoin system would be a better way to go.
  • Of Bitcoin, there was some security stuff. It uses decentralized caching. A ledger is spread out across several volunteer computers in a decentralized chain block. One has to wait for six transactions with the decentralized computers to be affirmed to verify a payment. Bitcoin has volatile exchange rate and another challenge is the anonymity of where payments are coming from and going to. How do we know Bitcoin isn't funding ISIS?
  • A lot of coworkers liked a talk called "How to Rob a Bank" which suggested that it was just easier anymore to steal someone's identity. One's home street address, which is typically not considered a super-sensitive piece of information, may be used in tandem with a social security number to fake an identity and thus, it does have some sensitivity as a datum. SSN and DOB (date of birth) together are also pretty good for faking identity. Tokenization was emphasized for security. It was noted that the law doesn't really keep up with technology when it comes to transactions. There were some statistics on how much a credit card number was worth to a hacker. It has fallen from about ten dollars to a single dollar. On the dark web, hackers will launder credit cards with gift cards, setting up credit cards based on gift card funding. This factoid led to some out loud speculation as to how to verify cards and time limits upon them.
  • Astro Teller of Google X gave a talk in which he covered the crazier stuff that Google X does like self-driving cars and WiFi balloons. He said that you should not be afraid to fail and that in order to innovate you need to fail often and fast.
  • "Drive" author Daniel Pink gave a talk on getting people to change their behavior with nudging. An example was given in which a hotel wanted guests to reuse towels instead of expecting the hotels to rewash them daily and it got this to happen by leaving note cards in the rooms which suggested that 70% of guests reused towels. He asserted that rhyming, repetition, and alliteration help in messaging and that, thus, "Woes unite foes." messages much better than "Woes unite enemies."
  • There was much talk on big data and if there is a way to sanitize and sell big data. Collect non-sensitive data and selling it to people? Big data was seen as an emerging theme. Every piece of information about you is probably worth something to someone. What are the times of day a business' sales have the most volume. Little subtleties like this may be opened up and exploited. F1 exhaustively records biometric data on its drivers. Pharmaceutical researches do big data too. "Drop Dead Healthy" author A. J. Jacobs suggested that we are all related and that big data proves it and that Barack Obama is effectively a twelfth-cousin or whatever as he can show a 14% generic match with him. He plans to have a family reunion in which everyone on Earth is invited. 23andMe can take a generic sample from you and try to find lost relatives with its big data abilities. They can also tell you if you a prone to certain diseases. You might have a genetic marker for heart disease that you didn't know about in your youth.
  • There were talks on both storyboarding and gaming that no one at today's event personally attended.
  • Optimizely was suggested as a cool tool in a talk on integrating A/B testing with an automated testing framework. Well, honestly, "Optiwiser" was what was said aloud, but I could not find this in Googling for it. As a concept A/B testing involves the moderation of a change variable. A lot of this talk delved into mobile space stuff.
  • There was apparently also a talk on UX testing which encouraged getting your customers together to do testing and taking their pulses.
  • There was a talk on JavaScript testing which suggested that PayPal is now using NodeJS and the NodeJS allows for modularized code. This was high-level talk which also had some Python and some CSS in the lesson-to-learn that one was to download and experiment with.
  • A coworker attended a talk on beacons. Beacons are wearable tech which let you send and receive Bluetooth signals in lieu of jumping on wireless networks. The coworker thought that perhaps the Round Rock Express baseball team used beacons to allow persons at the games to either order food or reserve places in lines. If you are walking in the mall with a beacon you could get an alert from The Gap for jeans on sale for $42.95 and the like. Pier-to-pier networks were also discussed in the beacons talk.
  • The government is trying to update the tax code to help with innovation in the name of patent reform.
  • Coworkers went to a talk called "seemingly seamless" which they hoped would be about things like how Uber takes payments without you ever giving a payment to the driver, but it was instead on subscription services. ClassPass and Braintree (recently acquired by PayPal) had speakers there.
  • Dwolla had a talk. There were talks on art. There was a talk on Nielson ratings stuff. There was a talk on how to draft in sports. There was talk on the ten greatest gambling moments ever.
  • Charles Barkley (basketball) gave a talk on controlling your digital identity. His company (tech) looks at the dark web for where others have been attempting to use your password. If someone gets your password from one source they are likely to try to reuse it at big venues like Amazon and the like, etc.
  • Speaking of basketball it is March Madness time and a panel set up a March Madness bracket to vote their way into what was the greatest geek moment ever. Star Wars ended up beating the internet. The crowd was allowed to vote afterwards and the crowd found the internet to be bigger.
  • Art Briles, the coach of Baylor football, gave a talk on coaching fast and furious and taking a no name team to the top.
  • There were not that many plugs from speakers on panels themselves for their companies. They just said who they worked for and went forward. The plugs happened went audience members got up to ask questions. They would then plug their companies.

Saturday, March 21, 2015

struggling to understand building a Func or an Action from C# expressions

If want to make a Func from this method...

namespace Expressy.Models
{
   public class MessageMaker
   {
      public string HugsAndKisses(int count, bool isToKissFirst)
      {
         int counter = 0;
         string hugsAndKisses = "";
         if (isToKissFirst)
         {
            while (counter < count)
            {
               hugsAndKisses += "XO";
               counter++;
            }
         } else {
            while (counter < count)
            {
               hugsAndKisses += "OX";
               counter++;
            }
         }
         return hugsAndKisses;
      }
   }
}

 
 

...not unlike so...

using System;
using System.Web.Mvc;
using Expressy.Models;
namespace Expressy.Controllers
{
   public class HomeController : Controller
   {
      public ActionResult Index()
      {
         MessageMaker messageMaker = new MessageMaker();
         Func<int, bool, string> funky = messageMaker.HugsAndKisses;
         ViewBag.Message = funky(13, true);
         return View();
      }
   }
}

 
 

...yet with an expression. How may I do so? I've gotten this far...

using System;
using System.Linq.Expressions;
using System.Reflection;
using System.Web.Mvc;
using Expressy.Models;
namespace Expressy.Controllers
{
   public class HomeController : Controller
   {
      public ActionResult Index()
      {
         var intType = Expression.Parameter(typeof(int), "int");
         var boolType = Expression.Parameter(typeof(bool), "bool");
         Type type = typeof (MessageMaker);
         var target = Expression.Parameter(type, "t");
         MethodInfo methodInfo = type.GetMethods()[0];
         Expression call = Expression.Call(target, methodInfo, intType, boolType);
         var lambda = Expression.Lambda<Func<int, bool, string>>(call, intType,
               boolType);
         Func<int, bool, string> func = lambda.Compile();
         ViewBag.Message = func(13, true);
         return View();
      }
   }
}

 
 

...and that surfaces this error:

variable 't' of type 'Expressy.Models.MessageMaker' referenced from scope '', but it is not defined

 
 

The hyperfast reflection implementation that a coworker has crafted uses expressions with stuff plucked from reflection to create Actions to do the setting of getsetters on POCOs. I hate to just plagiarizer his work on my blog so I thought I'd try to figure out how to do the expressions myself. I'm coming up sort. When I Google the error message it vaguely feels like I'm missing an expression for a "p" convention to go with my expression for "t" and it seems the "t" and "p" are commonly used when staging expressions in this manner. He, my colleague, does have something like so in his code...

var somethingMore = Expression.Parameter(typeof(object), "p");

 
 

...but I'm not sure how to jam it in myself. Maybe I'll follow up this blog posting with another or maybe I'll let this be. We shall see. I found this from some time ago which is easier to read honestly.

Convert.ChangeType in C#

It looks like this:

Type type = typeof(Int32);
string thirteen = "13";
int integer = (Int32)Convert.ChangeType(thirteen, type, CultureInfo.InvariantCulture);

 
 

...and, yes, you have to have that casting in the last line of code.

Friday, March 20, 2015

Hyperfast reflection in mapping was explained to me by a coworker today

Conceptually, when one is to map the dataset from a sproc to a POCO at C# in the name of decoupling an entity from the data implementation, this provides a way to do so wherein the C# type is crawled for its setters ONCE by reflection and a dictionary of actions is then crafted to actual set the getsetters. Mapping rules attempt to cast table columns to the dictionary keys to hydrate objects, and for the most part this behaves just as fast as if there were no reflection to begin with as the upfront performance hit is the only performance hit. When writing instead of reading, you don't really need the mapping. You can just call a sproc. You really only need to get back the id of a new entity if you are really ORMing-out and you may find that you don't really need to. In many apps, when adding a new object at a list of objects the user is just taken back the list and there is not immediately a greater workflow happening with the newly created thing. If you select the thing that was created a second time for editing, well, then you'd obviously have the id then.

hero knowledge in Scrum planning poker

This seems to lead to a scenario in which others just come up or down to the hero's estimate. It's not hard to talk others there as they know they are not in the know.

 
 

Where I work there is a growing inclination to skip using the cards with the Fibonacci sequence spread across them and to just talk our way to a consensus on a number for story points for any one story. On a team of seven not everyone is going to be equal in knowledge for every story. Often someone may more or less have the estimate standalone and it's just a matter of acknowledging it aloud.

Thursday, March 19, 2015

Alliance Data

...offers a bunch of fluffy credit cards for retail brands like Victoria’s Secret. As a part of their marketing arm they have an API that may be hit when one is marking a purchase with a different credit card online (when JavaScript notices all the important fields have been filled out at that form that is ostensively for just making a payment) which will judge if one should be approved for a Vicoria's Secret (or whatever) credit card.

a race to the bottom for content?

A coworker told me today that Amazon has set up a second site for a Netflixesque subscription service for books. Publishers of the books read at this site are given a financial incentive per page read and thus there is an inclination to just publish the first hundred pages of a would-be book to see if anyone bites and then maybe follow it up with another hundred pages if it's profitable. This is not the way to write books guys. The same coworker suggested that there is a lot of quick-out-the-door poop strung across Netflix itself too. I don't own a television so I haven't seen the bad of our modern streaming era for myself. I've heard I'd have to spend about two thousand dollars to buy a modern pimped out TV. Maybe I should just find another hobby.

Junk In, Junk Out ...just let it be when playing middleman for an API

Imagine this, others will submit data to your code, your code will do its thing and then hand off to another, third party API or perhaps get back stuff from the other API as a part of doing its thing. It's probably wise not to sanity check the users' stupidity to prevent them from handing in values that don't make sense at the API. A time hole comes in being "clever" like this and you are possibly limiting your own feature by limiting the API. You need to be able to tell the red-headed step child "You be you." and if it isn't solving a problem itself you probably should not take it upon yourself to build a fortress around it. There could be a valid reason why the API behaves as it does or has been left wide open. Don't try to warp the expected behavior.

Mountain Goat Software's planningpoker.com seems pretty cool.

We used it today while having a backlog grooming over a GoToMeeting meeting. You use the tool for... planning poker.

delete a story in Rally

If you open story you may find an option for a delete in the gear menu at the upper right.

Wednesday, March 18, 2015

struggling to get a new favicon.ico file to appear

I could not get the favicon.ico file to appear at an IIS application. It only started to show when I explicitly set up the application as a web site in IIS8, and then only after I first explicitly visited http://www.example.com/favicon.ico at Google Chrome and then, secondly, did a Shift-F5 at http://www.example.com/ itself. I do have the following tag in the views of the MVC app:

<link rel="shortcut-icon" type="image/ico" href="/favicon.ico" />

Addendum 3/25/2015:: This sucks. See this instead.

Tuesday, March 17, 2015

the "Language" menu in Notepad++

...will let you color format the contents of the document at hand in the assumption that it is of the language specified. The selection of "XML" for example caters to the angle braces formatting of XML, etc.

Walloon

...is a language spoken in Belgium and I've heard it sort of described as the French that is spoken in Belgium as if it were a whole lot like the French language and very much the influence of French presence. A coworker mentioned today that Walloon is not supported by Microsoft but that one may run it as a culture in Firefox to test the boundaries of what happens when a culture cannot be found when testing against Microsoft stuff (C#).

The contract name 'Foo.Bar.Baz' could not be found in the list of contracts implemented by the service 'Baz'.

When I hit this error in attempting to view an .svc endpoint in a browser, it turned out it was because this binding in the Web.config was messed up:

<endpoint binding="wsHttpBinding" bindingConfiguration="Binding" contract="Foo.Bar.Baz" />

 
 

I was not specifying the interface. I was missing the I in the name. The appropriate replacement was:

<endpoint binding="wsHttpBinding" bindingConfiguration="Binding" contract="Foo.Bar.IBaz" />

Microsoft is to give Windows 10 both Internet Explorer 11 and a new browser called Spartan.

Spartan will be vaguely like Chrome and Firefox per this.

modern day (as of Saint Patrick's Day of 2015) SignalR with OWIN

I set up a SignalR "Hello World" application today, and I could only partially use my old notes as a lot has changed in the second version. I started by making an ASP.NET MVC application in Visual Studio 2013, and then, as detailed here, I had to create an OWIN startup class like so;

using Experiment.Signaling;
using Microsoft.AspNet.SignalR;
using Microsoft.Owin;
using Owin;
[assembly: OwinStartup(typeof(Experiment.Startup))]
namespace Experiment
{
   public partial class Startup
   {
      public void Configuration(IAppBuilder app)
      {
         app.MapSignalR(new HubConfiguration());
         app.MapSignalR<AuthorConnection>("/author");
      }
   }
}

 
 

Alright, one needs an implementation of PersistentConnection too and mine looks like this:

using System.Threading.Tasks;
using Microsoft.AspNet.SignalR;
namespace Experiment.Signaling
{
   public class AuthorConnection : PersistentConnection
   {
      protected override Task OnReceived(IRequest request, string connectionId,
            string data)
      {
         return Connection.Broadcast(data);
      }
   }
}

 
 

The rest of the magic happens in JavaScript inside of the view the application first serves up which looks like this:

@{
   Layout = null;
}
<!DOCTYPE html>
<html>
   <head>
      <meta charset="utf-8" />
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Experiment</title>
   </head>
   <body>
      <h1>Let's all write a story together...</h1>
      <table>
         <tr>
            <td valign="top">
               <div id="story" style="width:500px; height: 500px;
                     background-color: #00CC00; overflow-y: scroll;">
                  <span style="color:#FFFFFF;">Once upon a time...</span>
               </div>
               <table>
                  <tr>
                     <td nowrap>...and then</td>
                     <td><input type="text" id="contribution" style="width: 400px;" /></td>
                  </tr>
                  <tr>
                     <td></td>
                     <td align="right"><button id="button">Go</button></td>
                  </tr>
               </table>
            </td>
            <td valign="top">
               fun, fun!
            </td>
         </tr>
      </table>
      <script type="text/javascript" src="~/Scripts/jquery-1.10.2.min.js"></script>
      <script type="text/javascript" src="~/Scripts/jquery.signalR-2.2.0.min.js"></script>
      <script type="text/javascript">
         $(function () {
            var conn = $.connection("/author");
            $("#button").click(function () {
               var contribution = $("#contribution").val();
               conn.send(contribution);
               $("#contribution").val("");
            });
            conn.received(function (data) {
               $("#story").append(" " + data + "...");
            });
            conn.start().done(function() {
               if (conn.eventSource) {
                  conn.eventSource.addEventListener('message', function(event) {
                     console.log("EventSource message: " + event.data);
                  });
               }
            });
         });
      </script>
   </body>
</html>

 
 

This all works! Different browsers may both push copy (that all that are listening may see) into the big square green divs seen here:

Addendum 3/18/2015: I should say "one needs an inheritance of PersistentConnection" not "one needs an implementation of PersistentConnection" as one inheritances a class and implements an interface.

I like the Revisions tab in newest Rally interface.

I am noticing the "Revisions" tab in the current Rally Interface at a given story or defect. Just as there is a Details tab showing the specs for the story/defect and a Tasks tab showing a list of tasks, there too is a Revisions tab with a history of revisions for the stuff at the Details tab. At @hand we were using Fogbugz instead of Rally and one thing I preferred about it was that the story/defect details were all presented in a sequential blogesque format of a history of additions and alterations. I found Fogbugz superior to Rally in that regard. The Revisions tab sort of compensates. I don't know if this feature has been in Rally all year and I'm just now noticing as of the revamped interface, but I like that it is there and that I've found it.

Monday, March 16, 2015

P2PE is Point to Point Encryption.

It and E2EE (End to End Encryption) detail processes in which data, perhaps financial data, goes from point A to point B while consistently being secure. In E2EE one is just going from one end to the other and in P2PE data is decrypted along a series of stops before the last train station. P2PE is more secure than the "Chip and PIN" or EMV approaches to communicating data by swiping a physical card. P2PE is a PCI solution. Some links:

.Default and .UTF8 are options off of System.Text.Encoding in C#.

The second will allow one to encode and decode special characters such as Chinese characters. I experimented with this today. I went to Google Translate and typed in "Hello World" and got the Chinese characters for "Hello World" and experimented with encoding and decoding them. With the default setting the characters just come back out of encoding as question marks.

If you backspace erase everything between two dots in a C# dot dot dot progression and then press Ctrl-Space...

...Visual Studio 2013 will present you with a list of viable options for a replacement.

I like that we mention Rally story numbers and defect numbers in our standups where I work.

I had a formal training on Scrum at FramesDirect in which we were explicitly told not to rattle off esoteric encodings that no one can follow (story numbers) in a standup as no one can follow what you are talking about. This isn't really true if you mention the number and then explain what it is and I think it does help out in talking about the story. If not everyone in the standup, a few others will recognize the story by its "name" as especially so if you follow it up with an explanation of what it is for the rest of the room. With the convention of cares about the numbers and emphasis on them comes, in my opinion, an easier time in using both Rally and source control.

Saturday, March 14, 2015

optional settings in XSDs

If Foo and Bar are mandatory here...

<xs:sequence>
   <xs:element name="Foo" type="xs:string" />
   <xs:element name="Bar" type="xs:decimal" />
</xs:sequence>

 
 

...then herein there is a switch up in which one may either use Bar or Baz and one must specify one or the other.

<xs:sequence>
   <xs:element name="Foo" type="xs:string" />
   <xs:choice>
      <xs:element name="Bar" type="xs:decimal" />
      <xs:element name="Baz" type="xs:string" />
   </xs:choice>
</xs:sequence>

 
 

 
 

Here, Bar is back to being a must-have and Baz is optional standalone.

<xs:sequence>
   <xs:element name="Foo" type="xs:string" />
   <xs:element name="Bar" type="xs:decimal" />
   <xs:element name="Baz" type="xs:string" minOccurs="0" />
</xs:sequence>

Virtual Venture

I don't mean venture capitalism that isn't real. I mean venture capitalism for virtual reality. It's spiking. I got my haircut at a Supercuts today and while I waited in the lobby I found the February 2015 issue of Wired Magazine at the magazine rack and in the midst of an article on Microsoft CEO Satya Nadella there was this chart!

I read recently that we are going into a venture capital bubble anew as the American economy improves. One fortunate thing that this article suggested was that only about a quarter of the stupid was being pumped into tech companies this time (in contrast to the bubble at the turn of the millennium) and that pharmaceutical musings were instead all the rage. Hopefully when the bubble pops the tech sector won't be as destroyed as it was at the end of the rave era. Happy Pi Day everyone!

Thursday, March 12, 2015

The request matched a wildcard mime map. The request is mapped to the static file handler. If there were different pre-conditions, the request will map to a different handler.

To get around seeing this error when visiting an .aspx web page a ASP.NET 3.5 web site at Windows Server 2012 R2...

  1. run Command Prompt as Administrator
  2. navigate to C:\Windows\Microsoft.NET\Framework64\v2.0.50727\
  3. run "aspnet_regiis -ir" to register the 2.0/3.5 stuff which is not yet registered

Turn on .NET Framework 3.5 at Windows Server 2012 R2.

In the "Server Manager" (you get there with that icon of a tower with a toolbox in front of it just right of the "start menu" icon) pick "Add Roles and Features" below the "Manage" menu at the upper right. Step through the wizard. At "Features" there is a checkbox for ".NET Framework 3.5 Features" ...and unfortunately here you may see an error stating:

Do you need to specify an alternate source path? One or more installation selections are missing source files on the destination server. The server will try to get missing source files from Windows Update, or from a location that is specified by Group Policy. You can also click the "Specify an alternate source path" link on this page to provide a valid location for the source files.

 
 

...followed by an error stating:

Installation of one or more roles, role services, or features failed. The source files could not be found. Try installing the roles, role services or features again in a new Add Roles and Features Wizard session, and on the Confirmation page of the wizard, click "Specify an alternate source path" to specify a valid location of the source files that are required for the installation. The location must be accessible by the computer account of the destination server.

 
 

It turns out you cannot just fix this by attempting to download and install and executable for the 3.5 Framework from http://www.microsoft.com/en-us/download/details.aspx?id=25150, but instead: In VMWare click the "Show or hide console view" icon then the "Edit virtual machine settings" link then "CD/DVD (SATA)" and finally "Use ISO image file:" set the .iso that created the VM's OS as searchable from a drive, for example the X drive. Type "mmc" at the search to get the "Console1" window. Go to "Add/Remove Snap-in..." at the "File" menu and pick "Group Policy Object Editor" which will put "Local Computer Policy" back in the main pane which will expand to show "Computer Configuration" which will expand to show "Administrative Templates" which will expand to show "System." "System" has within it "Specify settings for optional component installation and component repair" which needs to be doubled-clicked up to bring up a dialog box where the "Enabled" radio button needs to be checked. On the other side of this open PowerShell as Administrator and type "gpupdate /force" to rollout the "Enabled" state. When you walk back through the wizard again, you will need to specify a route to X:\sources\sxs wherein the X is the drive you specified.

The extension is not listed in the Visual Studio Gallery.

Alright, I see this error when I try to pull PostSharp out of my company's in-house Nuget repository and build with it in Visual Studio 2013, as I end up seeing a wizard for PostSharp materialize and when I next-next-next through the wizard I end up seeing "The extension is not listed in the Visual Studio Gallery." at the very end. This suggested that I need "VS extension build 3.1.43" even though I am attempting to use version 3.1.49! Attempting to go forward I found this which suggested that I go to "Extensions and Updates..." beneath "TOOLS" in Visual Studio and then search at the upper left, but that seemed to lead me to version 4.0.43 and I don't want an upgrade. Further Googling lead me to https://www.postsharp.net/downloads/postsharp-3.1/v3.1.43/PostSharp-3.1.43.vsix which lead me to bet there was a https://www.postsharp.net/downloads/postsharp-3.1/v3.1.49/PostSharp-3.1.49.vsix and I was right. I downed the .vsix from here and manually ran it and now the application builds just fine.

Monday, March 9, 2015

PWXO

I am childishly fascinated with PWXO, the Macintosh icons for the Macintosh-friendly versions of Microsoft PowerPoint, Microsoft Word, Microsoft Excel, and Microsoft Outlook respectively, as seen here:

more on SignalR 2

Following up on this, I got explore a little more, but just a little more today. Right-click on your UI Project and pick "New Item..." beneath the "Add" menu. Add a new "OWIN Startup class" and change the name from Startup1.cs to just Startup.cs. For an MVC app, I found myself replacing an existing Startup.cs and I also found the need to make the new class a partial class.

 
 

app.MapSignalR();

...goes inside the Configuration method.

 
 

[assembly: OwinStartup(typeof(YourProjectNameHere.Startup))]

...is an attribute you'll see in Startup.cs which loops in your change

When doing a Find and Replace in Visual Studio 2013...

I recommend clicking the "Match case" icon as seen here:

In this situation, if you don't "Match case" then instances of MyRepository handed in at method signatures as variables dubbed myRepository are going to get convered from camel case to Pascal case. I recently made this mistake. Don't make it yourself. The compiler obviously doesn't catch this.

Sunday, March 8, 2015

make a Windows Service run nightly at a very specific time?

I told myself that there has to be an easier way to make a Windows Service periodically act than the solution here and I went Googling for it today where I found this which lead me to hope I could just put this in the App.config inside the configuration tag to run the contents of Service1's OnStart method once a minute...

<appSettings>
   <add key="Mode" value="Interval"/>
   <add key="IntervalMinutes" value="1"/>
</appSettings>

 
 

...but it didn't work. The same thing I found suggests the following as the way to make the service wake up at a particular time of day and then run for minute though I have not tried it.

<appSettings>
   <add key="Mode" value="Daily"/>
   <add key="IntervalMinutes" value="1"/>
   <add key="ScheduledTime" value="18:41"/>
</appSettings>

Saturday, March 7, 2015

Friday, March 6, 2015

NServiceBus can apparently use a database and not just MSMQ for it's queue.

Learned this today. Nice.

SignalR 2 needs OWIN and works differently.

I have to strip out...

RouteTable.Route.MapConnection<WhateverConnection>

...from Global.asax.cs it seems. This has more.

Turn SQL Server on and off in the name of experimenting.

Right-click on the SQL Server instance in Object Explorer and pick "Stop" or "Start" as applicable. I needed, in experimenting with this, the ability to simulate the database missing after Global.asax.cs had run as it sucked in from the database the credentials to get log4net working. Make sense?

I'm struggling to get a WCF web service with TransportWithMessageCredential to play nicely with SmartBear's SoapUI.

My WCF web service does work. I can spin up a dummy ASP.NET application that uses the web service just fine. I did get through a few hurdles. I guess I can document those. Pick "New SOAP Project" from the "File" menu to start up a new project. You will need to enter the value for "Initial WSDL" in the "New SOAP Project" dialog box which appears. If your .svc endpoint is at https://www.example.com/WebServices/ConnectivityTester.svc then https://www.example.com/WebServices/ConnectivityTester.svc?wsdl is what to give here. Notice that I've just appended ?wsdl on the end and nothing more. On the other side of the import I can expand "ConnectivityTester" (my web service) at the upper left to see "WSHttpBinding_IConnectivityTester" and that then expands to show "Test" which is the one method on the web service (should return true or false). "Test" moreover expands to show "Request 1" and double-clicking upon this opens up a "Request 1" window. From here I may click the green rightward pointing "Go" arrow at the upper left of the window to attempt to connect to the web service. At this point I get back:

The message could not be processed. This is most likely because the action 'http://tempuri.org/IConnectivityTester/Test' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding.

 
 

I tried to fight around this by:

  1. clicking on the Auth tab at the lower left of the "Request 1" window
  2. changing the "Authorization" dropdown to "Add New Authorization..."
  3. picking "Basic" from the "Type" dropdown in the "Add Authorization" pop up which appears
  4. pressing "OK" at the "Add Authorization" pop up
  5. entering my Username
  6. entering my Password
  7. checking the "Authenticate pre-emptively" radio button

...back at the selection of "Request 1" in the main window there is a list of properties at the lower left for "Request 1" (assuming "Request 1" is selected) and here I also changed the empty property for "WSS-Password Type" to "PasswordText" as well. And, yet, I have not progressed any farther.

 
 

Wait!

Since typing the above a coworker has solved the puzzle! OK, just set the username and password at the Properties pane above "WSS-Password Type" and don't worry about "Authenticate pre-emptively" at all. Instead of going to the "Auth" tab at the "Request 1" window, go to the "WS-A" tab and herein click the "Add default wsa:To" checkbox. The last thing that is needed is a change to Web.config itself.

<message clientCredentialType="UserName" />

 
 

...must become...

<message clientCredentialType="UserName" establishSecurityContext="false"/>

 
 

Yay! Now everything works! FYI: This false flag forces you to authenticate every time you hit the endpoint. Your valid identity will not be kept in session.

Thursday, March 5, 2015

Change what URL to an .svc endpoint is used by a reference to a WCF web service in Visual Studio 2013.

Right-click on the reference and pick "Configure Service Reference..." from the menu which appears. A dialog box full of settings will appear and the "Address:" will be the very first setting.

Wednesday, March 4, 2015

Do you want Google Chrome to save your password for this site?

If you are tired of seeing this over and over again, change the "Nope" dropdown to "Never for this site" when it next appears.

MD5 is still legit for hashing passwords.

You don't want to use it in an SSL cert though as someone could then masquerade as you.

How do I add the binding for an SSL certifiate to an IIS application?

You do it at the "Default Web Site" level.

When you ASP.NET application seems to loose the ability to find the .master page for your Default.aspx...

...or when you get the red and yellow screen of death over this bit of your Web.config file:

<authentication mode="Forms" />

 
 

...that's a good sign that you should have set things up as an application in IIS instead of a virtual directory.

Tuesday, March 3, 2015

SpiderOak

...is a rival to Dropbox. I learned of it just now in listening to Edward Snowden speak here. He suggests that even if SpiderOak was raided in a warrant that authorities would still need your private key, which SpiderOak iteself does not have, to decode your stuff.

keeping encryption safe (as can be expected)

Triple-DES and AES are symmetric encryption algorithms currently considered secure (as of this blog posting) while DES, RC2, and RC4 are examples of algorithms whose time has past. RSA, Elliptic Curve, and ElGamal are asymmetric approaches. ElGamal is often used in PGP. When I get a public key from a party asking me to send them information, how do I know the key does not come from someone sinister pretending to be the person I really want to talk to? Ways to manage public keys in asymmetric implementations include:

  1. public key infrastructure (most common, third party certificate authorities, godaddy.com and the like, verify the identities of parties advertising public keys)
  2. identity-based encryption (a user's email address or something similar is used as a public key, not too secure)
  3. web of trust (PGP approach, users verify the identity of other users and vouch for them)

allow pop ups in Google Chrome

Click the "Content settings..." button under advanced settings. You'll see a series of radio buttons appear in a modal and herein you should check: "Allow all sites to show pop-up"

sort a collection by a property in C# and also make the dropdown list column types in a DevExpress grid allow for sorting

This...

<dx:GridViewDataComboBoxColumn FieldName="Group.Description" VisibleIndex="4"
      Caption="Group">
   <PropertiesComboBox ValueField="GroupId" DataSourceID="GroupSource"
         TextField="Description" ValueType="System.String"
         DropDownStyle="DropDown" />
</dx:GridViewDataComboBoxColumn>

 
 

...had to be revamped like so:

<dx:GridViewDataComboBoxColumn FieldName="Group.GroupId" VisibleIndex="4"
      Caption="Group">
   <PropertiesComboBox ValueField="GroupId" DataSourceID="GroupSource"
         TextField="Description" ValueType="System.
Int32"
         DropDownStyle="DropDown" />
</dx:GridViewDataComboBoxColumn>

 
 

... making the FieldName match the ValueField. My superior ended up writing something like so to sort the contents of the dropdown alphabetically without the uppercase Z getting sorted first before the lowercase a:

public List<Group> GetGroups()
{
   using (IMyRepository myRepository = GetRepository())
   {
      List<Group> groups = myRepository.GetAllGroups();
      groups.Sort((g1, g2) => String.Compare(g1.Description, g2.Description,
            StringComparison.CurrentCultureIgnoreCase));
      return groups;
   }
}

test session timeouts easily by setting the timeout length to be one minute in duration

At the sessionState blob of Web.config change the timeout setting from a 15 to a 1.

Monday, March 2, 2015

Session.Abandon() in C#

Per this, Session.Clear(); removes everything from that dictionary you might access with Session["whatever"] while Session.Abandon(); apparently raises a Session_End request which does all that and more, potentially throwing an event for a request to another page as an error!

Visa straight through processing

STP allows a means for a major merchant to bypass a credit card processor and talk directly to Visa itself for credit card processing. This allows it to save on an interchange rate. Costco is switching to allowing its members to pay with Visa instead of American Express in the name of such a saving.

Concur

SAP SE (Systems, Applications & Products in Data Processing) has bought Concur, a SaaS in the sky (well, cloud) travel management company which is the biggest player in its space.

set up an SSL certificate at a web site in IIS

  1. double-click a .pfx to install it
  2. apply the cert in IIS
    • click on "Bindings..." with a web site selected in IIS to make a new https binding
    • click "Add..." at the "Site Bindings" dialog box
    • set the "Type" dropdown to "https" at the "Add Site Binding" dialog box
    • select the appropriate certificate at the "SSL certificate" dropdown

 
 

These links offer further reading:

challenges in getting a UserNamePasswordValidator implementation working for a WCF web service

I was seeing the following error when I tried to push code beyond my local environment for the UserNamePasswordValidator stuff I had written.

Cannot find the X.509 certificate using the following search criteria: StoreName 'My', StoreLocation 'LocalMachine', FindType 'FindBySubjectName', FindValue 'localhost'.

 
 

This stems from the following line of the Web.config which got put in Web.config for me (lucky me) when I added the WCF web service into a Visual Studio project in my local environment:

<serviceCertificate findValue="localhost" storeLocation="LocalMachine"
      storeName="My" x509FindType="FindBySubjectName" />

 
 

Alas, the thing that this references did not exist in other environments and hence this line of the Web.config had to be removed outright. The removal caused this error to appear instead:

The service certificate is not provided. Specify a service certificate in ServiceCredentials.

 
 

That meant that the following blob of Web.config would also have to be replaced:

<wsHttpBinding>
   <binding name="Binding">
      <security mode="Message">
         <message clientCredentialType="UserName" />
      </security>
   </binding>
</wsHttpBinding>

 
 

This substitute would allow for the error to go away when one hit the .svc endpoint at a browser...

<wsHttpBinding>
   <binding name="Binding">
      <security mode="None" />
   </binding>
</wsHttpBinding>

 
 

...but would not allow for the UserNamePasswordValidator sanity check to occur. The real fix looked like so:

<wsHttpBinding>
   <binding name="Binding">
      <security mode="TransportWithMessageCredential">
         <transport clientCredentialType="None" />
         <message clientCredentialType="UserName" />
      </security>
   </binding>
</wsHttpBinding>

 
 

...and it now requires an endpoint to be hosted at an https:// address! Once a certificate was set up at the hosting, I tried to consume the .svc endpoint at a dummy ASP.NET application I had, and hit an error proclaiming:

The security certificate was issued by a company you have not chosen to trust.

 
 

To trust a certificate in Internet Explorer on Windows 2012 R2, first go to "Internet Options" under the "Tools" menu and then navigate to the "Security" tab where you should add the site to "Trusted sites" for beginners. Next type "mmc" at the search field at the charm bar to bring up "Console1 - [Console Root]" and then add the "Certificates" snap-in while picking "Computer account" when faced with a choice between:

  1. My user account
  2. Service account
  3. Computer account

Finally, import a certificate. That should be all. If you see this error:

An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.

 
 

...or this error:

An error occurred when verifying security for the message.

 
 

It just means that you are trying to authenticate with credentials that won't work. I had a user that was jacked up when I saw this. I just made a new user to sidestep the problem.

examples of .Take and .TakeWhile in C#

Take is going to pull the first x number of items from a collection into a new collection. TakeWhile will start crawling forward in the collection looking for matches. Both of these tests pass:

using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Whatever.Tests
{
   [TestClass]
   public class UnitTests
   {
      [TestMethod]
      public void TakeTest()
      {
         string[] array = new string[] { "foo", "bar", "baz", "qux" };
         string concatenation = "";
         var taken = array.Take(2);
         foreach (string piece in taken) concatenation = concatenation + piece;
         Assert.AreEqual(concatenation, "foobar");
      }
      
      [TestMethod]
      public void TakeWhileTest()
      {
         string[] array = new string[] { "foo", "bar", "baz", "qux" };
         string concatenation = "";
         var taken = array.TakeWhile(item => item.Length < 4);
         foreach (string piece in taken) concatenation = concatenation + piece;
         Assert.AreEqual(concatenation, "foobarbazqux");
      }
   }
}

multidimensional and jagged arrays in C#

This suggests that the three varieties of C# arrays are single-dimensional, multidimensional, and jagged. I offers that the multidimensionals are made and used like so:

int[,] array = { { 1, 2, 3 }, { 4, 5, 6 } };
var foo = array[1,2];

 
 

...and the jagged like so:

int[][] array = new int[6][];
array[0] = new int[4] { 1, 2, 3, 4 };
var foo = array[0][1];

 
 

The distinction being that a multidimensional array is an array of arrays where every "child" array will have the same number of slots. An example, might be an array of 4 arrays of 3 slots each. The jagged arrays do not have this restraint on their kiddos.

Sunday, March 1, 2015

The carat operator in C# is going to resolve to true if one and only one condition is true!

For example, this test passes:

using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Whatever.Tests
{
   [TestClass]
   public class UnitTests
   {
      [TestMethod]
      public void Test()
      {
         bool foo = true;
         bool bar = true;
         bool baz = false;
         bool qux = false;
         Assert.AreEqual((foo ^ bar), false);
         Assert.AreEqual((foo ^ baz), true);
         Assert.AreEqual((baz ^ qux), false);
         Assert.AreEqual((foo ^ baz ^ qux), true);
         Assert.AreEqual((foo ^ bar ^ baz ^ qux), false);
      }
   }
}

 
 

This is one more thing I learned in the thousand page trip through C# 4.0 in a Nutshell by Joseph and Ben Albahari.