The less-than-random ramblings of Scott Jackson, software architect.

No Such Comfort

The Nightmare of Favicons

Posted by scottj on April 19, 2017 in Uncategorized with No Comments


Would you like to read about the evolution of Favicons?

tl;dr? Here’s a tool that will solve (nearly) everything for you. They also have a tool on that page to check that everything is honky-dory with your favicons.

For my node prototypes, I create explicit static routes for each of the files it generates. Here’s an example.

module.exports = function (app, express) {
// must be hosted in the root directory for maximum compatibility
app.use('/android-chrome-192x192.png', express.static('public/favicon/android-chrome-192x192.png'));
app.use('/android-chrome-512x512.png', express.static('public/favicon/android-chrome-512x512.png'));
app.use('/apple-touch-icon.png', express.static('public/favicon/apple-touch-icon.png'));
app.use('/browserconfig.xml', express.static('public/favicon/browserconfig.xml'));
app.use('/favicon-16x16.png', express.static('public/favicon/favicon-16x16.png'));
app.use('/favicon-32x32.png', express.static('public/favicon/favicon-32x32.png'));
app.use('/favicon.ico', express.static('public/favicon/favicon.ico'));
app.use('/manifest.json', express.static('public/favicon/manifest.json'));
app.use('/mstile-70x70.png', express.static('public/favicon/mstile-70x70.png'));
app.use('/mstile-144x144.png', express.static('public/favicon/mstile-144x144.png'));
app.use('/mstile-150x150.png', express.static('public/favicon/mstile-150x150.png'));
app.use('/mstile-310x150.png', express.static('public/favicon/mstile-310x150.png'));
app.use('/mstile-310x310.png', express.static('public/favicon/mstile-310x310.png'));
app.use('/safari-pinned-tab.svg', express.static('public/favicon/safari-pinned-tab.svg'));
};

For node prototypes using pug as the templating engine, I also create an include to handle the meta tags.

link(rel='apple-touch-icon', sizes='180x180', href='/apple-touch-icon.png')
link(rel='icon', type='image/png', href='/favicon-32x32.png', sizes='32x32')
link(rel='icon', type='image/png', href='/favicon-16x16.png', sizes='16x16')
link(rel='manifest', href='/manifest.json')
link(rel='mask-icon', href='/safari-pinned-tab.svg', color='#ffc40d')
meta(name='theme-color', content='#ffc40d')

(link) Why I use Tape Instead of Mocha & So Should You

Posted by scottj on April 13, 2017 in Custom Development, Debugging, Testing with No Comments


I must say I’m enjoying Node JS development. I’m starting to lose track of things though, so I need to be writing down my thoughts here. Right now, this is just a link to another blog regarding a Node JS test framework.

Why I use Tape Instead of Mocha & So Should You

High DPI on CentOS 7.2

Posted by scottj on December 8, 2016 in Uncategorized with No Comments


In VirtualBox on a Retina Macbook Pro, you can turn on HiDPI support. Your copy of CentOS 7.2 will have some microscopic text! Surely Linux can support HiDPI displays, right?

Well, I’d class it as “experimental” at the moment, but there are some things you can do. First, from ArchWiki comes a command that does wonders for the logged in user:

gsettings set org.gnome.desktop.interface scaling-factor 2

This does not affect the initial log in screen when first starting the VM, however. I’m not sure how to effect that, so if you know, please feel free to add a comment!

Next, from PCWorld, comes a utility that may help:

yum install gnome-tweak-tool

The PCWorld instructions will tell you to set the Window Scaling to 2 using this tool. In my experience, this does scale windows and desktop icons, but doesn’t appear to scale the Gnome toolbars. Your mileage may vary, but it doesn’t seem to be necessary if you use the ArchWiki command instead.

The tool does have some other tweaks that may be useful though, including text rendering settings and swapping around control, option and command keys, if these fits your preference.

I have not found a way to adjust the icon grid. It seems a little off with the new settings. Any tips there would be appreciated.

CentOS Minimal, Revisited

Posted by scottj on March 24, 2016 in Custom Development with 2 Comments


It’s been a long time since CentOS 6 came out.  We’re well into the healthy lifespan of CentOS 7 now, and the process of getting a minimal desktop has changed a little.

First, the install GUI, even for a minimal install, will guide you through setting up an admin user, so we can skip that.  It’s just a matter of installing the X Window System and the smallest slice of Gnome we can manage.

yum groupinstall -y "X Window System" "Fonts"
yum install -y gnome-classic-session control-center gnome-terminal
unlink /etc/systemd/system/default.target
ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target

