Friday, May 31, 2013

.pop() in JavaScript will throw away the last item on an array, as if almost the opposite of .push()

In keeping with my silly supreme court example, if a file named defineyesmen.js merely contained:

var yesmen = ['Alito', 'Kagan', 'Kennedy', 'Roberts', 'Scalia', 'Thomas'];

 
 

...then the dropdown list given in the HTML below would end up with the contents of the array minus Clarence Thomas.

<html lang="en">
   <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width,initial-scale=1,maximum-
            scale=1,minimum-scale=1,user-scalable=no"/>
      <meta name="apple-mobile-web-app-capable" content="yes" />
      <title>Whatever</title>
      <link rel="stylesheet" type="text/css" href="styles.css" media="screen">
      <style type="text/css" media="all">
         #list {
            width: 220px;
         }
      </style>
   </head>
   <body style="overflow-y:hidden; overflow-x:hidden;">
      <select id="list">
         <option selected>change me to something else</option>
      </select>
      <script src="defineyesmen.js" type="text/javascript"></script>
      <script type="text/javascript">
         yesmen.pop();
         for (var i=0; i<yesmen.length; i++)
         {
            var opt = document.createElement("option");
            opt.text = yesmen[i];
            opt.value = yesmen[i];
            document.getElementById("list").options.add(opt);
         }
      </script>
   </body>
</html>

 
 

If an array is empty it will just stay empty upon a .pop() which seems to cause no error.

To keep Google Chrome from opening http://mysearch.avg.com/

...I had to uninstall a toolbar from the control panel.

Agent Ransack

...is a grep tool. Go get it here. Actually, this source may not be the best place to grab the code. When I got it from CNET it ended up putting something called Uniblue SpeedUpMyPC on my laptop. Grrr. Anyways, I digress. The tool itself seems to work. I can specify a folder and then search all the files in that folder and nested folders within for a magic string. A list of files that have a match is returned. Yay!

Addendum 6/2/2013: http://www.mythicsoft.com/agentransack/download is a better place to download from.

Trolling Google Images is a good way to find mouse pointer images for Photoshop play!

I like this one.

Oracle's Asset Management interface can be challenging in defining associations at lists.

To assign an employee to an operation within a work order in Oracle's Asset Management interface you need to select the employee with both:

  1. the radio button in the Select column shown above at the far left
  2. the checkbox in the Assign column shown above at the far right

 
 

If need to check both and then click "Apply" or else the assignment just won't happen. Oracle's interface is... interesting in this regard. You get to the screen above to begin with by finding a work order at the Work Orders tab, going to the Details tab within the Operations tab at the work order, and then changing the "Select Row:" setting to "Assign Employee" before pressing the Go button.

Addendum 6/21/2013: You don't need to check the radio button, just the checkbox.

Thursday, May 30, 2013

Ctrl-F

I am realizing that Ctrl-F pretty much does the same thing in most apps in Windowsland in that it allows you to search the copy at hand for a string. At the moment, I'm using it in Google Chrome's Developer Tools.

F8 continues past a breakpoint in Chrome Developer Tools debugging.

...not F5. Duh.

Chrome Developer Tools

At: Hotdog menu > Tools > Developer tools ...is where the Chrome Developer Tools are kept in Google's Chrome browser. Ctrl-Shift-I also opens them up. The hotdog menu is found in that button with three horizontal lines with rounded ends on it which tells you "Customize and control Google Chrome" when you mouse over it. Anyways, at the tools: Tabs will run across the top reading:

  1. Elements
  2. Resources
  3. Network
  4. Sources
  5. Timeline
  6. Profiles
  7. Audits
  8. Console

 
 

Open files in the "Sources" tab and set breakpoints in .js files there. When running a page, skip ahead from a breakpoint by pressing F5. If you have Firebug Lite open at the same time as the Developer Tools you probably won't even be able to see the content of the web site at hand. Close Firebug Lite in this case by clicking on the icon at the upper right of its pane which looks like a short vertical line surrounded by a circle.

Addendum: What I say about skipping ahead by pressing F5 is completely wrong. F5 refreshes the browser.

To rollback to a prior version in TortoiseHG/Mercurial...

...just go to the appropriate node in the history within TortoiseHG's Workbench and pick a point somewhere down the graph from the top. Right-click there and pick "Update..." This will give you what you want. In order to revert back to the latest stuff, just do an "Update..." at the top point in the graph.

Add As Link

Right-clicking in a project in the Solution Explorer in Visual Studio 2012 and then picking Add > Existing Item... ...will naturally let you add a class to a project. In the dialog box that appears, where you browse for a file, the "Add" button will have a little down arrow by it. If you click the down arrow, you will see a little menu with these options:

  1. Add
  2. Add As Link
  3. Show previous versions

 
 

Picking the "Add As Link" option will allow you to create a link to the file instead of including the file in the project at hand. When you update the file at its own project the changes will be usable immediately at the project linking it in, yet when you compile the project linking in the file, the code ends up in the .dll for the project linking the file in and there is not a scenario in which .dll will look to another .dll for a referenced file. In the case of class, there is a different icon for classes that are really in a project from those which are linked in. The former is a green "C#" and the latter is a green "C#" with a blue box with a dot in it laid over its lower right.

Wednesday, May 29, 2013

Firebug Lite for Google Chrome!

...doesn't suck.

-moz-scrollbars-none is obsolete!

...this suggests as much. I think the modern way to do away with scrolling in browsers might be:

<body style="overflow-y:hidden; overflow-x:hidden;">

 
 

Some of the examples I see online have this pulled out to a stylesheet and have the styling on the html element and not just the body element. I dunno.

dojoConfig versus data-dojo-config within... Dojo!

This offers: "Notice that dojoConfig is defined in a script block before dojo.js is loaded. This is of paramount importance—if reversed, the configuration properties will be ignored." ...while giving this code as an example:

<script>
   dojoConfig= {
      has: {
         "dojo-firebug": true
      },
      parseOnLoad: false,
      foo: "bar",
      async: true
   };
