<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.timewarptechnologies.com"  xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>jlopez&#039;s blog</title>
 <link>http://www.timewarptechnologies.com/blog/1</link>
 <description></description>
 <language>en</language>
<item>
 <title>Async and top level UI</title>
 <link>http://www.timewarptechnologies.com/node/235</link>
 <description>&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;p&gt;More and more libraries are using &lt;code&gt;async&lt;/code&gt; calls where you are expected to in turn use &lt;code&gt;await&lt;/code&gt; to allow the maximum code concurrency. However, there are some contexts where the costs of making an asynchronous call is high enough that you may want to insulate your code from the asynchronous nature while using it in other contexts where it makes sense.&lt;/p&gt;
&lt;p&gt;An example of this is a large system that I designed long before the &lt;code&gt;async&lt;/code&gt; keyword was available (.NET 2.0, to be precise) and the asynchronous model from that time was cumbersome enough that we generally avoided it. However, modern APIs are often designed to *only* provide asynchronous versions of their calls. (In our case, this is a mail provider with additional feature above the normal SMTP senders.) In .NET 4.5 MVC, this situation is easy to manage as you can mark the controller itself as &lt;code&gt;async&lt;/code&gt; and the calls can be made easily with maximum concurrency and minimal debugging issues introduced. However, WinForms only allows events to be marked &lt;code&gt;async void&lt;/code&gt; which complicates debugging considerably. Additionally, changing the API surface to Async only makes the integration &quot;big bang&quot;, forcing the entire codebase to be moved at once. Here we can mark the non-async call &lt;code&gt;obsolete&lt;/code&gt; and migrate at a more natural pace.&lt;/p&gt;
&lt;p&gt;In these cases, the best option I have been able to find is to make a wrapper that fully awaits the result, thus preventing code from running asynchronously in this context. We can achieve this using the &quot;boolean parameter hack&quot; which allows two surfaced calls to call the same underlying code, just awaiting the result and returning the completed version when called via the non async version. This allows migration to be more gradual (important when you have a half million lines of user code).&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Mon, 06 Feb 2017 23:42:08 +0000</pubDate>
 <dc:creator>jlopez</dc:creator>
 <guid isPermaLink="false">235 at http://www.timewarptechnologies.com</guid>
</item>
<item>
 <title>Unable to collect NUMA physical memory utilization data and other performance counter issues.</title>
 <link>http://www.timewarptechnologies.com/node/234</link>
 <description>&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;p&gt;On a development box I started getting the message &quot;Unable to collect NUMA physical memory utilization data. The first four bytes (DWORD) of the Data section contains the status code.&quot; This message is sourced from PerfOS, which makes me think the performance counters have been damaged. Running &lt;/p&gt;
&lt;pre&gt;lodctr /R&lt;/pre&gt;&lt;p&gt; twice at an admin prompt removed the error messages. This command attempts to rebuild the performance counters, which often become out of sync with installed and removed software packages.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Wed, 01 Feb 2017 20:29:26 +0000</pubDate>
 <dc:creator>jlopez</dc:creator>
 <guid isPermaLink="false">234 at http://www.timewarptechnologies.com</guid>
</item>
<item>
 <title>Uploading a file to blob storage in Azure</title>
 <link>http://www.timewarptechnologies.com/node/233</link>
 <description>&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;p&gt;Powershell is a powerful interface to Azure, but the steps to do any given task are not obvious even from the documentation. Here is, for example, getting started with Azure to upload a file as a blob. &lt;/p&gt;