And that should do it. You’ll have nothing but Gnome Desktop, admin tools and Gnome Terminal.

Now I didn’t include this last time, but if you’re setting up in a VirtualBox VM, before you reboot, you’ll also want to install the VirtualBox Tools…

yum install -y epel-release
yum install -y dkms bzip2 kernel-devel-$(uname -r)
mount /dev/cdrom /media
/media/VBoxLinuxAdditions.run

Happy clean and minimal developing!

CentOS 6 Minimal

Posted by scottj on September 12, 2014 in Custom Development with No Comments


I’ve come to enjoy using CentOS 6 as installed from the minimal CD.  Once it is installed, all you get is a login prompt and a root user.  I take the following steps to set up a personal account:

useradd administrator
passwd administrator            
usermod -G wheel administrator
visudo
# uncomment line allowing wheel to use sudo
vi /etc/pam.d/su
# uncomment line requiring wheel to su to root
vi /etc/aliases
# alter line redirecting root's mail

Then I install a very minimal desktop. These instructions assume you’re root, if not, you’ll need to sudo them.

yum groupinstall "Desktop" "Desktop Platform" "X Window System" "Fonts"
vi /etc/inittab
# boot into runlevel 5 instead of runlevel 3

When you’re done, don’t forget to yum upgrade.

Cleaning a Database

Posted by scottj on June 28, 2012 in Debugging with No Comments


When developing against SQL Server, sometimes scripts accidentally get run against the [MASTER] database.  I created the following script to drop all foreign keys, views and tables from a database.  It worked in my case, but be very careful with it.  It has two checks (called out in red) in there for tables that were not part of my solution, and they may not cover every case.  If someone knows how to refine this to exclude all sytem tables, I would appreciate them correcting this in the comments.  Thanks in advance.

select 'ALTER TABLE [' + c.TABLE_SCHEMA + '].[' + c.TABLE_NAME + ']'
  + ' DROP CONSTRAINT [' + c.CONSTRAINT_NAME + ']'
from information_schema.tables t
join information_schema.table_constraints c
 on t.table_catalog = c.table_catalog
 and t.table_schema = c.table_schema
 and t.table_name = c.table_name
where t.table_name not like 'MS%' and t.table_name not like 'spt_%'
 and c.constraint_type = 'foreign key'
union
select 'DROP TABLE [' + t.TABLE_SCHEMA + '].[' + t.TABLE_NAME + ']'
from information_schema.tables t
where t.table_name not like 'MS%'
 and t.table_name not like 'spt_%'
 and t.table_type = 'base table'
union
select 'DROP VIEW [' + t.TABLE_SCHEMA + '].[' + t.TABLE_NAME + ']'
from information_schema.tables t
where t.table_name not like 'MS%'
 and t.table_name not like 'spt_%'
 and t.table_type = 'view'

Understanding View Models

Posted by scottj on April 10, 2012 in Custom Development with No Comments


A view model represents the state and behavior of a particular piece of UI—it is the non-framework-specific analogue of a control. Just as you can’t generally place the same control instance in two locations in a UI tree, you can’t also reuse the same view model instance.

If you could, we’d call it a ViewsModel 🙂
Bryan Watts

I remember spending time when learning MVVMlight debugging issues around the reuse of view models, and I thought such reuse was integral to MVVM.  In then end, and with much regret, I tore out all this reuse, replacing it with very simple code that created a new view model when views were instantiated.  I felt awful, scrapping the work that went into MVVMlight to do this.  And yet, after reading the above quote, I feel a little vindicated.  I’m sure there’s cases where you might want to keep a viewmodel instance around, but I’m still suspicious if this should be the default behavior.

Debugging Timeout in IIS 7.0

Posted by scottj on January 11, 2012 in Debugging with No Comments


I’ve been working in SharePoint, and when debugging against my local IIS 7.0 instance, there is a 90-second page timeout.  If you’re not done with what you’re investigating at a breakpoint within 90 seconds, IIS will terminate the process hosting your code and dump you unceremoniously.

The tweak is quite easy though.  Open IIS Manager, find the appropriate app pool, right-click it and choose Advanced Settings.  In the Process section, turn Ping Enabled to false.

This will make your debugging sessions much more leisurely, as IIS won’t proactively terminate processes anymore.  You won’t want to leave it like that on a test or production server as that’s how IIS determines if a process has hung so that it can be restarted, but it’s great for your own develpoment environments.

Setting Up a Development VM

Posted by scottj on June 21, 2011 in Custom Development with No Comments


I often set up development VMs.  Here’s some settings I like.