</script>
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.9.0/dojo/dojo.js"></script>

 
 

Okey-dokey, this example is also given by the same source as a way to jam the dojoConfig JSON into a script tag as an HTML5 Custom Data Attribute:

<script src="//ajax.googleapis.com/ajax/libs/dojo/1.9.0/dojo/dojo.js"
   data-dojo-config="has:{'dojo-firebug': true}, parseOnLoad: false, foo: 'bar', async: 1">
</script>

 
 

Note:

  • async: true ...denotes if Dojo itself should be loaded asynchronously, allowing, if true, for the app to come to life before everything is sucked down to the client.
  • When using dojox:
    • The app I am looking at currently has a separate script tag for calling /dojox/mobile/deviceTheme.js and thus this app is using the data-dojo-config convention to pass the the configurations so that it may delinate configurations between the two script tags. (I'm guessing.)
    • There is also going to be an independent config.json file for dojox (perhaps) but I don't understand it yet. config.json is not managing the same thing that dojoConfig/data-dojo-config is. (I'm pretty sure.)

AMD is new to Dojo!

1.9.0 seems to be the latest version of Dojo as of this moment in time in May of 2013. Go get it http://download.dojotoolkit.org/. The AMD (Asynchronous Module Definition) modules are new to the framework as of 1.7 I think.

embedded mode versus full-screen mode

This has a good breakdown between embedded mode and full-screen mode. I gives me the impression that a full-screen mode HTML5 app will appear (perhaps disingenuously) as though it is a full-fledged app independent of the Safari browser on an iPhone and not just a web page within the Safari browser. The meta tag for the full monty is:

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

Sublime versus Notepad++

Today a coworker suggested that Sublime is more of an IDE (Integrated Development Environment) while Notepad++ is more geared towards browsing log files.

Create and use a virtual directory in IIS.

  1. open IIS
  2. select first "Default Web Site" at the left sidebar menu (titled Connections) and then "View Virtual Directories" at the right sidebar menu (titled Actions)
  3. right-click in the center of the open Virtual Directories pane and pick "Add Virtual Directory"
  4. specify an alias and a path to a folder
  5. if your alias is "foo" (for example) then you should be able to reach the folder via a browser at http://localhost/foo/

Visual Diff in TortoiseHG for Mercurial

If you right-click on a file and pick: TortoiseHG > Visual Diff ...you will get a comparison between the current version of the file and the file checked in at the Mercurial repository.

ERP stands for Enterprise Resource Planning.

Examples:
  1. SAP (by the German SAP AG)
  2. Oracle's eBusiness Suite
  3. PeopleSoft (now also owned by Oracle)
  4. IBM's Maximo

Addendum 4/29/2014: Maximo isn't really a full ERP. It is just the asset management piece of the pie. JD Edwards, Lawson, and Workday are other ERPs.

Mom tells me that Photoshop CS6 will be the last version that Adobe lets you download standalone outside of their cloud-based services.

...and my Mom knows everything.

Tuesday, May 28, 2013

Force push or pull (override safety checks, --force)

In the "Synchronize" pane in TortoiseHG there is an button titled "Options" and clicking upon it will reveal a series of checkboxes for configuration amongst which is "Force push or pull (override safety checks, --force)" and if you uncheck this checkbox the client will object to you attempting to check into a Mercurial repository you have not yet merged with. This safeguard will keep you from creating a branch with two heads.

You may compare any two files with Beyond Compare!

  1. Right-click on any file on your laptop and select "Select Left File for Compare" to pick the first file.
  2. Then right-click on any other file anywhere, in another folder even, and pick: Compare To "yournamehere"

BareMetalSoft's BareTailPro is another log tailing tool.

Get it at: http://www.baremetalsoft.com/

Sunday, May 26, 2013

Entity Framework 5 and Onion Architecture!

It looks like Entity Framework 5 lends itself a lot better to an Onion Architecture approach to crafting an ASP.NET Solution than some of its prior incarnations which were very three-layers-flavored. In Visual Studio 2012 I made an MVC4 ASP.NET Web API application and Entity Framework was wired up to work by default in the UI project (called MvcApplication in my "Hello World" example) that was made. I made two other projects in addition to the out of the box one (three total). Shall we go over them?

  1. The first is just called Core and I gave it no references. It holds one class:
    using System;
    namespace Core
    {
       public class Person
       {
          public int PersonId { get; set; }
          public string Name { get; set; }
          public DateTime Birthday { get; set; }
          public Boolean LikesCats { get; set; }
       }
    }

     
  2. The next is called Infrastructure and I gave it a reference to core and a reference to the Entity Framework .dll which was already in the bin folder of MvcApplication as MvcApplication was spun up with an Entity Framework reference. It too holds one class:
    using System.Data.Entity;
    using Core;
    namespace Infrastructure
    {
       public class PersonContext : DbContext
       {
          public DbSet<Person> People { get; set; }
       }
    }

     
  3. The last is the MvcApplication project which should probably have a better name such as UserInterface. It is also "the bootstrapper" referencing both Core and Infrastructure.

 
 

Alright, here is an example of using Entity Framework from a controller in the UI. Note: No Miller tools (Fluent NHibernate or StructureMap)

using System;
using System.Web.Mvc;
using Core;
using Infrastructure;
namespace MvcApplication.Controllers
{
   public class HomeController : Controller
   {
      public ActionResult Index()
      {
         using (var db = new PersonContext())
         {
            var person = new Person()
            {
               Name = "Tom",
               Birthday = new DateTime(1974, 8, 24),
               LikesCats = true
            };
            db.People.Add(person);
            db.SaveChanges();
         }
         return View();
      }
   }
}

 
 