&lt;p&gt;Powershell Azure Upload: (&amp;lt;something&amp;gt; is a slug to be replaced with real data)&lt;/p&gt;
&lt;p&gt;//One time steps required to add Azure commandlets to Powershell&lt;br /&gt;
* Install-Module AzureRM //Note, must be done as Administrator prompt.&lt;br /&gt;
* Install-Module Azure //Note, must be done as Administrator prompt.&lt;/p&gt;
&lt;p&gt;//One time per session, to connect to Azure&lt;br /&gt;
* Login-AzureRmAccount //Provide credentials for Azure portal in popup&lt;/p&gt;
&lt;p&gt;//Typical flow to find the correct destination and upload&lt;br /&gt;
* Get-AzureRmSubscription //List subscriptions&lt;br /&gt;
* Get-AzureRmSubscription -SubscriptionName &amp;quot;&amp;lt;Full name from above results&amp;gt;&amp;quot; | Select-AzureRmSubscription //Select one as the default to operate&lt;br /&gt;
* Get-AzureRmContext //Verify settings, no storage account will display&lt;br /&gt;
* Set-AzureRmCurrentStorageAccount -ResourceGroupName &amp;quot;&amp;lt;resourcegroupname&amp;gt;&amp;quot; -StorageAccountName &amp;quot;&amp;lt;storageaccountname&amp;gt;&amp;quot;&lt;br /&gt;
* Get-AzureRmContext //Verify settings, storage account will be shown&lt;br /&gt;
* //Change to local directory&lt;br /&gt;
* Set-AzureStorageBlobContent -File &amp;quot;&amp;lt;localfiletotransfer&amp;gt;&amp;quot; -Container &amp;quot;&amp;lt;targetazureblobcontainer&amp;gt;&amp;quot;&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Wed, 12 Oct 2016 19:14:05 +0000</pubDate>
 <dc:creator>jlopez</dc:creator>
 <guid isPermaLink="false">233 at http://www.timewarptechnologies.com</guid>
</item>
<item>
 <title>Removing active directory credentials using klist purge</title>
 <link>http://www.timewarptechnologies.com/node/232</link>
 <description>&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;p&gt;While installing a backup solution, there was an issue where the permissions to the target share seemed to be failing. We discovered that we had connected to the share using the administrative credentials while setting things up and the software was using application specific credentials that were failing to due to the existing credentials.&lt;/p&gt;
&lt;p&gt;It is easy to disconnect from an active directory share and remove the credentials, but it doesn&#039;t come up much, so it is easy to forget. First, run &lt;code&gt;net use \\server\share /delete&lt;/code&gt; for your share in question. Then, when the share is disconnected, run &lt;code&gt;klist purge&lt;/code&gt;. This removes the Kerberos cached credential information, which will be restored for the remaining connections that are still valid automatically. The other application can then make a connection using alternative credentials as expected.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Thu, 11 Aug 2016 22:52:39 +0000</pubDate>
 <dc:creator>jlopez</dc:creator>
 <guid isPermaLink="false">232 at http://www.timewarptechnologies.com</guid>
</item>
<item>
 <title>Virtual Box Guest Additions with APT requirements.</title>
 <link>http://www.timewarptechnologies.com/node/231</link>
 <description>&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;p&gt;When using Debian or other APT based systems, the guess additions can improve the experience by providing graphical drivers and adjustments to X that allow changing resolutions. (All commands require elevation of privilege). First we must insure the header files are available &lt;/p&gt;
&lt;pre&gt;apt-get install -y linux-headers-$(uname -r)&lt;/pre&gt;&lt;p&gt; and then we go to the Devices menu of VirtualBox and select Insert Guess Additions CD. Finally &lt;/p&gt;
&lt;pre&gt;cd /media/cdrom/&lt;/pre&gt;&lt;p&gt; and in that folder &lt;/p&gt;
&lt;pre&gt;sh VBoxLinuxAdditions.run&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Wed, 20 Apr 2016 17:46:30 +0000</pubDate>
 <dc:creator>jlopez</dc:creator>
 <guid isPermaLink="false">231 at http://www.timewarptechnologies.com</guid>
</item>
<item>
 <title>Custom Validation Attribute in MVC</title>
 <link>http://www.timewarptechnologies.com/node/230</link>
 <description>&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;p&gt;Creating a custom validation attribute for that you can use as a Data Annotation on your models is not hard, but does require a bit of care to make it work on both the server and client side. The first step is to create a class that inherits from ValidationAttribute and implements IClientValidatable. In one project, we need to validate against US and UK phone numbers.&lt;/p&gt;
