Friday, July 6, 2018

Visual SourceSafe - Automating Permission Setup

July 06, 2018 Posted by Jason Irwin No comments
At this point there can't be too many shops out there still using VSS. We still have a couple of legacy databases out there that recently had to move to updated servers. Microsoft has a nice guidedetailing requisite permissions and shares but providing Modify permissions on the Users/<username> folder is arduous. Here's a little shortcut to help. CD into the relevant "Users" folder and execute the following command:

icacls * /t /grant:r "vss_users":(OI)(CI)M

Tuesday, May 23, 2017

Pycharm, Docker and Matplotlib on a Mac

May 23, 2017 Posted by Jason Irwin , , ,

The Issue

I'm playing with Tensorflow at the moment. I'm loving PyCharm's docker integration, but the drawback I've run into is plotting Matplotlib graphs. When attempting to plot a graph, the following error occurs:

RuntimeError: Invalid DISPLAY variable

The Workaround

The standard workaround is to save plots as images and open them from the local filesystem, like so:

This is a minor annoyance, at best.

The Solution

But there is another way! In order to get things working in PyCharm, three steps are necessary:

1. Install and start Socat

Kudos goes to this blog post for the tip and requisite install and setup instructions.

2. Make sure XQuartz is installed

This one should be fairly straightforward. Worth upgrading to latest and greatest if steps do not work out of the box...

3. Edit PyCharm run/debug configuration

PyCharm allows docker flags to be set via it's run/debug configuration settings. The DISPLAY environment variable needs to be set to the appropriate address (my local IP is but yours likely isn't...). Ideally I could use the hostname versus IP address but I need to dig some more.

The Outcome

If all goes well, when you plot your graph you'll end up with a nice little XQuartz window displaying said graph

Monday, April 10, 2017

Adding functionality to Nopcommerce's admin screens without copying and pasting existing views

April 10, 2017 Posted by Jason Irwin ,


Nopcommerce's plugin engine is fairly powerful, providing extension points to expand core functionality. A sizable ecosystem has been built aroudn these extension points. When it works, it adds a lot whole lot of value. However, oftentimes required extension points do not exist, and extending the platform becomes much trickier.

In the past I have made modifications directly to the Admin site, but this leads to maintenance pain and I much prefer a plugin approach. In this post, I'll outline how I developed a trivial plugin, adding a button to the Order List screen, without duplicating any code.


For a long time administrators on my site have been able to print delivery labels from the Order List and Order Details screens. This requires adding a button to these screens, adding some Javascript to these screens and also adding some controller code. The result looks something like this:

As of right now, Nopcommerce does not have much support for admin page modifications. There are a limited number of widget zones (allowing custom widgets to be placed on screen) and otherwise very limited UI customizability.

Standard Suggestion

The most common advice you see in these situations is to create a plugin, create a new view engine and point it to customized versions of the existing cshtml view files. So, in my case, I'd take a copy of Orders\Edit.cshtml and Orders\List.cshtml, modify them with my desired behavior and point my viewengine at the modified files. In theory this is fine, and it works well for small partial views. However, for the two files in question we're looking at a totalk of 700+ lines of code being duplicated.

My Solution

The solution in my case is similar to the above, but without the redundancy implied by duplicate code.

Step 1: Create as Misc plugin

I'll asume the reader is experienced enough with Nopcommerce to complete this step without help

Step 2: Create Your View Engine

All we're doing here is telling the plugin where to find our views.


Step 3: Create Your Routeprovider

This step is pretty straightforward. The goal is to overwrite the routes that the admin page currently uses when listing/editing orders.

Step 4: Create your Controller

It doesn't get much more simple than this

Step 5: Create Your Views

So here's where the magic happens. Rather than duplicating and modifying the original view, we render it as an action in our new view, adding our button(s) and events via jQuery. Below is an example of my List.cshtml view. Orders.cshtml works the same way.

Assuming future changes by the Nopcommerce team are not too impactful, this plugin should continue to work without requiring any re-coding.

Potential Drawbacks

This is far from a perfect solution.

1. It potentially has a performance impact as view processing will take a little longer due to the nested nature of our action rendering. To me, this is insignifcant. I'm not sure if the difference is noticable and, even if it is, I am more concerned about consumer-facing and search-engine-facing performance than performance that my administrators see.

2. You can only do this once per screen. By that I mean, you can't have multiple plugins ammending the same screen. Remember, we are overriding our route list, replacing the default with our own routes. If we do this more than once, the last in wins...whichever routes are loaded last will determine what is seen by the user.