This works! If a Person-related database table does not yet exist it is created. (This is the code first stuff of modern day Entity Framework in action.) A row will be populated to the table regardless of whether or not the table is created first. I did experience some dirtiness in which if I deleted the table that my app could then get hung up trying to recreate it. I'm not sure why. The table gets named People which keeps with the Entity Framework convention of making tables named as the plural form of the objects they hold (in our case Person). EF was smart enough to name the table People instead of Persons. The end of my Web.config file looks like this:

   <entityFramework>
      <defaultConnectionFactory
            type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory,
            EntityFramework">
         <parameters>
            <parameter value="v11.0" />
         </parameters>
      </defaultConnectionFactory>
   </entityFramework>
   <connectionStrings>
      <add name="PersonContext"
            connectionString="server=.\JAESCHKE;database=MyData;Integrated
            Security=true;" providerName="System.Data.SqlClient" />
   </connectionStrings>
</configuration>

 
 

Addendum 2/14/2014: The use of the PersonContext should really be kept in the Infrastructure. The controller should call an interface in the Core which is hydrated with a repository class out of the Infrastructure which holds the mechanics for the PersonContext. Such a wireup may be done with StructureMap.

Saturday, May 25, 2013

I saw David Tulig speak at indeed.com on Google Closure Tools.

On Wednesday, I stopped by the indeed.com office for an event they held. David Tulig spoke on Google Closure Tools which is yet another JavaScript framework. The most interesting thing about the closure stuff is that it offers three different ways to minify code:

  1. whitespace_only
  2. simple_optimizations
  3. advanced_optimizations

These grow progressively more intense with simple_optimization being the most akin to what you are probably used to in JavaScript minification and whitespace_only being a watered-down version in which just the whitespace in a .js file is trimmed away but otherwise bits of code (such as variable names) which could be shortened are left be. In advanced_optimizations chunks of the code base which are deemed to be unused are merely thrown away. advanced_optimizations also sanity checks your code with compilation safety. If you try to pass a node to something that wants a string and then attempt the advanced_optimizations minification, the compiler will freak out as a compiler should consistent with what everyone expects of type safety. The architecture is interesting. Modules "depend" on other modules in that they listen for events to be fired by them. Two dependent modules with a common parent will talk to each other through the parent. For A to speak to B, A will fire an event that the parent consumes. Somehow the parent then makes B aware too. I cannot say that I really get it without digging into the code. The code David showed off was of an AutoComplete feature for a search field and the module had both a text handler and a RPC (remote procedure call) handler. The text handler module triggered an event in the AutoComplete module which then ended up making the RPC handler act. The text handler and the RPC handler were thus loosely coupled. A drawing of dependencies does not necessarily look like a tree however as a lot of the low level mechanics are abstracted to modules which are used by more than one parent. An application (module) typically breaks into DOM, events, and styles modules and while the events module uses the object and array modules it is not the only module in the second tier to do so. Google has a canned tool for defining dependencies and not starving a module of a dependency which, as you might imagine, hinges on defining things in the right order. Use this utility for defining dependencies cleanly.

I saw Mark DiMarco speak at AustinJS on D3.js.

If you want to have the visual stimuli of a Rich Internet application in your reporting, without the awful overhead of RIAs, there are a some pretty snazzy charting tools available in the JavaScript space:

The last of these was made by a Mike Bostock who has gone on to make an even more impressive charting library. On Tuesday night, I saw Mark DiMarco speak (all of the information here comes from him) at AustinJS on D3.js which is Bostock's new charting tool(s). The three Ds in D3 stand for Data-Driven Documents. To get started, Mark suggested that one not start from nothing, but instead browse some of the examples at the D3 web site, take the code for one and then start messing with it. Voronoi Tesselation was one of the examples he showed off. D3 drinks JSON and spits out SVG Scalable Vector Graphics (SVG) which are a feature in any modern browser and even the mildly geriatric IE9. I have not experimented yet with SVG myself, but I learned Tuesday night that one may apply CSS styles to SVG elements just as one may do so with HTML elements. An example Mark gave was:

path {
   fill: #222;
   stroke: #bad;
   stroke-width: 1px;
}

 
 

D3 has its own syntax for DOM manipulation and Mark encouraged the audience to do things the D3 way instead of rolling a mishmash of D3 and jQuery. Examples of the D3 way of doing things are:

  • d3.select(".someclass").style("color", "#fa0fa0");
  • d3.json("/mydata.json", function(data) { whatever });
  • d3.selectAll(".classy").on("click", function() { whatever });
  • d3.select("body").selectAll("div")
       .data([4, 8, 15, 16, 23, 42])
       .enter().append("div")
       .text(function(d) { return d; });

 
 

It is really hard to convey how awesome D3 is here in words. The presentation I saw sure relied heavily on actually showing off D3 to win the audience with its wow factor. Why not go to the site and see it in action for yourself?

The JavaScript-free viewport tag solution.

This viewport tag...

<meta name="viewport" content="width=device-width,initial-scale=1,
   maximum-scale=1,minimum-scale=1,user-scalable=no">

 
 

...in contrast to the one I mention here will show show the screen at 1:1 scale and disallow scaling to other scales across, I assume, all devices. (It worked at my iPhone in both portrait and landscape modes, switching between the two just fine.) What I mention here is still worth a look however as it includes the setInterval polling which it pretty neat in its own right.

setInterval("my_function();",500);

Friday, May 24, 2013

Rename a Mercurial branch in FogBugz Kiln.

If you create a branch in Fogbugz Kiln the branch should appear at the same page as the repository and have the familiar blue arrow at the upper right of its listing. Clicking on the arrow may or may not reveal an option for "Settings." It depends on how you are permissioned. If you can go into the setting, you can rename a branch. Earlier today I pushed changes to my shelf (branch), had to abandon the shelf when it turned out the story I was working on needed to be put on hold, and then just created a new shelf. The first shelf was renamed and the new shelf was then renamed to have the name of the old shelf, thus allowing Jenkins to continue to "see" it in the name of continuous integration.

Branch a Mercurial repository in FogBugz Kiln.

  1. Pick the repository from the "Browse Repositories" drop down at the top nav. (perhaps from the "Projects" subsection)
  2. Click on the blue arrow at the upper right of a repository listing.
  3. Pick "Branch" from the menu which appears.