Turn Off the Shutdown Dialog
Almost always my first change, that annoying shutdown tracker may be the best thing since checking comments, in an audited IT environment, but it’s less than useless on a personal development VM.  Let’s get rid of it!  From Start -> Run:

gpedit.msc

Then visit  Local Computer Policy -> Computer Configuration -> Administrative Templates -> System -> Display Shutdown Event Tracker and pick “Disable”.

Turn Off NAT and Bridging
We’re about to configure Windows in one of the most insecure ways possible.  You don’t want this on a network anyone else can get to, even through your own actions.

Install Microsoft Security Essentials
Most companies I know are pretty good about requiring virus scanning “on the metal” of my laptops.  Very few have asked if I run an anti-virus on my VMs.  Security Essentials should be considered just that, your minimum, essential security.  Did I mention these VMs are going to be pretty darn insecure?  And remember, your VM is usually powered off, so when that status icon goes orange or red, please run a manual scan, eh?

User Accounts
On “my” VMs, my login is always my usual network account name.  My password is not.  It’s something well known throughout whichever consulting company I work for, usually the consulting company’s name, proper case, followed by the number 1.  The point here is that I should be happy to give this password out to any of my coworkers, in the case I’m “hit by a truck” and want them to pick  up where I left off.  If the VM is intended to be shared around, the login will be the company name, all lower case instead.

Registration
All VMs should have correct registration information with my full name, and the common name of my firm.  Registration information isn’t easy to correct, and doesn’t seem to be set by default installations of Windows 7 or Windows Server 2008 anymore.

reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v RegisteredOrganization /t REG_SZ /d "No Such Comfort" /f
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v RegisteredOwner /t REG_SZ /d "Scott Jackson" /f

Thanks to win2008workstation.com for these tips.

Turn Off User Account Control
User Account Control just slows you  down on a development VM.  I shut it off.

Auto Login
Since the idea of a development VM is to boot-and-get-to-work, I set up auto login. From Start -> Run:

control userpasswords2

Uncheck the box requiring a password. If it’s already unchecked, check and re-uncheck it. Click Apply and you’ll be prompted for the login credentials to use.

If you join a computer to a domain, that handy checkbox is gone.  To get it back we can do:

reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d "1" /f

Also, you will likely need to provide the default login domain for the account you used via:

reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultDomainName /t REG_SZ /d "domain" /f

Thanks to Jeff for these tips.

Make Sure Auto Login Sticks
Once you do the above, if you cold-boot the VM you’ll be logged in, but if you suspend it, or just walk away too long, you’ll likely be asked to log in again.   On the start menu, search for “Require” and open “Require a password when the computer wakes”.  Turn that right off.  You may also want to visit the power options and turn off the display timeout, and double-check the screen saver, making sure it doesn’t require a password, if you use one at all.

Recycle Bin
Turn off the confirmation dialog when tossing stuff in the recycle bin. You’d probably do this anyway, but it’s always nice to remember to do so before you snapshot your VM, or you’ll be doing it over and over again whenever you revert.

Power Management
Useless on a VM, go ahead and turn on high performance and disable the screen timeout. By default the screen saver should already be disabled in modern shipping versions of Windows (in favor of the greener screen timeout and suspend settings).

Install Windows Updates on Your Schedule
There are few things more annoying than going to shut down your computer and finding out it’s going to install umpteen Windows updates.  Be sure to visit the Windows Update settings in the Control Panel, and choose one of the less-aggressive settings.  Since surprise changes to development environments are often to be avoided, I often choose Never Check for Updates.  Updating a development VM for me is a very long process that also involves shrinking disk drives and other fun.

.NET Data Services MERGE permissions

Posted by scottj on July 20, 2010 in Debugging with 1 Comment


With the help of a colleague and my client, we reproduced and diagnosed a permissions issue we were having with an elevation of a .NET Data Service from our development environment.  When executing MERGE queries through .NET Data Services, we would receive a 401.1 permissions denied error, and the update would fail.

The solution we found was that .NET Data Services appears to require file system Modify permission to the .svc file on the web server.  If the app pool user has modify permissions, the MERGE request succeeds.  If it does not, the request will fail as above.

Personally, I hope I find a better solution someday.  There is, in my opinion, no reason for the account my web service is hosted under to have permission to modify its source file.  Google, however, has failed me on this one; our searches haven’t found any relevant information yet.

Capricious Whim

“Einstein argued that there must be simplified explanations of nature, because God is not capricious or arbitrary. No such faith comforts the software engineer.” —Fred Brooks