Saturday, August 31, 2013

I saw Mark Rosenberg speak on optimizing stored procedures this month at Austin Code Camp.

Things suggested by Mark Rosenberg:

  • Try to use table variables instead of temp tables. Table variables are just like other declared variables save that their type is TABLE. This has this example:
    DECLARE @ProductTotals TABLE
    {
       ProductID int,
       Revenue money
    }

    When you do encounter temp tables: Try to pull temp tables out of code into real tables, and/or make SQL make temp tables and then fill them instead of using a SELECT INTO approach for doing both acts at once.
  • When MSSQL Server runs a query it must first plan how to do so. The plan is called "query plan." It is stored within a stored procedure, but does not exist premade in dynamic SQL (SQL found inline in code and SQL which perhaps varies in shape from query to query based upon conditions in code). Since SQL Server 2000, if dynamic SQL of a particular shape is run enough times then its query plan will become stored, however as the query plan must be drummed up otherwise it is obvious that a stored procedure will perform better than a dynamic query holding the same query logic as it does not have to drum up a query plan on the fly.
  • Use SET NOCOUNT ON in a sproc to keep MSSQL from returning a count of records from a select statement. This will make a sproc faster. One does not have to call SET NOCOUNT OFF explicitly to achieve the opposite effect. The opposite effect, in which a count of records is returned, happens by default.
  • Using a qualified name for a table called in a sproc will make the sproc speedier as MSSQL Server will not have to figure out where to look.
  • If returning only a single record, just return the contents as output parameters while using the return value for an error code.
  • Don't start the name of a sproc with "sp_" underscore as Microsoft uses this convention for its own stored procedures and will crawl through its own stored procedures first in attempting to find your stored procedure should you use this convention.
  • Use sp_executesql instead of EXECUTE to run a stored procedure. This speaks to the difference.
  • sp stands for special object!
  • There is a distinction between data manipulation logic and data definition logic. The latter is of making and modifying tables and columns and the former is for operations against the tables and columns crafted in data definition logic. Do not put Data Definition Language (DDL) in a stored procedure.
  • Use WITH RECOMPILE in a stored procedure to escape using a query plan. There is a way to use SQL Server Profiler to view a list of stored procedures and see which ones are using query plans.
  • Use a WHERE clause before a HAVING clause to filter records before aggregation.
  • UNION has DISTINCT baked into it. Using UNION ALL instead will give you better performance as it does not come with this extra thing.
  • When matching on LIKE '%foo%' a query will have to look at every possible string value to parse every character inwards from the beginning in attempt to find "foo" somewhere downstream from the beginning. However, when matching on LIKE 'foo%' a query will only have to look at strings starting with the letter f. If possible, avoid the leading percent symbol in LIKE matching.
  • Mark suggested trying to get out of the pain of swapping between CREATE and ALTER when running stored procedure code by doing some if-exists sanity checking. This has some potential examples of that sort of thing.

I saw Matthew Groves speak on AOP at Austin Code Camp earlier this month.

PostSharp is one of the leading products (not free) in the AOP (Aspect-oriented programming) space and Matthew Groves is of PostSharp. Mr. Groves spoke on AOP in general and how it can get better with PostSharp. I'm going to focus this blog posting on AOP in general though. So what is it? It has to do with cross-cutting concerns, with code that comes up over and over again, generally in a comparable syntactical shape, which you wish you could somehow keep in just one place in the name of the Don't Repeat Yourself rule and also in an attempt to minimize the spaghetti mess logic of sprinkling it about everywhere. Scattering and tangling comes with the spaghetti. Fortunately, there are ways to tease the cross-cutting concerns out to their own isolated implementations. Some examples of cross-cutting concerns are:

  1. logging
  2. caching
  3. null checks
  4. defensive programming (sanity checks)

 
 

One may use the Castle library to augment StructureMap wire-ups at Global.asax with some extra logic which empowers the aspects (code run when a method in the interface associated with an AOP-augmented StructureMap Dependency Injection wire-up is called AND code run either before or after the meat of the method is run). This is an example:

x.ForRequestedType<IFileIoRepository>()
.TheDefaultIsConcreteType
<FileIoRepository>()
.EnrichWith(i => proxyGenerator
.CreateInterfaceProxyWithTarget
<IFileIoRepository>(i,
new LoggingInterceptor()));

 
 

The actual example that Matthew gave in his talk looked more like this:

x.ForRequestedType<IFileIoRepository>().TheDefaultIsConcreteType<FileIoRepository>()
.EnrichWith(i => proxyGenerator.CreateInterfaceProxyWithTargetInterface
<IFileIoRepository>(i, new LoggingInterceptor()));

 
 

But I couldn't get it to work. Visual Studio put the proverbial squiggly red line under IFileIoRepository in the last place it appeared and suggested:

The non-generic method 'Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithTargetInterface(System.Type, object, params Castle.Core.Interceptor.IInterceptor[])' cannot be used with type arguments

 
 

I eventually searched the web and found this which led me to the working implementation I offer first above. Anyways, LoggingInterceptor in my code is a class which I invented which implements IInterceptor and looks like so:

using AspectOriented.Core;
using Castle.Core.Interceptor;
using StructureMap;
namespace AspectOriented.UserInterface
{
   public class LoggingInterceptor : IInterceptor
   {
      public void Intercept(IInvocation invocation)
      {
         ILoggingRepository loggingRepository =
               ObjectFactory.GetInstance<ILoggingRepository>();
         loggingRepository.Log("starting");
         invocation.Proceed();
         loggingRepository.Log("all done");
      }
   }
}

 
 

You can see I am logging before and after invocation.Proceed() which runs the thing being wrapped by the AOP logic, in this case some File I/O stuff. In Matthew's code he was also setting invocation.ReturnValue before invocation.Proceed() and then retrieving its value afterwards. (His example had to do with caching.) Beyond this, I am assuming there is other magic one may do with invocation in this circumstance to tell what is about to happen and thus how to react and to indeed react. There is likely a way to sniff the method signature of the method being called, etc. Anyways, the way PostSharp differs is that it lets one decorate methods with attributes. One rolls their own attribute that inherits from MethodInterceptionAspect which is a PostSharp class. This keeps the Global.asax StructureMap stuff from doing more than just Dependency Injection. Mine for example now has some extra complexity.

using System;
using AspectOriented.Core;
using AspectOriented.Infrastructure;
using Castle.DynamicProxy;
using StructureMap;
namespace AspectOriented.UserInterface
{
   public class Global : System.Web.HttpApplication
   {
      protected void Application_Start(object sender, EventArgs e)
      {
         ObjectFactory.Initialize(x =>
         {
            var proxyGenerator = new ProxyGenerator();
            x.ForRequestedType<IFileIoRepository>()
                  .TheDefaultIsConcreteType<FileIoRepository>().EnrichWith(i =>
                  proxyGenerator.CreateInterfaceProxyWithTarget
                  <IFileIoRepository>(i, new LoggingInterceptor()));
            x.ForRequestedType<ILoggingRepository>()
                  .TheDefaultIsConcreteType<LoggingRepository>();
            x.ForRequestedType<ITimeRepository>()
                  .TheDefaultIsConcreteType<TimeRepository>();
         });
      }
   }
}

 
 

I saw John Crowe speak at Austin Code Camp too and he discouraged making a spaghetti mess inside one's Dependency Injection logic blob for associations. He didn't want extra concerns bleeding in here and thus I wonder if he would prefer the new PostSharp way of doing things to the Castle approach.

The I/O in File IO stands for Input/Output.

Word.

Thursday, August 29, 2013

How do I get to the command line in TortoiseHg Workbench?

abort: push creates new remote head 177db2f43b1d!
hint: did you forget to merge? use push -f to force

 
 

If you are seeing something like the above in TortoiseHg Workbench when you try to push up to a shelf, you will need to entertain the act suggested in this alert at the command line. This naturally, begs the question: "How do I get to the command line in TortoiseHg Workbench?" ...to which the answer is to go to the "Terminal" option under the "Repository" menu. Run this command to force a push:

hg push -f thenameofyourshelf

 
 

I think this may do the same thing while targeting a specific revision:

hg push -f thenameofyourshelf -r 4213

 
 

In figuring this out I visited:

Flash Security???

At the geek lunch today I met a guy who worked for Kantar Group who mentioned that Adobe Flash was still being used in his space (big scope marketing) because it allows for a piece of media to be protected such that it could only be viewed once. He wondered how the same thing might be accomplished in modern HTML5/JavaScript hybrid applications. Neither of us knew. I don't miss Flash at all. Let it die.

Google's Android Studio

...is for developing Android applications. It is a full IDE and it has either JetBrain's ReSharper or perhaps a knock off it (using the IntelliJ IDEA core of ReSharper) completely integrated. You may drag and drop controls to lay out a view not unlike using the Toolkit with web forms ASP.NET in Visual Studio!

second level cache in ORMs

This suggests that the second level cache in NHibernate is a bag of queried objects which may be requeried/reused at the C# side without a trip all the way back to the database! (The first level cache more mundanely holds a list of queries/transactions run that perhaps you do not want to rerun several times over.) The cache stuff can be a pain point as well as a blessing until you get used to it. You don't want to query the cache snapshot of an object you just updated for example. This gives more details on the second level cache for NHibernate's sister, Hibernate.

Wednesday, August 28, 2013

Dropbox's Datastore API

...is currently in beta and offers a place to store structured data (not files) for consumption by JavaScript. Transactions may be run against a data blob sucked down from Dropbox.

New Chrome Promises

Chrome is trying to incorporate promises into the Chrome browser itself and is doing it based upon the promises spec. (There is a formal promises spec somewhere. Is this it?) This will only be a browser thing and will only be for Chrome. Google is to speak to other browser providers about moving promise capabilities to be of the browser!

iBooks is Apple's Kindle-comparable thing.

Wikipedia says: iBooks is an e-book application by Apple Inc. for its iOS and OS X operating systems and devices. It was announced in conjunction with the iPad on January 27, 2010...

Better tabs for IE?

Clover is a rip off of Google Chrome's tabbing features for Internet Explorer.

Frozen/disabled buttons in iPhoneland?

Sure why not. It isn't necessarily a don't. There are plenty of places in an iPhone's settings menu where an on/off toggle can grey-out a bunch of controls which are otherwise touchable buttons. An interface which has a disabled submit button which unlocks (opens up to be colorful/clickable) when all of a form's fields are finally completely properly is not out of bounds. We just had a big conversation about this at work. Oh mobile devices, why are you so intriguing?

GAC policy files allow one to point/force a request for version X of a library to version Y of a library instead.

They are made in XML and the XML gets built into a .dll.

Ctrl-Shift-T will reopen the last tab closed in Google Chrome!

Nice. (You can sort of walk backwards through a history the same way you might with Ctrl-Z in an application.)

Flat user interfaces are coming!

There has been much talk at work about flat UIs and the skeuomorphic affordance they lack, and yet... they are trending it seems. jQuery Mobile 1.4 will be sort of flat. A coworker thinks the trend stems from a desire to reduce bandwidth by reducing images. There is less to load when your crutch is CSS.

WinSxS is Windows Side by Side Assembly Store.

The GAC is to CLR code what WinSxS is to unmanaged code, namely any code you might interact with from CLR code which does not itself compile to CLR such as:

  1. C++
  2. COM stuff

COM stands for Component Object Model.

It is a Microsoft binary standard for APIs invented in 1993. This is yet another thing I've learned from C# 4.0 in a Nutshell.

 
 

Addendum 11/1/2015: This stuff is of the PC's environment itself. When working in C# you are eventually going to need to do something at the PC level wherein you have to cross out of managed code into older gunk of unmanaged code that was never penned in CLR and I suspect the COM is the gateway in. I don't really know. This backs up that idea. Wikipedia says: COM and ActiveX components are run as native code on the user's machine, with no sandboxing.

New Zealand has done away with honoring software patents.

This was done in the name of reducing the costs of frivolous lawsuits. The nation got around being entrapped by preexisting agreements with other countries by not recognizing software as a unique invention!

Head First Design Patterns

...was recommended as a book today. It might go over some of the patterns I've learned and some of the one's I'd like to understand better. So far I get:

  1. decorator
  2. observer
  3. visitor

System.Web.HttpContext.Current.Cache.Add allows one to add something to a cache in ASP.NET.

I am preparing for a blog posting on the AOP talk I saw Matthew Groves give at Austin Code Camp. I took some photos of the code he projected with my phone and I hoped to recreate the System.Web.HttpContext.Current.Cache.Add example he gave, but:

  1. I'm missing some of the details.
  2. The caching isn't really crucial to the concept of AOP. (This is an example of one of many cross-cutting concerns.)

I've not done caching of this shape before. There is a way to do it.

Addendum 6/24/2014: I've figured out the cache! See: this

Tuesday, August 27, 2013

when not to go to the web

I made a goofy one page web forms application for writing copy to text files which looks like so:

 
 

You will notice that I just have a path to a file in a regular input field in lieu of using a file type input field. That is done because of this "problem." Either way, the interface doesn't really make sense in a web context because I am altering a file and not uploading a file. In using this interface via a web browser one would have to know the path to the file at the sever to edit it and the browser is thus rather useless without having access to the server itself. An application that just manipulates flat files should probably be made in WinForms and just run at the appropriate environment. My markup:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
      Inherits="AspectOriented.UserInterface.Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
   <head runat="server">
      <title>Write to a .txt file...</title>
   </head>
   <body>
      <form id="form1" runat="server">
         <asp:Label ID="Label1" runat="server" Text="Complete:"></asp:Label>
         <div style="padding: 30px 10px 10px 10px;">
            Write to this .txt file:
            <asp:TextBox ID="TextBox1" runat="server" Text="C:\Tom.txt"></asp:TextBox>
         </div>
         ...this copy:
         <asp:TextBox ID="TextBox2" runat="server" TextMode="MultiLine">
               </asp:TextBox>
         <asp:button runat="server" text="Submit" OnClick="Unnamed1_Click" />
      </form>
   </body>
</html>

In HTML, file type inputs will not expose full paths to the files they select in modern browsers.

They will just give you the name of the file (for example when you use a FileUpload web forms control in ASP.NET). You may see some JavaScript hacks like this one floating about the web for working around this "problem" ...but this too is coming to an end. These hacks won't work in modern Google Chrome. Don't spend time trying to fight around this circumstance. A file input field should not expose the path to the file selected by it.

Monday, August 26, 2013

Organizations in Oracle's eBusiness Suite

...define the scope of everything else. You may change the organization at hand in Oracle Asset Management from the dropdown at the upper right. Any work orders or assets you see, edit, find in a search, etc., are going to be of the organization within the dropdown. Objects will not reference each other across the bounds of two separate organizations.

Sunday, August 25, 2013

of handing in delegates to APIs

Chapter 25 of C# in a Nutshell is basically on interfacing with C++ from C#, and it really isn't that interesting. However!, there is an example in which a C++ method signature takes in a C# delegate which I found fascinating. Not caring too much about C++, I imagined how a C# library might consume a Func from another outside C# method in a different library that might use the API taking the Func.

using System;
namespace Whatever.Core
{
   public static class Api
   {
      public static int AddThreeNumbers(Func<int> middleAct)
      {
         int counter = 0;
         counter = counter + 1;
         counter = counter + middleAct();
         counter = counter + 2;
         return counter;
      }
   }
}

 
 