Thursday, May 23, 2013

Wednesday, May 22, 2013

ZSoft Uninstaller

Mentioned today by a coworker, ZSoft Uninstaller allows you to:

  1. Take a snapshot of the file names existing, logs, and registry keys in your Windows environment.
  2. Install software.
  3. Take a new snapshot.
  4. Make a report showing the Delta from steps one and three above.
  5. Roll back (undo) the Delta later.

ESXi

VMware vSphere per this has a "hypervisor piece" that is called ESXi. A coworker today mentioned that one may spin up VMs and then save them for easy recreation in any state along a build-out process. Even memory may be retained so that one may enter a saved snapshot and see a application halfway into an act sitting on the desktop.

Underscore is for querying collections.

I saw Mark DiMarco speak on D3 charting at AustinJS last night and while the talk really didn't have a primary focus to do with underscore.js, he brought it up in passing and I was fascinated. He said one may use pluck to pluck items out of a collection and put them into a new collection. I looked into Underscore and found that it is for doing LINQesque (think C#) queries in JavaScript. I downloaded the minimized production version and struggled to get pluck to work. I think it was wrong for what I was attempting. (Below I get all of the supreme court justices who vote Yay and just those justices listed in a dropdown list.) I eventually used filter instead of pluck but struggled in vain to get filter to return the keys of a dictionary-shaped hash in lieu of the values to an array. I eventually just made a backing store array and populated it as an extra step in the process. This is cool stuff.

<!DOCTYPE html>
<html lang="en">
   <head>
      <meta charset="utf-8">
      <title>Whatever</title>
      <link rel="stylesheet" type="text/css" href="styles.css" media="screen">
      <style type="text/css" media="all">
         #list {
            width: 220px;
         }
      </style>
   </head>
   <body>
      <select id="list">
         <option selected>change me to something else</option>
      </select>
      <script src="underscore-min.js" type="text/javascript"></script>
      <script type="text/javascript">
         var obj = new Object();
         obj['Alito'] = "Yay";
         obj['Breyer'] = "Nay";
         obj['Ginsburg'] = "Nay";
         obj['Kagan'] = "Yay";
         obj['Kennedy'] = "Yay";
         obj['Roberts'] = "Yay";
         obj['Scalia'] = "Yay";
         obj['Sotomayor'] = "Nay";
         obj['Thomas'] = "Yay";
         var yesmen = new Array();
         var yays = _.filter(obj, function(a,b) {
            if (a == 'Yay') yesmen.push(b);
            return a == 'Yay';
         });
         for (var i=0; i<yesmen.length; i++)
         {
            var opt = document.createElement("option");
            opt.text = yesmen[i];
            opt.value = yesmen[i];
            document.getElementById("list").options.add(opt);
         }
      </script>
   </body>
</html>

 
 

A random note for myself: By the way if I had just taken the original hash and displayed the yays and nays while using the names as the hidden value that would have looked like so.

for (item in obj)
{
   var opt = document.createElement("option");
   opt.text = obj[item];
   opt.value = item;
   document.getElementById("list").options.add(opt);
}

Tuesday, May 21, 2013

MetroAG threatens to sue Microsoft over calling the Windows 8 UI "Metro"

...and thus Metro is not used as a term in the Windows world... ...or so I hear...

Prep the emulator for Windows Mobile.

Run the download here and then spin up Visual Studio 2008. Remember that Windows Mobile is not Windows Phone and does not play well with the modern Visual Studio.

Go to: Tools > Device Emulator Manager ...which will open the Device Emulator Manager. Once it is open you may close Visual Studio 2008 as the pane may run on its own.

Go to: Start Menu > Windows Mobile 6 SDK > Standalone Emulator Images > US English > WM 6.5 Professional ...to bring up the emulator itself. Note, whenever you close this (fake) device by clicking the X at the upper right you will be asked "Do you want to save the emulator state before existing?" and you likely will want to answer to the affirmative if you have prepped the emulator whatsoever. I lost a bunch of changes today in not saying yes.

Next type "Windows Mobile Device Center" at the start menu to spawn the Windows Mobile Device Center. Yes, you now have three little windows spun up at once.

Windows Mobile Device Center has a link to click on for settings. Go to the settings and prep them. Set "Allow connections to one of the following:" to "DMA."

I was asked to install a driver called drvupdate-amd64.exe too at this point (at my work) once all three windows were up and running, but I'm not sure where to grab it online. In the Device Emulator Manager click the Refresh button to see the emulator "appear as a guid" under "Others." Right-click on the guid and pick "Cradle" from the menu which appears. The Windows Mobile Device Center should change to say "Connected."

You should now (on the other side of everything mentioned above) be able to move files onto the (fake) device via "My Computer."

When you overload methods in C# you could be sabotaging the reflection implementation of someone else which latches onto a method by name (and now has a conflict).

I mention this in case you are not feeling paranoid enough.

Monday, May 20, 2013

Merge with Local...

To merge a detached head back to the trunk in TortoiseHg, right click on the head and pick "Merge with Local..."

Get Windows Mobile!

The Windows Mobile 6.5 Developer Tool Kit comes with emulator images!

Linked Files with #If Directives in ASP.NET

Imagine this C#:

#if FOO
   
whatever
#else
   
something more
#endif

 
 

Now imagine that you have a Visual Studio solution with multiple projects and that MyProject.Core contains the code above in a .cs file and moreover has FOO listed within the "Conditional compilation symbols" field within the "Build" tab which one may find by right-clicking on the MyProject.Core project in the Solution Explorer and picking "Properties." Alright, when browsing the .cs file directly at MyProject.Core, the code between #else and #endif above should be greyed out and inaccessible in terms of setting breakpoints.

Linked files as a concept allows one to reference a .cs file in a different project as though it were in the referencing project. Such a file will compile with the assembly that is latching onto it, ending up in the .dll for the referencing assembly with no dependency on the assembly referenced. In this situation, assuming that MyProject.SomeOtherProject has a linked file to the .cs file containing the code at the top of this blog posting and that MyProject.SomeOtherProject does not have FOO at "Conditional compilation symbols" then the first half of the code nested in the #IF Directive, that which comes before #endif, will be unavailable.