&lt;pre&gt;    [AttributeUsage(AttributeTargets.Property | 
    AttributeTargets.Field | 
    AttributeTargets.Parameter, AllowMultiple = false)]
    public class ValidPhoneAttribute : ValidationAttribute, IClientValidatable
&lt;/pre&gt;&lt;p&gt;
From there, we implement the IsValid method:&lt;/p&gt;
&lt;pre&gt;
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            ValidationResult validationResult = ValidationResult.Success;
            string toValidate = (string)value;
            if (!Parse.IsPhone(toValidate))
            {
                validationResult = new ValidationResult(ErrorMessageString);
            }

            return validationResult;
        }
&lt;/pre&gt;&lt;p&gt;
Finally, we implement IClientValidate. The &quot;validphone&quot; string defines the function in our javascript file that will be called. &lt;/p&gt;
&lt;pre&gt;
        public IEnumerable&lt;modelclientvalidationrule&gt; GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
        {
            string errorMessage = ErrorMessageString;

            // The value we set here are needed by the jQuery adapter
            ModelClientValidationRule validPhoneRule = new ModelClientValidationRule()
            {
                ErrorMessage = errorMessage,
                ValidationType = &quot;validphone&quot; /* This is the name the jQuery adapter will use*/
            };


            yield return validPhoneRule;
        }
&lt;/modelclientvalidationrule&gt;&lt;/pre&gt;&lt;p&gt;
In our javascript library file custom-validation.js, we added&lt;/p&gt;
&lt;pre&gt;
$.validator.addMethod(&quot;validphone&quot;, function (value, element, params) {
    usPhoneRe = /^[(]?(\d{3})[) -\.]?[ ]?(\d{3})[ -\.]?(\d{4})$/;
    ukPhoneRe = /^\+?44[ -\(\)\d]{9,}$/;

    var isUsPhone;
    isUsPhone = usPhoneRe.test(value);

    var isUkPhone;
    isUkPhone = ukPhoneRe.test(value);

    return isUsPhone || isUkPhone;
});

$.validator.unobtrusive.adapters.add(&quot;validphone&quot;, function (options) {
    options.rules[&quot;validphone&quot;] = &quot;#&quot; + options.value;
    options.messages[&quot;validphone&quot;] = options.message;
});
&lt;/pre&gt;&lt;p&gt;
This registers the method with the jquery validator object.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Tue, 12 Apr 2016 16:15:03 +0000</pubDate>
 <dc:creator>jlopez</dc:creator>
 <guid isPermaLink="false">230 at http://www.timewarptechnologies.com</guid>
</item>
<item>
 <title>Lodctr - Performance counters</title>
 <link>http://www.timewarptechnologies.com/node/229</link>
 <description>&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;p&gt;A frequent event log error is regarding broken performance counters. Generally the &quot;solution&quot; to these messages is to put one&#039;s head in the sand and ignore them, but if you prefer not seeing event log entries for things you can fix it might be possible to repair the counters using the &lt;code&gt;lodctr&lt;/code&gt; command to reset the offending counter. [1]&lt;/p&gt;