So, why hand in a Func? Can't the thing using the API do whatever it needs to do that is extra after the API call runs? Well, I can think of a few reasons for something like this. At work, we are struggling to find a way to swap the asset child of an asset with another child in Oracle's eBusiness Suite through the API it exposes. It looks like we will have to make one API call to drop an association and then another that makes a new association. Well, what if something goes wrong between the two? What should be done? We could have an API that leaves that to the caller. Perhaps the caller could hand in another method from the API to attempt to associate anew the dropped child. Perhaps the caller could just log the problem, handing in a method that is rolled in the caller's project. In an alternative scenario, what if the API takes in a list of T and it will "process" each T? At the end of each processing it could run a Func that was handed in. As much would extend its capabilities!

using System;
using Whatever.Core;
namespace Whatever.UserInterface.Objects
{
   public class ApiManipulator
   {
      public int Number { get; set; }
      
      public ApiManipulator()
      {
         Number = 0;
      }
      
      private int DoSomethingFunky()
      {
         return 10;
      }
      
      public void CallOutToAnotherProject()
      {
         Func<int> somethingFunky = DoSomethingFunky;
         Number = Api.AddThreeNumbers(somethingFunky);
      }
   }
}

 
 

I've been impressed with how Action types are used in the observer pattern, but otherwise I never saw why I should care about functional programming. I didn't see why I might use a Func and indeed it does seem that they should be used sparingly. "I get it" a little better now.

using Whatever.UserInterface.Objects;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Whatever.Tests
{
   [TestClass]
   public class Test
   {
      [TestMethod]
      public void TestApiWrapper()
      {
         ApiManipulator apiManipulator = new ApiManipulator();
         Assert.AreEqual(apiManipulator.Number, 0);
         apiManipulator.CallOutToAnotherProject();
         Assert.AreEqual(apiManipulator.Number, 13);
      }
   }
}

Saturday, August 24, 2013

Fix array sizes within unsafe C# methods?

There is a way to fix the size of an array at its declaration after all, but in involves the unsafe keyword and I cannot get an example to work. I read of this in C# 4.0 in a Nutshell.

using System.Runtime.InteropServices;
namespace Fun.Core
{
   [StructLayout (LayoutKind.Sequential)]
   unsafe struct Testing
   {
      public fixed float whatever [6];
   }
}

You have to use the unsafe keyword at a method signature to have a method wherein you use pointers in C#.

This touches upon it some and I've also just read about this some in C# 4.0 in a Nutshell. I don't find unsafe that interesting nor long to ever try it. I've managed to sneak into being a junior developer through the school of hard knocks instead of a bunch of formal training in C++. I just want to keep using C# like it is C#.

Thursday, August 22, 2013

We are using iconexperience.com icons at work.

Check them out! They are pretty fun.

Nginx is pronounced "Engine-X"

You run it on port 80 and it routes traffic to other ports. You could have a Node site running on one port and some Python code running at another port. The intent is to decouple web server and platform. That said this suggests bringing an ASP.NET solution into the mix might be a bit painful.

I learned this morning that one may import a solution into a solution within Visual Studio.

Add an existing solution in as you would an existing .csproj (project). When you are browsing for a file, just change the file type to .sln.

Wednesday, August 21, 2013

1969/03/17 13:23:45 is a date format friendly to both MSSQL and Oracle.

It is a good format to use when writing a query in code that could end up being run against either shape of database.

Fix the length of an array in C#.

This is good:

string[] tastes = new string[6];

 
 

This will not compile:

string[6] tastes;

 
 

By the way, yes, there are now six tastes as...

  1. sweet
  2. sour
  3. salty
  4. bitter

 
 

...has been expanded to:

  1. sweet
  2. sour
  3. salty
  4. bitter
  5. pungent
  6. astringent

 
 

...or maybe this has always been so in Indian culture and now it is creeping into the West and screwing up what I learned in public school. This makes me feel old. This tastes bitter, if you will, not unlike Lake Champlain becoming a sixth great lake. At least the seven fruits in Ms. Pac-Man will never change. I digress.

Dhall, Decorator, and Developers Hating Developers

I saw Chander Dhall of Ria Consulting speak at Austin Code Camp this weekend. The talk was titled "10 things every developer must know." I suppose I could give an ordered list of ten items in this blog postings, but I think I shall instead offer an unordered list of things I found interesting in the talk:

  • Chander stressed that developers hate each other. We do not get along and we do not want to have conversations with each other. We just want to hide beneath our headphones and stare into our monitors, or we see ourselves individually as rock stars as opposed to ourselves collectively as teammates. Team dynamics was stressed as the eleventh of Chander's ten items. Projects fail when team members do not get along. For example: The very first of Chander's list was on algorithms and he suggested that developers here especially should not try to come up with solutions in a vacuum. The mechanics of how to tackle algorithms should always be talked out by a team and not delegated to one individual. A complicated puzzle demands a discussion not a hero.
  • Shocker: For quick projects that have a scope of less than two months of time, a team may write code without tests that nonetheless is not buggy by following the principals in the book "Secure Code." Projects that do have longer lifetimes do demand testing.
  • Another shocker: Before you allow a user to do something big, force them to reauthenticate! This was encouraged as a security practice. CAPTCHA helps too and should be used in tandem with reauthentication but must not be seen as bulletproof.
  • A third shocker: Never write integration tests against an actual database. Use an in memory database if need be.
  • Do not let unit testing geek out beyond 85% coverage. 75% to 85% coverage is a good benchmark. When you start writing tests for third party libraries, something is wrong. Testing just the API integration points is sufficient and herein the unit tests also double as documentation.
  • Developers should know more than two languages.
  • Sanity check on all sides, both C# and JavaScript.
  • There are parts of the world where https security is just not supported.
  • The server should not know specifics about the client and the client should not know specifics about the server. Communication between the two should be stateless! Think of scalability.
  • Types of repositories: TFS is a centralized suite of tools, SVN is also centralized, and GIT is distributed.
  • Do not use ThoughtWorks' Go for continuous integration, but instead try: Visual Studio Team System, CruiseControl, TeamCity, Jenkins, or even SnappHQ.com which is currently free and allows one to deploy from development to production with one click.
  • Write .dlls as though they are not changeable.
  • Partial classes and extension methods are hacks not computer science. The decorator pattern is a better way to go when extending code...

Chander had some slides which showed off an implementation of the decorator pattern he made. Based upon these slides I made a one page web forms app that implemented a comparable pattern. The application puts three prices (double values) to labels.

  1. the price of a laptop
  2. the price of a laptop with a mouse
  3. the price of a laptop with both a mouse and a second monitor

 
 

In this example, laptop represents a product one might buy online and the mouse and second monitor represent accoutrements for the laptop. Mice and monitors aren’t really the best example for this. I think Chander used a microphone as one of the appended extra features in his example, but, whatever, let’s pretend for this example that one would only buy a mouse or a second monitor as an extension of a laptop. My code looks like this:

using System;
using Decorate.Core;
using Decorate.Core.AddOns;
namespace Decorate.UserInterface
{
   public partial class Default : System.Web.UI.Page
   {
      protected void Page_Load(object sender, EventArgs e)
      {
         Laptop laptop = new Laptop();
         Label1.Text = laptop.Price.ToString();
         
         Mouse laptopWithMouse = new Mouse(laptop);
         Label2.Text = laptopWithMouse.Price.ToString();
         
         Monitor laptopWithMouseAndSecondMonitor = new Monitor(laptopWithMouse);
         Label3.Text = laptopWithMouseAndSecondMonitor.Price.ToString();
      }
   }
}

 
 

Alright, in order to make the price grow progressively we are handing the laptop into the first additional item and then handing the first additional item into the second additional item. The laptop and the two additional items all have a getsetter for Price which is growing in value progressively. How is this magic possible? The answer: Mouse and Monitor are grandchildren of Laptop which holds the Price getsetter. A middleman between Laptop and a grandchild of Laptop empowers the ability to progressively boost Price.

  1. Label1 ends up with 699.99 in it.
  2. Label2 ends up with 713.54 in it.
  3. Label3 ends up with 863.53 in it.

 
 

The laptop itself is rather plain Jane. There is a virtual field.