Div to Local

Right-click on a commit (not the most recent) in the TortoiseHg Workbench and pick "Div to Local" to see what varies between that commit and the most recent commit. Beyond Compare or something comparable will allow you to see which lines of code have changed.

Retain a username and password in TortoiseHG.

Stack Overflow has the answer as always:

  1. Inside of the root of a project there will be an ".hg" folder. Go into this folder and open "hgrc" in Notepad.
  2. Paths which look like this...
    http://www.example.com/whatever
    ...need to be doctored to look like this...
    http://foo:bar@www.example.com/whatever
    ...where foo is your username and bar is your password. (Yes, this is the same convention one used to FTP via the URL line in IE eight years ago.)

Saturday, May 18, 2013

test functions with mocha

If test/test.js looks like this:

function myFunction(six, seven)
{
   return 42;
}
var assert = require("assert")
   describe('Array', function(){
   describe('meaning of everything', function(){
      it('should multiply the two numbers handed in', function(){
         var result = myFunction(6,7);
         assert.equal(result, 42);
      })
   })
})

 
 

Clearly, I am able to use mocha to test myFunction as myFunction sits in the same .js file as its test. The test above passes (or fails if I change the 42 to a 43). What is more, I can then latch onto test/test.js with, for example, an HTML file sitting one folder up from the test folder. In making a connection, I may use myFunction in HTML and I am pleased to report that the extra mocha stuff in the file causes no errors or drama.

<!DOCTYPE html>
<html lang="en">
   <body>
      <div id="putsomethinghere"></div>
      <script src="test/test.js"></script>
      <script language="javascript" type="text/javascript">
         var result = myFunction(6,7);
         document.getElementById('putsomethinghere').innerHTML = result;
      </script>
   </body>
</html>

 
 

It seems to me that one way to go about mocha.js testing of functions would be to do something like this. In this model numerous files could live in the test folder and be referenced by applications. Node.js should run all the tests in the test folder spread across different files as best as I can tell. Pain points might come into play when one does a release of an application once it is baked to a point where a version goes out the door. The paths which reference the test folder would likely be rewritten to be something else and the mocha tests themselves may have to be stripped out in the name of minification accentuation. That said, this is perhaps a minor headache at best and it seems like one could get used to this being a part of the deployment dance. The other way to skin this cat would be to somehow have myFunction in a separate file that test/test.js references and while this may be a better way to go I have yet to figure out how to get it to work. I have struggled with require.js some and there may be a way to get a .js file to consume another .js file without an HTML file wiring up the dependencies with require.js, but I have not yet been able to figure out the magic myself. Outside of require.js, I have been unable to make a new document (in code in JavaScript) without having a document (again we are back to needing an HTML document to associate .js files) in the name of consuming a .js file. I have seen examples online of reading a .js file from a .js file but they all assume that you can either use document.whatever or something called DOMParser() and you cannot do these from within a standalone .js file. Does anyone know if there is a really easy trick that I'm missing?

npm install requirejs

...will install require.js in Node and not:

npm install require

 
 

I was wrong earlier... (forgive me)

Friday, May 17, 2013

Attach to Process...

...under the tools menu in Visual Studio seems to be a pretty handy thing to troubleshooting WinForms apps. If you have a WinForm app built out and installed somewhere and you want to use it while also setting breakpoints inside of libraries it uses, you may:
  1. open the uncompiled code in Visual Studio
  2. set break points
  3. open the application
  4. perform the Attach to Process...
  5. browse the application as if one were browsing a web application via Cassini!
If the application has a .dll which is out of version with the code you have breakpoints in then you can't expect Visual Studio to wire up an association that will let you debug. (It is doing this based solely on what you have open and the .exe you attach to. It is making some logically assumptions.) So, you will want to update .dlls at your WinForms app before undertaking this process.

To destroy the most recent commit in Mercurial...

...you must do so at both the local HG Workbench and the repository itself. In both cases you will need the ID of the commit which may be seen enclosed in curly brackets from within HG Workbench at the "Show Repository Registry" pane at the center right of everything following "Changeset:" and the number for the changeset. The ID will look like a Guid that is only twelve characters long and has no dashes within it. For local fixes the .ini file at C:\Users\YOURNAMEHERE\mercurial.ini should look something like so to empower mq='s strip:

# Generated by TortoiseHg settings dialog
 
 
[ui]
merge = beyondcompare3
purge=
mq=
username = Tom Jaeschke <tom@example.com>
 
[tortoisehg]
vdiff = beyondcompare3
 
[extensions]
purge=
mq=

 
 

Shift-Right-Click on the root folder of the repository to get a popup menu with the "Open command window here" option in it which you should pick. At the command line type the following substituting the appropriate ID for the one I make up below:

hg strip 1a2b3c4d5678

 
 

Another way to accommodate the same thing without the strip is to update from a prior commit in the Workbench by right-clicking on a line item in the "Show Repository Registry" pane and picking "Update..." When offered a "Discard Local Changes" checkbox, you should check it before proceeding. In Fog Creek's Kiln you will need to destroy the commit at the repository by going to the repository's settings and then using the "Strip Changesets..." and "Delete Repository..." features at the bottom of the settings page. The former is likely more applicable than the later unless you are destroying the backup of a repository. For the former to work, you will need to enter the ID of the changeset.

add a new repository in TortoiseHg

At the synchronizaton pane I mention here, one may add new repository branches at the empty long fill-in-the-blank field running above the two taller lists of "Paths in Repository Settings:" and "Related Paths:" by specifying a URL and then pressing the "Save Disk" icon at the left of the field's beginning.

Thursday, May 16, 2013

Spinning