In Closing

Look, this is a hack. Undoubtedly so. At some point in the near future the Nopcomerce team will expand upon the available widget zones in the admin area and/or add further extension points to the admin panel, making all of this unnecessary. When they do, I will most certainly update my code. But, in the short term, this allows additional value to be addded to administrative screens without having to copy and paste a bunch of code.

Monday, November 7, 2016

Siri not working on Mac OS Sierra

November 07, 2016 Posted by Jason Irwin

I've been holding out on rebuilding/reimaging my 2012 Macbook Pro in the hope of picking up a 2016 model. Underwhelmed by this year's offerings, I went ahead and rebuilt this evening.

Everything worked well in its vanilla state, but after installing a bunch of dev tools Siri on Mac OS Sierra failed to work. Clicking on either Siri icon and/or holding the prescribed keyboard shortcut did nothing. No error, no nothing. This happened on my prior build. I logged the issue with Apple's beta feedback team but the conversation was fruitless (despite me sending a video of my actions, the rep asked if I was holding the shortcut keys or merely pressing them...) and I temporarily gave up on Siri on Mac OS.

I'm unable to prove it at this juncture but suspect there is something installed as by Donne Martin's awesome dev tools that somehow conflicts with Siri, but cannot be 100% sure without further testing. I'm including this comment not to disparage his setup scripts (they are the first thing I run any time I rebuild) but to provide a fix in case one of the installed tools is the culprit.

Fortunately, I ran into a discussion thread on Apple's support forums indicating tha the problem stemmed from the notification center process being disabled. The steps to fix the issue are as follows:

1. From a terminal:
* launchctl load -w /System/Library/LaunchAgents/
* killall NotificationCenter

2. Disable and re-enable siri

3. Reboot

Tuesday, August 23, 2016

Android Studio - incompatibility between HAXM hypervisor and VirtualBox 4.3.30+

August 23, 2016 Posted by Jason Irwin ,

I ran into the following error when launching the simulator in Android Studio on my Macbook Pro today:

emulator: ERROR: Unfortunately, there's an incompatibility between HAXM hypervisor and VirtualBox 4.3.30+ which doesn't allow multiple hypervisors to co-exist. It is being actively worked on; you can find out more about the issue at (Android) and (VirtualBox)

For me the fix was a simple one. I run Docker Beta on the same box. Apparently the hypervisor doesn't like this. So, in order to run the simulator, all I had to do was exit Docker completely. Not ideal, but a quick fix...

Tuesday, June 30, 2015

Issues with default git editor

June 30, 2015 Posted by Jason Irwin , No comments

Sublime is my editor of choice, but I guess at some point in the past I used Textmate as I recently started running into some Textmate-related issues when pulling code from GitHub. Effectively, when pulling code from GitHub for a merge. I got an error stating that the mate command could not be found.

$ git pull origin masterFrom * branch            master     -> FETCH_HEADCan’t find (error -10814)error: /usr/local/bin/mate -w died of signal 6error: There was a problem with the editor '/usr/local/bin/mate -w'.Not committing merge; use 'git commit' to complete the merge.

I assumed the issue was related to my global git config or my bash profile but, after much digging, the issue was in fact caused by a GIT_EDITOR environment variable

$ echo $GIT_EDITOR/usr/local/bin/mate -w

Unsetting this variable got things working again


Thursday, June 4, 2015

Intel Quick Access breaks Sublime Text Hot Keys

June 04, 2015 Posted by Jason Irwin

CTRL-ALT-UP and CTLR-ALT-DOWN are two hotkeys that I use *all the time*. They’re used in Sublime to execute multi-select on the previous/next line. Mulit-select is one of those features that is difficult to live without once you’ve experienced it and when I set up my new laptop the shortcuts didn’t work correctly.

As it happens those same shortcuts were kidnapped by Intel’s graphic features. What once made me productive was instead hijacked to rotate my display clockwise and counter-clockwise (not something that the majority of people would need a hotkey for, but I digress…)

Anyhow, one would assume that disabling hot keys via Intel’s Graphics Options menu would do the trick, but alas it did not.

Instead it is necessary to override each hotkey via Intel’s HD Graphics Control Panel (thanks a lot, Intel)

I’m back to running at full speed with keyboard-invoked multi-select in tow. Happiness.

Wednesday, June 3, 2015

Windows 7 - %windir% is not recognized as an internal or external command

June 03, 2015 Posted by Jason Irwin