namespace Decorate.Core
{
   public class Laptop
   {
      public virtual double Price { get; set; }
      
      public Laptop()
      {
         Price = 699.99;
      }
   }
}

 
 

The middleman inheriting from Laptop while also holding a getsetter for another Laptop is pretty amazing. Can you see how it does its trick?

namespace Decorate.Core
{
   public abstract class AddOnDecorator : Laptop
   {
      protected Laptop _laptop;
      
      protected AddOnDecorator(Laptop laptop)
      {
         _laptop = laptop;
      }
      
      public override double Price
      {
         get
         {
            return base.Price + _laptop.Price;
         }
         set
         {
            base.Price = value;
         }
      }
   }
}

 
 

The children of the middleman are:

  • namespace Decorate.Core.AddOns
    {
       public class Mouse : AddOnDecorator
       {
          public Mouse(Laptop laptop) : base(laptop)
          {
             base.Price = 13.55;
          }
       }
    }
     
  • namespace Decorate.Core.AddOns
    {
       public class Monitor : AddOnDecorator
       {
          public Monitor(Laptop laptop) : base(laptop)
          {
             base.Price = 149.99;
          }
       }
    }

 
 

Here are all of the players coming together in action one more time:

using Decorate.Core;
using Decorate.Core.AddOns;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Decorate.Tests
{
   [TestClass]
   public class Tests
   {
      double laptopPrice = 699.99;
      double mousePrice = 13.55;
      double monitorPrice = 149.99;
      
      [TestMethod]
      public void adding_mouse_then_monitor_to_laptop_behaves_as_expected()
      {
         Laptop laptop = new Laptop();
         Assert.AreEqual(laptop.Price, laptopPrice);
         Mouse laptopWithMouse = new Mouse(laptop);
         Assert.AreEqual(laptopWithMouse.Price, laptopPrice + mousePrice);
         Monitor laptopWithMouseAndSecondMonitor = new Monitor(laptopWithMouse);
         Assert.AreEqual(laptopWithMouseAndSecondMonitor.Price, laptopPrice +
               mousePrice + monitorPrice);
      }
      
      [TestMethod]
      public void adding_monitor_then_mouse_to_laptop_behaves_as_expected()
      {
         Laptop laptop = new Laptop();
         Assert.AreEqual(laptop.Price, laptopPrice);
         Monitor laptopWithSecondMonitor = new Monitor(laptop);
         Assert.AreEqual(laptopWithSecondMonitor.Price, laptopPrice + monitorPrice);
         Mouse laptopWithSecondMonitorAndMouse = new
               Mouse(laptopWithSecondMonitor);
         Assert.AreEqual(laptopWithSecondMonitorAndMouse.Price, laptopPrice +
               monitorPrice + mousePrice);
      }
   }
}

 
 

Wait! I have more to say. I wrote the code above the day before this paragraph and in the time between I have had some time to chew on it and I see two things that could be better:

  1. The grandparental Laptop class may be subclassed by other product classes, allowing for many products to share the same potential for having the add-ons. I tested my theory by making a Dell child of Laptop. It behaves as I expected in code. I think an implementation like this is gravitating us closer to the code Chander showed off too.
    namespace Decorate.Core.Laptops
    {
       public class Dell : Laptop
       {
          public Dell()
          {
             Price = 599.99;
          }
       }
    }
     
  2. My mouse and monitor example is really terrible. Wireless cards and USB ports might be better examples of decorations for a decoration pattern example which should probably be exclusively of composition not aggregation. Chander stressed in his talk to understand the difference between aggregation and composition. In aggregation an item has a collection of things which could exist independent of the item (a cat has n kittens) while in composition lies a deeper dependency wherein there is no parental independence (a cat has n colors).

Tuesday, August 20, 2013

SqlParameters should be called differently considering whether or not one is talking to MSSQL or Oracle.

The @ (at symbol) in an MSSQL SqlParameter should be a : (colon) in a Oracle-friendly SqlParameter. It is important to hand in types that are not strings as SqlParameters when writing code that could swap between both Oracle and MSSQL. Let a adapter talking to the database string encode a DateTime for instance, do not try to be too smart and do this yourself.

I learned today that there is now a way to shim other libraries as if they were AMD modules in requirejs.

At work we were apparently wrapping a call to Underscore.js in an AMD module to make it AMD-friendly. Then we moved away from as much given that is no longer needed. This has the following example of prepping the shims in a .config file:

shim: {
   'libs/jquery': {
      exports: '$'
   },
   'libs/underscore': {
      exports: '_'
   },
   'libs/backbone': {
      deps: ['libs/underscore', 'libs/jquery'],
      exports: 'Backbone'
   }
}

 
 

THINK you may hand in the exports values to a define as you would routes to modules... have not yet tried it firsthand...

Run all unit tests in a ASP.NET solution in Visual Studio with MSTest!

  • At VS2012: Test > Run > All Tests
  • At VS2010: Test > Run > All Tests in Solution
Remember: You must explicitly create a test project as a test project if you wish to use MSTest with it.

Monday, August 19, 2013

BACKBONECONF!

Check it out... some videos on Backbone

Regarding the icons by the clock at the lower right of Windows 7's start bar...

...when these are tucked away into a menu together one may click on the upwards pointing arrow and get some further details on how they are collected by pressing the "Customize..." link from the menu which appears. This link opens what one would find at "Notification Area Icons" at the Control Panel. It is important to note the location within the Control Panel because if you check the checkbox for "Always show all icons and notifications on the taskbar" here you will not be able to uncheck this checkbox without going back into this pane through the Control Panel. There will not be a way back in through the start bar. If you do check this checkbox, all of the icons that were tucked away in the fly-out menu will now be shown in a straight line at the start bar.

Sunday, August 18, 2013

I caught the end of a talk by John Crowe on Inversion of Control at Austin Code Camp.

I ducked out of Eric Lawrence's Fiddler talk yesterday at Code Camp early and found Mr. Crowe's talk instead. It was called "Effective IoC with Dependency Injection." By the time I walked into the room he was wrapping up and taking questions. He had a slide up on service locator and I asked when one would want to use service locator in lieu of dependency injection. His answer boiled down to: "Never!" Service locator makes it harder to run tests as one will have to fabricate an IoC container inside of the tests. If you ever abandon service locator for dependency injection you will have a lot of work to do in the name of replacing all the service locator calls sprinkled throughout your code. Someone in the audience asked about the performance hit one takes with IoC tools and John asserted that is wasn't worth worrying about. If you are interacting with a database, you might as well worry about your performance problems there. Eric Hexter mentioned that there was an article by Dan Holme from 2011 which listed some IoC tools and rated them on performance. I tried to find it online for this blog posting but I couldn't. John said that one should keep the wire up for dependency injection in Global.asax.cs (or wherever it may be) simple and clean. There should not be other code bleeding in here. Jeffrey Palermo suggested that he views the code here as just another global variable or singleton and encouraged not trying to make it something more. In an earlier session on AOP by Matthew D Groves, both Castle and PostSharp were brought up as potential AOP tools. Castle relies on appending AOP conditions to mappings at StructureMap's configurations for dependency injection where PostSharp does not. I wonder if John would thus find PostSharp "better" in regards to not polluting IoC mappings. I tried to take a photo of John during his talk, but the pictures I took all came out bad. (He had the lights dimmed in the room to project.) I ultimately stole this picture of him at the day's end in the parking lot of the Echelon center (where Saint Edwards has its North campus) after Code Camp let out. It's cool that his shadow is Nosferatuesque.

Service locator is scary.

I saw the majority of a talk by Eric Lawrence, creator of Fiddler, on Fiddler at Austin Code Camp.

"All problems in computer science can be solved by another level of indirection."
- David Wheeler