...as opposed to blocking in threading is the art of holding a thread from progressing by way of a loop which will eventually expire instead of freezing up the thread with code that is actual of threading itself. I am reading C# 4.0 in a Nutshell by Ben and Joseph Albahari and this is something I read of today. At this training I was encouraged to make WatiN tests pause for aesthetics not by Thread.Sleep but instead by setting a DateTime variable and then running a loop until the moment at hand was greater than that in the variable.

Zepto.js is a library like jQuery-mobile which works well with jQuery.

It however does not try to be friendly with older browsers and is only 10kb when minified.

run NAnt targets

A NAnt script such as OurApp.build will contain targets like so:

<target name="foo" description="bar" depends="baz">
   
whatever...
</target>

 
 

From a command prompt one may run the NAnt target by first navigating to the folder holding the .build file and then running a command like so:

NAnt foo

 
 

I am NOT giving a mention of OurApp.build in the command so I'm not sure how it is found. Perhaps there is a one .build file per folder convention??? I dunno.

Wednesday, May 15, 2013

change Windows password policies?

Per this one may drop Windows password rules that lead to this error:

The password does not meet the password policy requirements. Check the minimum password length, password complexity and password history requirements.

...by typing "Local Security Policy" at the start menu and then navigating to: Security Settings > Account Policies > Password Policy

run Java Forms within the Oracle Asset Management web interface

  1. Get Java(TM) 6 Update 45 and install it.
  2. Remove Java(TM) 7 Update 1 (64-bit) and/or Java 7 Update 9 if they exist in the control panel.
  3. It should work in Firefox. It will not work in Chrome. It takes some doing in IE. (add the site to trusted sites and then remove the XSS safety)

Tuesday, May 14, 2013

Fogcreek Fogbugz

...is a good task management a bug tracking tool for also tying into Mercurial. See: This!

Transparent Network Substrate

TNS is sort of like DNS for Oracle. In TNS one defines aliases which map to collections of settings that specific certainly both the hostname to connect to and the particular database at the server to dive into there and also possibly some other settings like port numbers. When making a connection in Oracle one will often just give an alias, a username, and a password. All the guts of what might be in an MSSQL connection string beyond how one authenticates need not be exposed in Oracle.

SQL Server Compact

Microsoft SQL Server Compact 3.5 is "an embedded database that allows developers to build robust applications for Windows desktops and mobile devices" per the link.

I'm unsure what NPM modules to install to get require.js to jive with mocha.

I've been installing, in addition to mocha:
  1. define
  2. require
  3. dojo

Azure endpoints and PowerShell

I forgot to mention here that Matt Hester mentioned that one may talk into/across PowerShell endpoints with PowerShell and also, in general, use PowerShell to open and shut endpoints.

Azure Affinity Groups

...offer a way to group VMs together and, at the very least, make sure they are hosted at the same datacenter. I forgot to mention this here. The Microsoft facilities in San Antonio (West) and Chicago (East) are thus far the most feature rich and Jeffrey hinted these were the best to use.

Azure Austin

Yesterday's Austin .NET User Group meeting hosted the kickoff of Azure Austin which is a new and different user group spearheaded by Jeffrey Palermo meeting in tandem with the Austin .NET User Group just this once. Jeffrey presented some on Infrastructure as a Service which, as mentioned here, is more or less all about the art of spinning up VMs in Azure and emphasized:

  1. The expected over the exotic: The way everyone is used to interacting with a data center or other cloud environments is based in making remote desktop connections to other machines, be they VMs or physical servers. Azure has a lot more crazy, exotic features, but Infrastructure as a Service is what we all know already.
  2. The expected, quickly: The data center interactions we all know may now be had quickly. Instead of putting in requests to your datacenter to turn x off and y on, you can just do it yourself, waiting minutes instead of hours. Azure Infrastructure as a Service is thus what you are used to, but better.
  3. Endpoints, the exception to the expected: One exception to what I suggest above lies in the Azure concept of endpoints which are holes in the Azure firewalls that allow for ports in. This model is different from merely using Windows Firewall, but then in a traditional datacenter one would have Cisco or SonicWall or something more sophisticated anyways. The endpoints paradigm are Azure's better way of doing the firewall. A Matt Hester spoke at this event too and he touched on endpoints heavily.

Monday, May 13, 2013

DOS wildcard

cd v4*
   ...at a command prompt will let you move from...
C:\Windows\Microsoft.NET\Framework64\
   ...to...
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\

Chai.js

Chai is another JavaScript library for testing.

Thursday, May 9, 2013

Google Chrome may be used as a PDF reader.

Just associate .pdf extensions with Chrome, by which I mean:
  1. right-click a .pdf file on your desktop
  2. pick "Choose default program..." under "Open with"
  3. find Chrome

Wednesday, May 8, 2013

run SQL commands in the Oracle Database Express Edition client

at: SQL > SQL Commands > Enter Command

backup tools

Carbonite, CrashPlan, and Time Machine are backup tools.

Add a directory to the Path environment variable within Windows 7.

  1. For Windows 7, go to the control panel and click on the "Advanced system settings" at the left... This brings up the "System Properties" dialog box with the "Advanced" tab selected
  2. Click the "Environment Variables..." button
  3. Double-click "Path" in the lower scrolling box (System variables)
  4. Add new paths here... The paths get separated by semicolons per this

get NAnt

http://nant.sourceforge.net/ is where you get NAnt.

PL/SQL Developer

http://download.cnet.com/PL-SQL-Developer/3000-10254_4-10012692.html says: "PL/SQL Developer is an integrated development environment for developing, testing, debugging, and optimizing Oracle PL/SQL stored-program units such as packages, and triggers."

Where to create a signature in Microsoft Outlook 2010.

Click on "New E-mail" at the Home tab. In the email dialog which appears, the Message tab will have a Signature button. Click on it. The rest of the work to be done is straightforward.

Environment variable: "PATH" - This test checks whether the length of the environment variable "PATH" does not exceed the recommended length.

Check the "Ignore All" checkbox in the client installer (at the same pane of the wizard where the error pops up) to get around this drama when installing an Oracle client.

Start and stop the Oracle Database Express Edition.

