Latest from Chris West

JavaScript Snippet – Convert HTML Table To 2D Array Aug 21, 2016
at 11:09AM

A few days ago I was working on manipulating data that I found in Wikipedia. The data was in a table where the colspans and rowspans were making it difficult to simply programmatically pull data. Then I started looking into code to turn HTML table to JSON but for some reason the rowspans were still […]

JavaScript Snippet – isValidVarName() Aug 17, 2016
at 12:14PM

Now Available in YourJS Recently I was working on a function which needed to determine whether or not a string could be used as a variable name. Variable name validation can get tricky so instead of using a crazy regular expression which includes all keywords (which may change over time) and instead of testing for […]

Installing Watchtower Library on Mac with Wine Apr 2, 2016
at 2:25AM

Instead of always switching to your PC or using a VM just to use the Watchtower Library you can use Wine. Here is how you can do it: Go to the WineBottler home page and download WineBottler (which comes with Wine). Open the image file (the DMG file that you downloaded) and drag-and-drop both Wine […]

JavaScript – Detecting Infinite Loops Mar 16, 2016
at 6:28PM

When allowing a user to input code that could potentially cause an infinite loop, it is nice to test the code first, right? Even, if the code doesn’t run infinitely, it would be nice to know if it takes longer than you would want. One way to nicely test for infinite loops or long running […]

JavaScript Snippet – Recurse A Directory Synchronously Feb 26, 2016
at 12:21AM

Recently I took a look at making HTML5 programs that will work on Mac, Linux and Windows via Electron and needed a way to recurse a directory synchronously in Node.js. I ended up with the following code: The above function allows us to recursively get the contents of a directory. It also provides the ability […]

PHP Snippet – array_splice_assoc(…) Dec 27, 2015
at 11:07AM

Recently I was working on something that required inserting key-value pairs into an array after a specific key in PHP. As I was looking through stackoverflow answers I realized that there was no awesome answer that really jumped out at me. Therefore I decided to take a few minutes to just write my own array_splice_assoc() […]

Game – Bible Book Master Dec 26, 2015
at 3:44PM

Yesterday I really wanted to make a multi-lingual so I decided to make a game in which you have to go through all of the books of the Bible as fast as you can. I still need to do some work on the game to make it more user-friendly, but the following (which can also […]

Game – Where’s the Nose that Knows? Dec 25, 2015
at 12:18AM

I noticed that lately there has been interest in finding a panda in a large array of snowmen in this post. There was also this post where you have to find a cat amidst a great deal of owls. I started thinking about how I could make a similar game that is randomly generated. I […]

PHP – Re-indexing 2D Array By A Specific Key Dec 16, 2015
at 12:29PM

Today I was working on a personal project and wanted to be able to use a native PHP function to re-index a 2D array so that the key for each sub-array was pulled from a value in that sub-array. Unfortunately I wasn’t able to find a way to simply do it natively although it may […]

365.2425 Days in a Year? Dec 15, 2015
at 5:18AM

I was looking through some of the posts on Google+ and noticed that one of Douglas Crockford’s posts alluded to the fact that there are 365.2425 days on average in a year. At first I thought that the number should’ve actually been 365.25 due to us seeing a leap year every 4 years, but then […]