Well, with that is mind Mr. Lawrence gave us Fiddler, now owned by Telerik, which is a proxy that http traffic (requests to and stuff being returned from the world beyond one's browser) bottleneck through. Fiddler has come up in talks by both Shawn Weisfeld and Ryan Vice on ASP.NET Web API, and I have certainly used it some myself in trying to understand ASP.NET Web API. The meaty meat of this talk was on how to use Fiddler to juggle huge amounts of traffic without having what is reported back by Fiddler become just noise. I have largely worked around this problem myself by just opening Fiddler just before I use it and then closing out the one browser I have open after Fiddler sniffs whatever act I hope it will sniff so that more activity does not build up in its reporting. I thus won't go into the management tricks for heavy use stuff, however other things touched upon of interest were:

  • Fiddler may be chained to another proxy upstream of it so if your company requires that you bottleneck through a different proxy to get out into the wild, this does not mean Fiddler is out as an option.
  • Fiddler may be used as a reverse proxy! If you run a web site on a random port such as port 81 and then send web traffic to Fiddler on port 80, you may then route the port 80 pings into port 81 from wherein a signal back may roundtrip back through Fiddler.
  • Telerik is working on making a Mac-friendly version of Fiddler.
  • FiddlerHook is a Firefox plugin that will let you toggle Fiddler on and off. It ended up both installed and disabled when I installed Fiddler itself. To use the plugin you just have to enable it.
  • SPDY/HTTP 2.0 or "Speedy" uses binary transfer of data (not plain text ASCII) and is a new hypertext transfer protocol. Internet Explorer 11, coming at year's end with Windows 8.1, will support it and the latest versions of Chrome and Firefox already support it. Fiddler is ready for this. Bring it.
  • Charles is a rival to Fiddler.
  • Regarding the interface: In Fiddler, clicking in the black bar (or pressing Alt+Q to get there) gives one a spot to type in command line commands. Also, the "Stream" button may be toggled on and off. When it is on there will be no buffering (Fiddler otherwise catches and then rethrows) and this setting is much more friendly to SignalR than the alternative.

I saw Amir Rajan speak on various JavaScript approaches to MVC at Austin Code Camp.

I went to Austin Code Camp (put on by the Austin .NET Users Group) yesterday and saw five talks and parts of two others. I'll make blog postings for all seven. First up, this particular talk by Amir Rajan, was on a smattering of different possibilities in jsland. He experimented briefly yet significantly with many tools. All "MVC" tools were analyzed in tandem with use in ASP.NET MVC. (jQuery isn't an MVC tool in its own right for example.) His feedback:
 

  • jQuery
    • mantra: spaghetti code!
    • speed: fastest

     
  • Backbone.js
    • mantra: event-driven
    • speed: second fastest
    • go further with: Marionette (for routing)
    • If you know jQuery already, picking up Backbone should be pretty painless. This is a library more than a framework and it has a dependency on Underscore.js. One uses templates with Backbone.

     
  • Knockout
    • mantra: like Silverlight (the good parts)
    • go further with: Durandal (uses RequireJS... not django.js)
    • This tool too is more like just a library than a toolkit/solution. All JSON objects must be cast to ko.observable objects to work with them in Knockout and that is its biggest pain point. It only works in newer browsers.

     
  • AngularJS
    • speed: slowest
    • mantra: redefining what HTML is to developers
    • go further with: AngularUI
    • <input onenter="act();" id="foo" /> is an example of something you may have in AngularJS. You may define your own events such as onenter in this manner. Note we are not using the data- HTML5 convention here. Instead, Angular redefines HTML. This only works in modern browsers and has MVVM capabilities. There is a terrible performance hit in Internet Explorer 9. Use ng-repeat for looping in Angular.

     
  • Kendo UI
    • This came up by way of someone in the room asking about it. Amir had not used it and punted by bringing up a web site that had more about Kendo UI. It was a GitHub site. I did not record in my notes where he took us and what he meant to convey. (Forgive me, this was the last talk of the day and I was starting to fade.) In Googling, I can tell that there are GitHub projects of using Angular and Kendo UI in tandem.

     
  • Ember.js
    • mantra: We are moving all aspects of MVC to the frontend.
    • This is the REALLY deep end of the pool. It has the hardest learning curve and the "most bang for the buck" (Amir's words). You have to use mustache templates with Ember so you have to learn mustache.js as well in learning Ember.

     
  • Sencha Ext JS
    • has a $595 price tag!

     
  • Dojo
    • not mentioned at all!

I have been using the ScreenHunter 6.0 Pro of Wisdom software for screen-scraping my own blog.

Get it here. It will scroll the scrollbar on a web page downwards until it can't and put everything it "sees" in one vertically-long .png. I am sure there are many tools just like this one. I found this one and it is good. I endorse it.

Saturday, August 17, 2013

OpenSpan

OpenSpan is an automation tool that has a Visioesque way to layout processes like SSIS but with this tool you can fill out a form on a web site, specifying which fields to put what in, and then get the response back. I'm at Austin Code Camp right now and this came up during a chat at lunch with another.

Friday, August 16, 2013

how transaction/rollback pain is handled in Oracle ERPland

Following this* my superior has looked into the two types of integration for remotely swapping assets...

  1. PL/SQL API
  2. Interface

...and has concluded that the PL/SQL API approach won't fly. Oracle has a concept of "save points" which are checkpoints to roll back to in the name of a failure. The save point for the asset API call is set in a different genealogy-related call that we don't want to use. That throws out that approach. I do not think we could turn the save point stuff off if we wanted to, but regardless there is a real need to have transaction safety with asset swapping, as asset swapping entails "unassigning" an asset and then assigning a new one, two acts. What if something goes wrong in-between?

*More on Oracle eBusiness Suite's Assets: The screen for managing assets is confusing. If an asset has an end date, it isn't really an asset, it is a historical note of an asset's now done history with the other asset it "sat within." Only assets without current end dates are really assigned to the assets they "sit at."

In the interface table approach, two records will be put in the table, one to update the asset being disassociated and one to add a new asset to the parental asset at hand. There is a column for denoting the update or insert act. The two records will be processed together by an "import process" and thus will succeed or fail together. However there isn't really any feedback to be had if the import process fails (no alert) and what is more I think the import process has to be run manually at eBusiness suite. I might be wrong about that and maybe there is a way to run it on a timer. It would be best if we could just force what is in the interface table to resolve right away. There may be an API call for that for assets. There is NOT a way to do this for other things such as inventory items.

Thursday, August 15, 2013

Remoting with MarshalByRefObject

It is possible to hand objects which inheirt from MarshalByRefObject in C# into an new AppDomain that is made and then destroyed in the current domain. This allows the objects to do their thing in a sandbox with memory and garbage collection independent of the default domain. This is called remoting and is the theme of chapter 24 of C# 4.0 in a Nutshell. I tried to create an example just now so I could show you some code but I couldn't get it working. Overall, I don't find this that interesting so I won't spend any more time on it.

.bat file for copying about .dll files

This lists "Macros for Build Commands and Properties" such as $(ProjectDir) seen here. The .bat script is going to have something like this inside of it:

set ProjectName=%1
set ProjectDir=%2
set TargetDir=%3
set TargetName=%4
echo WORKFLOW-POSTBUILD for %ProjectName%
xcopy %TargetDir%log4net.dll %ProjectDir%..\..\whatever\ /i /d /y
if errorlevel 1 goto BuildEventFailed
goto BuildEventOK
:BuildEventFailed
echo WORKFLOW-POSTBUILD for %ProjectName% FAILED
exit 1
:BuildEventOK
echo WORKFLOW-POSTBUILD for %ProjectName% SUCCEEDED

Another way to do ASP.NET web services: ServiceStack!

ServiceStack is a "A fast, unified and integrated replacement for WCF, WebAPI, and MVC" per its web site.

Google Glass

I saw Kyle Samani speak at AMPD last night on Google Glass. There are maybe ten thousand Google Glasses in circulation right now in advance of their official release likely before Christmas of this year. Google put these out in the wild to build excitement and of course in the name of testing. You can have one yourself via an eBay purchase for four to five thousand dollars. (Kyle guesses a Christmastime price would be around $266 as the devices cost $120 in materials and perhaps $160 when you add in shipping and other factors like that.) Kyle wore a pair during his presentation and in my photo of him (halfway down this blog posting) you can see the fatter of the two handles, the one that sits at your right as you wear the glasses. (One may swipe this with one's finger to scroll through a "Timeline" user interface which Kyle found to be a clumsy experience.)

Anyways, after Kyle finished speaking the kitschy cool (oxymoron?) toy was passed around the room. By dumb luck, I got it first. The individual sitting next to me, who must have been named Amber Lindholm given her name tag, asked that I take her photo within the glasses and it is above. Below, Amber takes the picture of "Gene" while he sports the specs and as you can see there is a line forming to play with the device. (The first individual in the line is a Tim Scott who I've met a few times before. He used to work in C# and is now in the Ruby space.) The man at the far left with his back to the camera is a David Vogel who was hosting AMPD (Austin Mobile Professional Developers).

This talk ended up being a series of bullet points on Google Glass. Yes, it comes with Google Now but, no, Google Googles were not baked in for some reason, etc. Kyle Samani is the founder and CEO of a medical software company called Pristine and is developing software for medical professionals who will wear the glasses, but his talk was lightweight on specifics. I eventually put my hand up and asked how a doctor would use the software and he told me he could not speak to the specifics. His investors have a gag on him it seems. He mentioned that security professionals could use the glasses to look through the eyes of security guards from an administrative role and I imagined that as much could be done in the medical field too. Then I thought of how recording via the glasses could get the costs of lawsuits down too. It was fun to guess at what Kyle was up to. Kyle mentioned that Telsa cars emit wireless signals exposing an API for metrics and that someone had made a silly app to see these metrics from Google Glasses. Maybe Kyle's software could get cues from machinery in an emergency room and relay alerts to a doctor who had both hands tied up. I'm just daydreaming at this point. The bullet points on Google Glasses in a more generic sense were:

  • There is a proximity sensor which can tell if you are taking the glasses on or off. It can tell if you tilt your head back thirty degrees and this is one way to activate the glasses. It can't tell where you are moving your eyes the way a Galaxy's camera might as an eyeball is a perfect sphere and you would need a camera watching the eyeball's iris for this. Such a feature is not rolled in as it would be energy consumption intensive. (There is one camera looking outward from the glasses however and one may take a photo by touching the glasses slightly.) The sensor can tell if you are winking or blinking. Kyle asked us to put our fingers to our temples and feel how little they moved when one blinked. He then had us wink and the effect, the amount to which you twitch and the crinkling of the skin, is noticeably more extreme. The differences between winking and blinking can be picked up by the proximity sensor and someone has written a tool called Winky for triggering wink event handler stuff.
  • There is no control over brightness, contrast, etc. with the camera.
  • The 640x320 (pixels) screen holds 40 to 50 words of text. Good UX entails white text on a black box. One cannot be looking at something and looking at the peripheral stuff broadcast by the glasses. You instead look away from what you are doing to use the glasses. Google glasses are not augmented reality eyewear in which the whole of one's eyes are obscured and one sees, for example, text about the person they are looking at through the glasses. That is a different thing and one loses the ability to communicate with others by way of the facial gestures the eyes afford in such a space. There are some other companies working on this stuff but not Google. The Google glasses don't have any facial recognition software and Google has blocked at least one attempt by a developer to offer such software for Google Glasses.
  • A light is visible to others when the screen is on.
  • Three to five hours of battery life are available, and it takes under an hour for the device to fully recharge.
  • A speaker at the back of the big handle feeds you audio. Passersby will be able to hear beeps but will not be able to really discern words.
  • The operating system was forked off of Android 4.0.4 (Ice Cream Sandwhich) and what is different is anyone's guess. 4.2.2 may be loaded on the device and the default fork has done some things to emulate some 4.2.2 stuff.
  • You may do things with voice commands. Programming to accommodate one word voice commands is ideal as there is no way to correct a mistake in a sentence. Every spoken word is thus a potential point of failure. Google is not making it easy for developers to create custom voice commands. Kyle implied that he persevered in this arena after much heartache.
  • There is going to be some GeoLocation stuff. When you pull into a McDonalds expect the glasses you are wearing to tell you of a special or a discount. Speaking of which, there has been some effort in West Virginia to ban Google Glasses from being worn while driving. Kyle defended the glasses by saying they were considerably safer than smartphones in the same circumstances. I suppose just as a cocaine addict might improve his lot slightly by becoming addicted to methadone instead, someone who texts and drives might become a slightly better bad driver by way of Google Glasses.
  • The initial setup is painful and involves scanning some QR codes.
  • For tethering (connecting one device to another) one may talk to an Android app called MyGlass at an Android smartphone. In the iPhone realm all one can do is expose a hotspot via the iPhone and use it from Google Glasses to jump to somewhere else.
  • Mirror is a RESTful API which allows you to push data in.
  • HUD projection is at the screen of which Wikipedia says: "A head-up display or heads-up display—also known as a HUD—is any transparent display that presents data without requiring users to look away from their usual viewpoints."
  • Warby Parker is to do prescription lenses for the glasses. If you are farsighted you will currently have a hard time reading the display.

Kyle stressed that he did not see a huge commercial market for Google Glass as getting Twitter feeds flashed to your eyeball is just an inferior experience to using a smart phone or tablet for the same thing. One has to be clever to make use of these accessories that make you look goofy when you are wearing them. It would seem that Mr. Samani sees a business model with return on investment in the medical space, but again, he is being tight-lipped about the specifics. Another difference between Joe Public and Joe Professional is that you can tell Joe Professional that he has to be wearing a cord to power the glasses under his clothes if he is going to wear them 8 hours a day, but that sort of thing doesn't play well with hobbyists at all. There apparently is company called PowerGlass which makes a headband that one wears in tandem with Google Glasses which holds a bunch of batteries and increases the life of Google Glasses significantly. Individuals who would wear such a headband are extreme geeks or dedicated professionals, not Joe Public.

Addendum 8/22/2013: I am noticing that big white spot in the midst of the photo above for the first time right now. It is pretty interesting how iPhones will miss a spot sometimes.

Wednesday, August 14, 2013

Remember to turn your microphone on when presenting over a Go To Meeting meeting.

Change to this setting when others start complaining that they can't hear you. :P

North Austin is where it is at not South Austin.

Austin of 2013, well at least its tech scene, is the bomb. Imagine the romanticism people have for the California of the 1960s that you never experienced. The same romanticism will exist a generation from now for 2013 Austin tech. I feel really lucky to be here. I would say caught a break in moving to the ATX from Florida at age 12, but the truth is that my mother worked for IBM and tech was moving here even back then in 1986's Texas oil crisis. We had to come. In growing up in Austin, I always lived North and was told that the South side of town was the cool part of the city where all the pierced people lived, but recently I lived and worked South and feel I can scoff at it. North Austin, centered around the Arboretum, is where all the tech stuff is. I may never get to date a girl with pink hair, but, more importantly, I have a cool job. I have, for three months now worked @hand and it is awesome!

If it seems like this is sixth place Tom Jaeschke has worked since leaving Headspring in March of 2011, your count is good, but I am going to stay at @hand for some time (years) so don't think this is temporary. :P I recently got a new apartment at Balconies Woods Apartments near the office. Here is a selfie I took in the new mirror before it got disgusting:

The apartment is nice on its own, but as fate would have it I comes with a couple of perks. Through dumb luck, I live below Matt Underwood and Katie Pennington who are my two favorite people at the Olive Garden at 183 and Burnet where I eat every day.

Also, I can bike to work. I write this blog posting as today was the first day I did a bike in and bike out. The map here shows the way to drive to work, but on bike, I can take Balconies Woods Eastward until it dead ends and then get onto the driveway for The Quarries Church which empties onto a feeder road for MoPac that will take me into the parking lot holding @hand's office. The red circle shows where I may move from Balcones Woods's dead end to the drive of The Quarries Church. This may only be done by foot or bike and not by car!

Note: I don't drink alcohol or go to church. Please don't read either of those things onto this blog posting. If the selfie makes me seem narcissistic, well, that part is real.

Addendum 5/2/2014: Well, I didn't stay at @hand for years after all. :( It was good to work with the people there however. I'd like to acknowledge them. Clockwise around the conference room table from where I am standing in making the Vine above are: Luis Sanchez, Bryant "Poff" Poffenberger, Brad Coffman, Jonathan McKinney, Bryan Harclerode, Chris Elgin, Ben Hynum, Andrew McClellan, Kelsey Mayfield, Max Magee, Mike Loos, and Stepan Riha. My immediate superior was Tim Trentham.

F5 versus Shift-F5 in PowerPoint

You may run a PowerPoint slide show out of PowerPoint's editor from the beginning by pressing F5. If you close the slide show presentation partway through but still have PowerPoint itself open, you may return to your spot with Shift-F5.

Mercurial is case insensitive.

This can cause some pain in a Windows environment wherein a folder is renamed from "foo" to "Foo" and Mercurial ends up with two folders. It is supposedly getting better about detecting a Windows environment and sidestepping some of these problems.

skeuomorphic affordance

skeuomorph derivative object that retains ornamental design cues to a structure that were necessary in the original
   
affordance where an object's sensory characteristics intuitively imply its functionality and use
   
  These terms came up today in a discussion as to whether the flat theming of Twitter Bootstrap (or that of iOS7 or the Windows 8 look which was almost called Metro) is detrimental. It was argued that a skeuomorphic design in which buttons were slightly raised was superior, by carrying more affordance, to the new coolness of 2013.

jsduck custom tags are written in Ruby, not JavaScript!

You have to have a Ruby interpreter to include jsduck in a Grunt build. Whatever.

AngularJS does not use promises it uses "futures."

The futures may resolve in any particular order. AngularJS never used the promise spec.

two corrections

  • This isn't what I thought it was. I wasn't including a .dll as a reference. The .dll in question (Castle.Core.dll) was sitting in my bin folder and would "work" when run locally because it was only ever used by a different .dll, but did not end up copied elsewhere when I tried to publish my web app to a folder somewhere because it was not a reference. My problem didn't have to do with the GAC.
  • It was pointed out to me today that the reason I cannot send mail via code from outside of my own hosting here is because I am not authenticating. Duh.

Tuesday, August 13, 2013

When the Slides and Outline tabs appear to be hidden in Microsoft Outlook 2010...

...they are in fact just collasped all the way to the left. At the left edge of the application, there should be a border that you may drag back rightwards to reshow this content. This taught me as much.

phantom log4net logs and how to get rid of them

<file value="" />

...is a good thing to have in the log4net.config file if you are going to doctor up the value anyways in on the C# side like this. I ran into an issue in which I was specifying, on the C# side, a log name that fluctuated as part of the name was the current date. There was no way to specify an identical name at log4net.config and hence I just put in a random name. An empty file with the random name would then end up at either C:\Windows\SysWOW64\ or where I kept application.manifest. The cure is to use the setting above.

C:\Windows\SysWOW64\

...seems to be where a log4net log file will end up by default for a COM+ app if you do not set this stuff.

Monday, August 12, 2013

asset swapping in Oracle's eBusiness Suite's Asset Management web interface

  • Go to the "Assets" tab.
  • Search for an asset and find it.
  • Click the link in the "Asset Number" column to open it.
  • Change the "View" menu at the upper right to "Configuration History" and then click the "Go" button by it.

Here one may throw away a child asset (example: the engine within a tractor) that does not yet have an end date, by clicking on the pencil icon in the "Update" column and then checking the checkbox for "Return to Inventory" at the following screen (followed by clicking "Apply"). Using the "Associate Child" button at the list of child assets one may add a new child asset. Clicking "About this Page" here (a link that adorns the lower left of most pages where one may update inventory in Asset Management) one gets the "Page Definition" for this functionality which shows how the various controls work.

This touches on an interface-based API for this stuff while this touches on the INV_GENEALOGY_PUB public API which is going to be PL/SQL based. I don't understand either yet.

There are plenty of things one cannot do as sysadmin in Oracle eBusiness Suite's Asset Management.

The tabs seen here are going to show up for "regular" users and not the administrative superuser (sysadmin) as best as I can tell. There is likely a way to unlock this sort of functionality for sysadmin, but creating and updating records is not typically seen as of its pervue and thus those sort of capabilities are walled off from it.

types of integration in Oracle's eBusiness Suite

Oracle's eBusiness Suite was cobbled together by many different hands and there are numerous ways to undertake integration.

  • synchronous PL/SQL api calls is an example
  • another approach is to use the "open interface" which entails putting stuff into a database table called "interface" which will later get picked up by a process (a "concurrent program") and validated and then imported if validation goes well (If you log into Oracle E-Business Suite as the system administrator you should be able to pick "Integrated SOA Gateway" from the home page then Integration Repository from its submenu and then you should be able to get "a complete catalog of Oracle E-Business Suite's Business Service interfaces.")

also see: this

Browserify is the new RequireJS?

I heard of Browserify today which was portrayed as a better version of RequireJS.

create an Oracle support account

At https://support.oracle.com/ click the link for "New user? Register here" and create an account. Wait for an email confirmation while keeping the browser where you created the account open. The confirmation email should prompt you to visit a second web page in a second browser where you will need to confirm a few things. When you are finished, there should be a button at the first browser window to proceed. Do proceed. You will then be taken through a wizard where you must fill out three things.

  1. there will be a form for adding "Note to the Approver" which is silly and not required and "Support Identifier" which is a number which will allow Oracle to know what company you are with. You will need to be of a company that is an Oracle partner (I think) and you will need to enter a Support Identifier. Add the Support Identifier to the list of Support Identifiers, and then proceed forward in the wizard.
  2. update contact info yet again if desired (you may give a fax number here)
  3. check a checkbox to accept some terms-of-use legalize

You will get a second confirmation email after all of this at which point you are golden.

Friday, August 9, 2013

call id tags with a variable name in jQuery

The one line of code here may be altered like so without issue:

var foo = "foo";
$("#" + foo).animate({ backgroundColor: "#548d57" }, 0).animate({ backgroundColor:
      "#75b249" }, 900);

jquery.color.js

When you attempt to use /Scripts/jquery.color.js you may get an error in Visual Studio like this:

To suppress this message, disable the 'Warn if no code on launch' debugger option.

 
 

This checkbox is in Visual Studio 2012 at: Tools > Options > Debugging > General ...just uncheck it to make the error go away. With jquery.color.js you may get this to work which will otherwise not work (give no effect that one may observe):

$("#foo").animate({ backgroundColor: "#548d57" }, 0).animate({ backgroundColor: "#75b249" }, 900);

Thursday, August 8, 2013

Sort a List of T in C#. (hardcore version)

Note, that reversing a and b like so...

list.Sort((b, a) =>

...here will reverse the order. If FriendlyName held a string value for the names of the three (four) stooges, then then their names would end up sorted in a decending manner like so:

  1. Shemp
  2. Moe
  3. Larry
  4. Curly

 
 

However they would come out in the original example like this:

  1. Curly
  2. Larry
  3. Moe
  4. Shemp

 
 

Get it? If another sort statement came before the stooge sorting then the collection would primarily be sorted by FriendlyName and secondarily be sorted by the other item.

Sort a List of T in C#.

using System;
using System.Collections.Generic;
using AntMill.Core.Objects;
namespace AntMill.Core.Utilities
{
   public class DataTransferObjectSorter
   {
      public List<DataTransferObject> Sort(List<DataTransferObject> list)
      {
         list.Sort((a, b) => String.Compare(a.FriendlyName, b.FriendlyName));
         return list;
      }
   }
}

Now I really hate the GAC! If it contains a .dll you have as a dependency the .dll may not end up in your bin folder.

See: this!

 
 

Addendum 8/14/2013: This is questionable. See: this

display: inline-block;

...in CSS will make a div snug up around the text inside of it. Leave off a specification for width! Use white-space: nowrap; to keep text from wrapping.

margin: 0; and margin: 0px; are not the same

If you have the former on the html tag, body tag, and a div that wraps everything, you may then put margin-top: 20px; in a nested child div and you will end up putting 20 pixel of white space BEFORE (above) the outermost div wrapping everything. The effect somehow cascades up. I don't get it and I don't want to think about it right now. (I'm in a hackathon.) I am only using margin: 0; because it was in an example I found on the web for an iPhone-friendly HTML5 app. I am, as suggested here, putting this setting on both the outermost html css tag and the body tag.

use a view in another controller in ASP.NET MVC 4

...in this case HomeController:

public ActionResult Index()
{
   return View("../home/index");
}

damn you clock bar

<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />

makes that bar with a clock on it sort of black and muted on an iPhone but per this there is no way to get rid of that bar altogether. Grr.

keep an HTML5 page from scrolling on an iPhone

I'm not really confident in window.scrollTo(0, 1); but the rest of this is golden.

<script language="javascript">
   window.scrollTo(0, 1);
   $(function () {
      setInterval("resizeMobileScreen();", 500);
   });
   function resizeMobileScreen() {
      windowWidth = document.all ? document.body.clientWidth : window.innerWidth;
      windowHeight = document.all ? document.body.clientHeight : window.innerHeight;
      document.getElementById("viewport").setAttribute('content', 'width=device-width,
            width=480, maximum-scale=1.0, minimum-scale=1.0');
   }
</script>

Why won't apple-mobile-web-app-capable hide Safari's URL bar?

<meta name="apple-mobile-web-app-capable" content="yes" />

...should hide the menu bar right? Well, one may to force this to happen is to:

  1. navigate to the site in quesion on your iPhone
  2. click that options icon that looks like an arrow jumping out of a box toward the upperright
  3. pick "Add to Home Screen"
  4. find the icon at your home screen
  5. click it to open it

base ten to hexadecimal converter

look at this

DROP TABLE Whatever

this drops a table in SQL

Use the "HTML" button at the "Format Text" tab of the ribbon in a would-be email within Microsoft Outlook to switch an email from plain text back to HTML formatting.

This will allow you to put an image in an email when you reply to the plain text email of another.

Monday, August 5, 2013

Run a query in PL/SQL Developer

  1. Go to: File > New > SQL Window
  2. Type a query
  3. Click on the icon that looks like a gear which should say "Execute (F8)" when you mouse over it (or just press F8)

Sunday, August 4, 2013

Did you know strings in JavaScript have a .valueOf() method? If you didn't it is because you mostly don't need to.

I got the following from this:

var str="Hello world!";
document.write(str.valueOf());

Psake is an alternative to NAnt.

Get it here. It needs PowerShell. You could use something like TeamCity to run the Psake scripts. Psake (and NAnt) are for Continuous Integration, the process of automating the building of code and deploying it to a target locale while alerting a team with a failure if the code cannot compile or a test fails.

Nvidia drivers cause PhantomJS to hang!

I learned this in our last retrospective. I still have not used PhantomJS myself.

Saturday, August 3, 2013

async

I just finished Chapter 23 of C# 4.0 in a Nutshell which is called "Asynchronous Methods." This stuff is the forerunner of the stuff you can do with async keyword in C# 4.5 which looks like this:

async Task<int> AccessTheWebAsync()
{
   HttpClient client = new HttpClient();
   Task<string> getStringTask = client.GetStringAsync("http://msdn.microsoft.com");
   DoIndependentWork();
   string urlContents = await getStringTask;
   return urlContents.Length;
}

 
 

If this looks simple enough to you, then perhaps you won't be disappointed when I don't show you the 4.0 equivalent. I have only 52 pages left to read in the thousand page reference manual that is C# 4.0 in a Nutshell and I am pretty checked out at this point. The Asynchronous Methods chapter doesn't really help. All of the examples are spaghetti messes. What I take away from the chapter is that I should lean on a tool like NServiceBus before I ever write Asynchronous Methods. The examples also show off scrapping the web as a use case and suggests steering clear of using Asynchronous Methods in file I/O stuff.

 
 

Addendum 3/14/2014: My reference to C# 4.5 should really be a reference to the ASP.NET 4.5 Framework which uses C# 5.0.

an original piece of artwork

I have well over a decade of experience with Adobe Illustrator, but I find that I do graphic arts work less and less as my professional life takes me deeper into C#. Before I learned C# and before there was a C# language however, I earned an associates degree in multimedia and worked in the industry at a Houston multimedia house for a few years straddling the turn of the millennium. I thought I'd put some of the skills I learned there to use, just for fun, and make myself an original piece of print art. I came up with what is above which I hope you will find tacky in a fun way as opposed to outright offensive. ;) It is a memory of mine from my multimedia days, which, again, lay in the heart of the Rave era. Specifically, this is a hodgepodge of something I recall from Houston's NUMBERS nightclub and a spin on events that came up in retelling the story to a friend soon afterwards. The artwork is completely of vector graphics nested inside of this Adobe Illustrator file. I handed the file to a Speedpro Imaging in Austin. They printed it on a five foot by three foot and change canvas and put grommets along the top. A pole pocket was placed at the bottom edge and I bought a wooden pole at Home Depot to sit inside of it. There used to a program called Adobe Streamline, which Wikipedia suggests is now discontinued, which would attempt to convert raster images into vector images! This too is something of the Rave era. I still have a copy and I used it to turn scribbles I made with sharpies on index cards into vector shapes!

I scanned the index cards on a scanner at a FedEx Office Print & Ship Center, and then used Streamline to get them into .eps format. I then brought them into Adobe Illustrator one at a time and assigned uncoated Pantone colors to them. The outlines converted to shapes not outlines. For example, if one were to draw the letter O, scan it, and then convert it to vector format with Streamline, one would not get a white shape with a black outline. Instead one gets a black shape with no outline and a slightly smaller white shape with no outline sitting on top of it. To make one shape of the two a subtraction operation has to occur. On the other side of that, you nonetheless have a shape and not an outline. This is not a bad thing however as the variations of line width in my sharpie doodles survived the translation into vector format. I made all of the people in the piece the same size when I drew them so the ones that end up farther in the background had to be scaled down and thus the widths of their borders are proportionally smaller than those of individuals closer to the foreground. The way all of the lines look is what I am most proud of. Streamline tries to make shapes based upon colors. A photo of your face will end up sort of becoming a stained glass window. That sort of conversion is pretty worthless. However, black lines on white paper, where there is strong contrast between only two colors, translate well.

 
 

Addendum 9/3/2017: I've grown to hate this piece of art as the pole pocket was too long for the four foot pole I bought at Home Depot. There is no way to buy wooden sticks of various lengths at Home Depot. Maybe I can find a longer pole somewhere. The one of time I used this print shop while I was at Headspring they just furnished a pole but this time they said they would not. That makes me cranky. Does it have to ruin the artwork?

Friday, August 2, 2013

App.config for COM+

Per this, one may place an application.manifest file with the following contents...

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
</assembly>

 
 

...in the "COM+ application root directory" to make an application.config in the same directory behave as if it were the App.config file for the COM+ application. Naturally, this begs the question: What is the COM+ application root directory? To find this directory:

  1. Type "component services" at the start menu to launch the component services dialog box
  2. Drill in to: Console Root > Component Services > Computers > My Computer > COM+ Applications
  3. Right-click an application here and select "Properties" from the menu which appears
  4. Go to the "Activation" tab of the application-specific dialog box which appears
  5. The "Application Root Directory" value is set here!