There should be Start Database and Stop Database commands in the start menu. All these seem to do is open a command prompt to the appropriate folder (in my case: C:\oraclexe\app\oracle\product\10.2.0\server\BIN) and then run either:
net stop OracleServiceXE
...or...
net start OracleServiceXE

This might have been a helpful link if it had searchable contents.

sys is the default God user for Oracle Database Express Edition.

You'll spec the password during the install.

Tuesday, May 7, 2013

MVC2 for Visual Studio 2008!

http://www.microsoft.com/en-us/download/details.aspx?id=22079

turn caching off for certain file extensions in IIS7

  1. open IIS7 and click on a site
  2. from the big icons that appear in the main window, pick the "Output Caching" icon and double-click upon it
  3. you will end up in an "Output Caching" screen where you should click the "Add..." link
  4. type a file extension (such as ".js") in the first fill-in-the-blank box and then complete the rest of the dialog box

For those of you who don't know, you may run an .iso file directly, as it it were an executable, with Magic ISO.

  • Get Magic ISO here.
  • You will also need this.
  • Right click on the .iso file. Pick the first option under the MagicISO menu which starts with "Mount" and then the first/only option that appears under the next submenu that flys out.
  • This will associate the .iso with a drive letter, perhaps the E drive for example. Just navigate to the drive via "My Computer" to run the .iso.
  • When finished, right-click on any file and pick "Unmount all drivers" from the MagicISO menu.

getting used to TortoiseHg anew

  1. TortoiseHg is like TortoiseSVN for subversion in that, when you right-click on a file or a folder you will get options for cloning a directory to a folder, adding a file to a local commit, removing a file from a local commit, and many other things.
  2. Work in this manner to get code bases and make local commits.
  3. Go to TortiseHG Workbench to do something more. Here, pick "Open Repository..." from the File menu and browse to the root folder of a local cloned reference to a repository to select THAT code base.
  4. The double arrows (the Synchronize icon in the workbench) will allow you to specify, in another pane, the trunks and branches associated with the repository, these will populate a dropdown menu on the main navigation several icons to the right of the the Synchronize icon.
  5. Pick a trunk or branch here and then click the icon to the immediate left ("Push outgoing changes to selected URL"), which looks like a green arrow pointing from a large yellow cylinder to smaller one, to make a real commit, not a local commit.

Prep TortoiseHG to use Beyond Compare for comparing differences in files.

The following is copied largely directly from here:

  1. Launch TortoiseHG Workbench.
  2. Under the File menu go to Settings.
  3. Select TortoiseHg
  4. Set both the Visual Diff Tool and the Three-way Merge Tool to beyondcompare3 using the dropdown.

Pidgin is a chat account aggregation-around-one-client tool.

Get it at: http://sourceforge.net/projects/pidgin/files/latest/download

Set the home page in Firefox 20!

It's crazy. Drag the favicon to the left of the URL at the URL line to the home button.

Tortoise for Mercurial

TortoiseHG is a Mecurial client.

Update 5/24/2013: Mercurial is the proper spelling.

Monday, May 6, 2013

I'm starting to understand functional programming better.

I've made an object that both has a method for sending an email via a web service and some state for reporting on how it went. An instance for this object will exist for every email address in a list of addresses to which a canned email message will be broadcast. The methods for the instance objects will get spooled up in a Func and then fired off at once.

using System;
namespace Funky.Core
{
   public class EmailAttempt
   {
      public string Error { get; set; }
      public EmailSendingStatus Status { get; set; }
      public string ToAddress { get; private set; }
      
      public EmailAttempt(string email)
      {
         ToAddress = email;
         Status = EmailSendingStatus.Unsent;
         Error = null;
      }
      
      public DateTime Attempt(Tuple<string, string, string> htmlPasswordAndSubject,
            IEmailSender emailSender, IClock clock)
      {
         try
         {
            emailSender.Send(ToAddress, htmlPasswordAndSubject.Item1,
                  htmlPasswordAndSubject.Item2, htmlPasswordAndSubject.Item3);
            Status = EmailSendingStatus.Successful;
         }
         catch (Exception exception)
         {
            Status = EmailSendingStatus.Failed;
            Error = exception.Message;
         }
         return clock.Time();
      }
   }
}

 
 

Here is an enum used by my object. This is for delineating if a would-be attempt has been processed and how the processing faired.

namespace Funky.Core
{
   public enum EmailSendingStatus
   {
      Failed,
      Successful,
      Unsent
   }
}

 
 

Here is a static method for populating and then executing the Func mentioned. It will return a list of objects which denote how each would-be outbound email faired and also a note about when the whole of the greater operation ended.

using System;
using System.Collections.Generic;
using System.Linq;
namespace Funky.Core
{
   public static class EmailSenderWrapper
   {
      public static Tuple<List<EmailAttempt>, string> SendToList(List<string> emails,
            Tuple<string, string, string> htmlPasswordAndSubject, IEmailSender
            emailSender, IClock clock)
      {
         List<EmailAttempt> attempts = emails.Select(email => new
               EmailAttempt(email)).ToList();
         string endStatus = CommonMagicStrings.EmailSpoolEmptyMessage();
         if (attempts.Count > 0)
         {
            Func<Tuple<string, string, string>, IEmailSender, IClock, DateTime> queue;
            queue = attempts[0].Attempt;
            if (attempts.Count > 1)
            {
               int counter = 1;
               while (counter < attempts.Count)
               {
                  queue += attempts[counter].Attempt;
                  counter++;
               }
            }
            DateTime endTime = queue(htmlPasswordAndSubject, emailSender, clock);
            endStatus =
                  String.Format(CommonMagicStrings.EmailSpoolCompletionMessage(),
                  endTime.ToString());
         }
         return new Tuple<List<EmailAttempt>, string>(attempts, endStatus);
      }
   }
}

 
 

Here is an example of use.

