Latest from Chris West

YourJS – 1st Pass Nov 8, 2015
at 2:13AM

I finally have the 1st pass of YourJS available to the public!!! What is YourJS? YourJS is a fully customizable JavaScript library which gives the developer more control than ever before. Who controls the codebase? Everyone does! All you have to do is sign up and you can start writing code that can be included […]

PHP – Problem with issetor() Nov 6, 2015
at 1:24AM

In case you haven’t seen it before, issetor() is a quick and dirty way of getting a value from a variable that may or may not be defined: function issetor(&$var, $default=NULL) { return isset($var) ? $var : $default; } One unfortunate side-effect that most people are unaware of is that even though you can use […]

PHP Snippet – array_filter_keys() Nov 4, 2015
at 3:08PM

While working on I was trying to figure out a quick way to use extract() to only convert some of the $_REQUEST values to variables in the symbol table. Then I realized I could use this: function array_filter_keys($array, $keys_to_include) { return array_intersect_key($array, array_flip($keys_to_include)); } Using this will give you a new array with only […]

Symbolic Mind Meld Oct 26, 2015
at 9:43AM

Your computer may be able to read your mind if you are good at simple math. Try it out below or go here.

YouTube Thumbnail Images Sep 9, 2015
at 2:26AM

Did you know that YouTube automatically generates thumbnail images for all videos? Each video gets the following four thumbnail images automatically generated:{VIDEO_CODE}/default.jpg{VIDEO_CODE}/1.jpg{VIDEO_CODE}/2.jpg{VIDEO_CODE}/3.jpg In addition to these thumbnail images, a larger still of the video is generated and stored in{VIDEO_CODE}/0.jpg. Try Me! I wrote the following JSBin example to display the […]

JavaScript Snippet – isClass() Sep 8, 2015
at 1:41AM

If you need to determine if a variable is actually a class (prototype) you can use the following function (isClass()): First of all, as was stated in the previous post, even though I use the word class, I am actually talking about prototypes. Secondly, this solution is actually incomplete because it is very difficult to […]

JavaScript Snippet – getClass() Sep 7, 2015
at 8:07PM

If you have been using JavaScript for a little bit you probably already know how to determine a variable’s class constructor, but just in case you are overthinking it here is a hint: variable.constructor. Of course, many times I like to make functions that will spit my results for me so here is one that […]

JavaScript – Getting Function Parameter Names Jun 26, 2015
at 4:33PM

Two years ago I wrote a post about how to pass arguments by name in JavaScript. Recently I have started to ramp a new project call YourJS and found a need to be able to read the names of the parameters of the given function. The following getParamNames() function takes an arbitrary function and returns […]

JavaScript Snippet – Using Degrees with Cosine, Sine & Tangent Mar 20, 2015
at 4:27PM

Yesterday I was working with Math.cos, Math.sin and Math.tan and was thinking it would be nice to have the equivalent functions which accept the values in degrees instead of radians. For that reason I wrote the following definitions for Math.cosd, Math.sind and Math.tand: After executing the above 5 lines you will be able to get […]

Python Quirks – List Concatenation or Mutation? Feb 19, 2015
at 1:23PM

If you execute the following code, what do you think will be the result? list1 = [1] list2 = list1 list2 += [2, 3] assert list1 == list2, '{} != {}'.format(list1, list2) list1 = list1 + [4, 5] assert list1 == list2, '{} != {}'.format(list1, list2) Will an assert error occur? The answer is yes! […]