I am Hack Sparrow
Captain of the Internets.

JavaScript – Check Object Types

There are times when you want to know the object type of an instance in JavaScript, whether it is an Array, or a Function, or an Object, a String etc. There are two flavors to doing that, one involves the use of the instanceof operator, the other involves stringification of the object's prototype. Follow the examples below, I show both the techniques. First create these variables: [code] var a = []; var o = {}; var s = ''; var n = 42; var f = function() {}; ...

Python: split string method and examples

So you are looking to break up a string into smaller strings (in an array if you are coming from a PHP / JavaScript background) based on a delimiter or character. Python provides a very straightforward and easy function to do that. The function is called split, it returns a list as the result (you really don't want to a Python array for this one) and here are some examples. Examples 1 to 3 are to be tri ...

Python: check if a character or substring is in a string

Let me start with a little history about myself. I have been developing on the Web for more than five years now - in PHP. Yes, in goddamn PHP! I had been exposed to Python much earlier, but for some strange reason I never made the effort to learn it or use it. If I had learnt Python earlier, I wouldn't be struggling to to check if a substring exists in a string or not today. On the brighter side, I realize what a beauti ...