&lt;p&gt;There are two steps to this task. The first is to find the appropriate &lt;code&gt;.ini&lt;/code&gt; file to reload. These files live in &lt;code&gt;%systemroot%\Inf&lt;/code&gt; (C:\Windows\Inf\ for a default install). There is a directory per counter on the system and each counter&#039;s directory can contain multiple locale variations. The specific local can be found via MSDN [2] but for &quot;English - United States&quot; the folder is 0409 (1033 in hex). &lt;/p&gt;
&lt;p&gt;Once the counter is found, at the command line change into that folder and run &lt;code&gt;lodctr [counter.ini]&lt;/code&gt; to reload the counter information. More information about this command can be found at Technet [3]&lt;/p&gt;
&lt;p&gt;[1] https://jesperarnecke.wordpress.com/2013/12/18/corrupt-or-broken-performance-counters-windows-2012/&lt;br /&gt;
[2] https://msdn.microsoft.com/en-us/goglobal/bb964664.aspx&lt;br /&gt;
[3] https://technet.microsoft.com/en-us/library/bb490926.aspx&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Tue, 26 Jan 2016 15:50:31 +0000</pubDate>
 <dc:creator>jlopez</dc:creator>
 <guid isPermaLink="false">229 at http://www.timewarptechnologies.com</guid>
</item>
<item>
 <title>Remote registry control</title>
 <link>http://www.timewarptechnologies.com/node/228</link>
 <description>&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;p&gt;The fix to many active directory issues involves the registry. RegEdit has built in support to connect to remote machines, but we normally leave the remote registry service turned off. Ironically, the recommended method usually given to turn on remote registry edits involves... editing the registry. Now this can be done via group policy, but for a one off fix, it is far easier to just start the service, make the change and turn it back off.&lt;/p&gt;
&lt;p&gt;To do so, you can use the &quot;sc&quot; command, which gives control over remote service status. While it can do a lot more, all we care about in this case is the ability to &lt;code&gt;sc \\computername start remoteregistry&lt;/code&gt;. Connect to the registry, make the changes and when done, run the command in stop mode.&lt;/p&gt;
&lt;p&gt;[1] http://thescriptingadmin.blogspot.com/2013/04/enable-remote-registry-service-on.html&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Mon, 02 Nov 2015 17:23:20 +0000</pubDate>
 <dc:creator>jlopez</dc:creator>
 <guid isPermaLink="false">228 at http://www.timewarptechnologies.com</guid>
</item>
<item>
 <title>Performance counter management.</title>
 <link>http://www.timewarptechnologies.com/node/227</link>
 <description>&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;p&gt;Performance counters are a frequent recurring error message in Windows systems. They can indicate issues that need to be addressed, but it is very common to get errors from performance counters that are irrelevant (such as Readyboost on machines that don&#039;t use the feature). Fortunately, there is a way to manage which counters are enabled.&lt;/p&gt;
&lt;p&gt;First, download Exctlst.exe from the Windows 2000 Resource Kit[1]. Once installed (default location is C:\Program Files(x86)\Resource Kit) run the executable as administrator and find the counters to enable or disable. &lt;/p&gt;
&lt;p&gt;[1] http://download.microsoft.com/download/win2000platform/exctrlst/1.00.0.1/nt5/en-us/exctrlst_setup.exe&lt;br /&gt;
[2] http://blogs.technet.com/b/askperf/archive/2010/03/05/two-minute-drill-disabled-performance-counters-and-exctrlst-exe.aspx&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Mon, 05 Oct 2015 17:08:16 +0000</pubDate>
 <dc:creator>jlopez</dc:creator>
 <guid isPermaLink="false">227 at http://www.timewarptechnologies.com</guid>
</item>
<item>
 <title>Unable to access the IIS Metabase</title>
 <link>http://www.timewarptechnologies.com/node/226</link>
 <description>&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;p&gt;Ran into a situation after updating to Windows 10 from Windows 7 where Visual Studio could not debug under the full IIS stack. Turns out it is a simple fix[1]. Simply go to %systemroot%\system32\inetsrv\config and when prompted that you don&#039;t have access, click the button that grants access. (This avoids needing to run Visual Studio as the administrator).&lt;/p&gt;
&lt;p&gt;[1] http://stackoverflow.com/questions/12859891/error-unable-to-access-the-iis-metabase&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Tue, 22 Sep 2015 23:52:49 +0000</pubDate>
 <dc:creator>jlopez</dc:creator>
 <guid isPermaLink="false">226 at http://www.timewarptechnologies.com</guid>
</item>
</channel>
</rss>
