Samuel MacLachlan

Count integer occurrence within number range

The digit "1" appears twice between 0 and 10.

Sometimes in life, you need to find out weird facts, such as how many times the digit 1 occurs in a number range sequence of 0 to 10 (the answer is 2 times, appearing as "1" and the "1" in "10"). This came up a couple of years ago in a Reddit discussion thread that I was involved in (will post the link if I can . . .

Read More

Posted in: programmingtools

April 02, 2016

Testing Browser Feature Support With JavaScript

Testing feature support without Modernizr

For robust browser feature detection, Modernizr is an exceptional tool with which you can specify which tests are included in the library download. But what about those times when you only need a single, simple non-critical feature test? You can write the test yourself.

On a recent website project, I needed to display a . . .

Read More

Posted in: programmingtools

April 01, 2016

JavaScript Powered Ratio Calculator

JavaScript can make your life easier.

I see your math challenge and ratio a calculator (pun intended)

I recently created a new tool for a friend which essentially helps calculate a value based on a ratio. For example, if the chosen ratio is 16:9, if a is = 1920, then b = 1080. Essentially, if you populate the a field, the calculator will give you the value of b and vice . . .

Read More

Posted in: programmingtools

March 30, 2016

Automating Line Break Removal

And some white space while we're at it too.

I like to write small utilities to make my life easier (mostly forwork). My job often entails tasks that are repetitive or at least periodically recurring.

One such task is adding a machineKey tag to the web.config file of the web applications installations we deploy.

While there are a number of ways to generate a . . .

Read More

Posted in: programmingtools

December 07, 2015