I’m in the process of getting acquainted with my new work laptop, a Lenovo W550s. I’ve had the laptop for a couple of weeks now, and very recently, and randomly, strange things started to happen.

I started getting weird error messages when I attempted to perform any kind of system related tasks and couldn’t modify the domain I was connected to.

Icons in the start menu (Command Prompt, Paint, Snipping Tool, etc.) changed from meaningful to generic, indicating that something was wrong.

I came very close to reimaing by brand new laptop, until the realization that %windir% was not accessible led me to the hunch that my path was corrupted. It wasn’t corrupted, it was just too long. While my user path was short and sweet, the system path environment variable was full of garbage, weighing in at 2164 characters, full of references to varying pre-installed lenovo and intel software. After some more digging it appears that Windows can handle up to 2048 characters but no more. After saving out the old path I removed a bunch of (what I perceive to be) junk, rebooted, and things are back to normal. Phew!

Wednesday, October 1, 2014

TSQL–Calculating Date of Irish/UK Mother’s Day

October 01, 2014 Posted by Jason Irwin No comments

While in the US Mother’s day falls on the second Sunday of May, in western Europe things are a little more complicated. Mother’s Day falls on Mothering Sunday which is the 4th Sunday in Lent. I couldn’t find a T-SQL script to calculate this date, so I rolled my own (with a little help from SO). Let me know if you can have a more succinct method of capturing the same. Here’s the script:

DECLARE  @year INT, 
@EpactCalc INT,  
@paschal_days_calc INT, 
@num_of_days_to_sunday INT, 
@easter_sunday_month INT, 
@easter_sunday_day INT,
@easter_sunday DATETIME,
@start_of_lent DATETIME
SET @year = 2014
SET @EpactCalc = (24 + 19 * (@year % 19)) % 30 
SET @paschal_days_calc = @EpactCalc - (@EpactCalc / 28) 
SET @num_of_days_to_sunday = @paschal_days_calc - ( 
	(@year + @year / 4 + @paschal_days_calc - 13) % 7 
SET @easter_sunday_month = 3 + (@num_of_days_to_sunday + 40) / 44 
SET @easter_sunday_day = @num_of_days_to_sunday + 28 - ( 
	31 * (@easter_sunday_month / 4) 
SELECT @easter_sunday = CONVERT      (  SMALLDATETIME, 
    + RIGHT('0'+RTRIM(@easter_sunday_month), 2)  
    + RIGHT('0'+RTRIM(@easter_sunday_day), 2)  
SET @start_of_lent = DATEADD(DD,-46,@easter_sunday)
set datefirst 7 -- Sunday
DECLARE @days_to_first_sunday INT, @days_to_fourth_sunday INT
SET @days_to_first_sunday = 7 - datepart(dw, @start_of_lent)
SET @days_to_fourth_sunday = 28 - @days_to_first_sunday
select DATEADD(DD,  @days_to_fourth_sunday, @start_of_lent)

Thursday, April 3, 2014

Review: You Don't Know JS: Scope and Closures

April 03, 2014 Posted by Jason Irwin , No comments

Disclosure: I received a review copy of this title from O’Reilly

You Don't Know JS: Scope and Closures

I have three main criteria when purchasing educational content – how much knowledge I can garner (bonus points for anything that I can use in the real world), the time investment required on my part and cost. You Don’t Know JS: Scope and Closures does well on all 3 fronts. The book is short and sweet, inexpensive (the eBook was $8 at time of writing) and informative. It weighs in at 78 pages (including appendices) and is the first in the multi-part You Don’t Know JS series, focusing exclusively on a small subset of the Javascript language – scopes and closures. This exclusive focus enables the author, Kyle Simpson, to cut through the fluff that usually forms a good portion of more general titles and deep dive into this narrow (but important) topic.


The book is detailed and doesn’t veer away from tricky concepts. At the same time is a very quick and pleasant read – one could easily read it cover-to-cover (including the appendices which were quite interesting) in a single sitting. This might be off-putting to some, but I learned a few new concepts and definitely expanded/reinforced my understanding of existing concepts. As such, in my mind the return on investment is quite high. The title is quite accessible and contains code examples to support each concept. I’d recommend it to developers of any level and think it would be a great foundation for beginners, helping them to avoid frustrating pitfalls caused by misunderstanding of how scope works. It is just as relevant to intermediate/advanced developers – I can only imagine the number of veteran JavaScript developers who don’t fully understand why scope and closures work the way they do.


I’m a big fan of this title and look forward to the next installment in the You Don’t Know JS series.