using System;
using System.Collections.Generic;
using System.Web.Mvc;
using Funky.Core;
using StructureMap;
namespace Funky.UserInterface.Controllers
{
   public class HomeController : Controller
   {
      public ActionResult Index()
      {
         IEmailSender emailSender = ObjectFactory.GetInstance<IEmailSender>();
         IClock clock = ObjectFactory.GetInstance<IClock>();
         Tuple<string, string, string> htmlPasswordAndSubject = new Tuple<string, string,
               string>("Body", "Xenu", "Header");
         List<string> emails = new List<string>() {"fevercheese@gmail.com",
               "tomjaeschke@tomjaeschke.com"};
         Tuple<List<EmailAttempt>, string> detailsAndStatusOfEmailCampaign =
               EmailSenderWrapper.SendToList(emails, htmlPasswordAndSubject,
               emailSender, clock);
         return View(detailsAndStatusOfEmailCampaign);
      }
   }
}

Sunday, May 5, 2013

dojo/domReady!

The following refactoring of this makes circumstances such that the whole of the HTML page using this module must load before the code will run. I think domReady! needs to be the last module dependency listed in the define array.

define(["dojo/dom", "dojo/domReady!"], function(dom){
   return {
      myThing: function(id){
         var node = dom.byId(id);
         node.innerHTML = "Tom!"
      }
   };
});

My first Dojo module!

define(["dojo/dom"], function(dom){
   return {
      myThing: function(id){
         var node = dom.byId(id);
         node.innerHTML = "Tom!"
      }
   };
});

 
 

What is above gets used as seen below. This is my own warping of the canned Hello Dojo tutorial. Below "dojo/tom" means "look in the dojo folder for tom.js" and above "dojo/dom" means "look in the dojo folder for dom.js." The word "Hello" below will get swapped out with "Tom!" That is all this does. I ran the HTML below through IIS under a fake subdomain I faked at the hosts file as the tutorial suggested that might be better than run trying to run an HTML file out of a folder standalone.

<!DOCTYPE html>
<html>
<head>
   <meta charset="utf-8">
   <title>Tutorial: Hello Dojo!</title>
</head>
<body>
   <h1 id="greeting">Hello</h1>
   <script src="/dojo/dojo.js" data-dojo-config="async: true"></script>
   <script>
      require(["dojo/tom"], function(myModule){
         myModule.myThing("greeting");
      });
   </script>
</body>
</html>

Saturday, May 4, 2013

bullet points from the Hello Dojo tutorial

  • this is the tutorial
  • starting a url with // instead of http:// or https:// at an src attribute within an HTML tag will make a browser load the link with the protocol at hand (either http:// or https://)
  • data-dojo-config="async: true" ...is an example of passing in a JavaScript object literal (JSON object) as a configuration specification to a given item using Dojo
  • the article recommends using asynchronous mode by default as given in the bullet point above
  • Dojo uses the AMD specification as of version 1.7
  • content delivery networks (CDN) Dojo stuff is accessed online and thus inaccessible when one is offline
  • my/module/id ...is an example of how a "module" would be mentioned in code. It would reference: my/module/id.js

Friday, May 3, 2013

AMD stands for Asynchronous Module Definition

This talks about it some.

Psych: Running mocha scripts has EVERYTHING to do with the Node shell as it turns out.

I have been struggling this morning to figure out how to reference one file from within another in a mocha test, and have been through this a little bit, and that convinces me that what I say here about not needing Node isn't true after all. The npm commands at The Command Line are of node.

Thursday, May 2, 2013

Running mocha scripts has nothing to do with the Node shell as it turns out.

Per this I typed npm install -g mocha followed by mkdir test at the Command Prompt in Windows 8 which, for me, by default spins up at C:\Users\Thomas so I suppose I both installed mocha therein and created a directory called "test" for mocha to crawl. In the test directory I manually made a file called test.js with this inside of it (taken from the page I link to):

var assert = require("assert")
describe('Array', function(){
   describe('#indexOf()', function(){
      it('should return -1 when the value is not present', function(){
         assert.equal(-1, [1,2,3].indexOf(5));
         assert.equal(-1, [1,2,3].indexOf(0));
      })
   })
})

 
 

I returned to the Command Prompt and typed mocha and was able to run the test successfully. I returned to file I made and changed the five to a two and then ran the test again to see it fail. Yay!

Addendum 5/3/2013: See this as the very title of this blog posting is bad.

I am trying to get used to the Node shell.

per this: A standalone line of code may be run just by typing it in the shell like so...
console.log('Hello World');
...and pressing enter, (which in my case caused "Hello World" to be written on the next line and "undefined" to be written on the line below it), but starting a line of code with a dollar sign opens up the ability to write a series of lines of code. Herein, pressing enter breaks to the next line instead of executing the line beforehand.
per this: Ctrl-C will end a series of lines of codes started by opening up a dollar sign.
per this: I now believe that what I wrote above of dollars signs (I'm writing this as I figure stuff out.) is just wrong. Node will assume you are writing a function (and thus not "close out" upon the press of the enter key) if applicable and will not cease until you do something to convince it that it is time to stop. For example, I wrote the following three lines one after another, pressing enter at the end of each line, and only got the command prompt again (after the word "undefined") after the third line.
var foo = {
   bar : "baz"
);

Immediately after this I typed:
console.log(foo.bar);
...and upon pressing enter got "baz" on the next line followed by "undefined" on the line after that. However, when I type something with a bug in it like this...
var foo = {
   bar = "baz"
);

...I never get back to a command prompt! The shell does not know how to deal with what I've shoved into it.
per this: npm install mocha
...is the command for installing mocha at Node. I struggled to run this command. First I gave a dollar sign before it and then could not exit the mess I started. Then I took off the dollar sign and was informed that I needed to run the command NOT in the Node shell but just at the regular Command Prompt within Windows. The command, without the dollar sign, seems to have worked there.

no Mocha without Node?

Oh boy! It looks like I have to stop fearing Node.js and embrace it if I want to use mocha.js. It seems I can install Node from here and then get a mocha package to run in the shell here. I'm about to jump in. I'll tell you if the water is cold.