Statistical population javaScript examples

A Statistical population is not always what the name might suggest. A Statistical population could be census data, however it could also be just about any collection of standard data in general actually. Much of what is done in statistics involves at least some kind of collection of data, in some kind of standard from. Things are then drawn from that population of data than can then be used to make sense of it.

For example say you have a population of data that is a collection of objects, and each object represents certain properties of a Blog post on a website. The properties might be the total word count of the post, the subject, how much traffic it received, and how much money it made over a certain uniform time period. There would then be all kinds of additional code that can be used to pull samples from that collection of objects, and generate other populations of objects that might contain the average amount of money made per word per post collection for example. The results can then be presented in the from of graphs, sorted indexes, and any other means to help paint a picture of what is working, and what is not. Knowledge of the results can then be used to make informed derisions when it comes to what to write about next, and what content might need additional attention when it comes to editing and promotion.

Read More

Node path resomve method and absolute rather than relative paths

In nodejs there is the path module and the resolve method of that module than can be used to resolve a relative path to an absolute path. A relative path can be a string representation of the current working directory, or to some other path that is relative to an assumed starting point. It is generally a good idea to think more so in terms of absolute paths to things rather than relative ones to help eliminate confusion, and as such I generally use absolute paths unless for some reason I must use relative ones.

Read More

A planet of mine canvas example clone

This week I wanted to aim for making at least one new canvas example post even if it is just another clone of something, or even just an attempt at a clone of something. I have this idea in my head that if I make enough of these I will end up with one or two that I will end up moving forward with into some kind of long term, interesting project that will be worth further investment of time. In the process of doing so I will likely end up with a whole bunch of canvas examples that will never progress beyond a simple prototype state of sorts.

I do not spend that much time playing games these days, but I do have a few installed on my phone and one that I have been playing around with a little is called a planet of mine for android.

The game is a pretty cool concept you have a starting world and two starting workers that can be used to build structures on land tiles of the world. There are many resources that can be gathered, one of which is used to power a rocket ship that can be used to go to another world in a solar system. There is even more to it than that, but that is the basic idea of the game.

I liked the game so much that I though I would start to work on a clone of the game that is not all that different from it. I was not able to clone every aspect of the game, but I did get to a very basic working first prototype of the concept thus far. If I get around to it I might come back to this one at some point in the future as i keep making canvas examples like these in a effort to try to find something that I would not mind working on for a while longer.

Read More

Uint8arrays in javaScript

In javaScript there are a number of constructors that provide typed arrays, one such constructor is the Uint8Array constructor. These kinds of constructors create index collections similar to that of a regular javaScript array, only they are a little different when it comes to the values that can be held in them.

For starters the length of the collections is static, and the values that the collections can hold is restricted to number values. On top of that the number values are also restricted depending on the kind of typed array, for example a uint8 array is restricted to a one byte number range between 0 and 255. So these typed arrays are not a replacement for regular javScript arrays that do not have these restrictions and can hold any kind of value, but typed arrays still come in handy when working with binary data.

So then typed arrays are helpful when working out something that is an underlaying binary data buffer value of some kind for one thing, and more often then not that is what they are used for. The reason why is because of the fixed size, and the fact that values are restricted to numbers only, and on top of that additional rules for the integers, or float values depending on the kind of typed array that is used.

There is also both clamped, and un-clamped versions for many of these typed arrays that has to do with what happens when a value goes out of the number range. There is clamping a value so that a value higher then 255 end up being 255, and a value below 0 will be 0. Then there is warping, or in other words allowing for a value to wrap around and work out to what is left when dividing.

So there is a bit to cover when it comes to a uint8 array, and typed arrays in general. In this post I will be looking mainly at the Uint8Array constructor, but much of what is written here can be applied to other type array constructors.

Read More

lodash xor array method aka symmetric difference

In lodash there is the _.xor method that can create a new array that is the symmetric difference of the given arrays. In other words it will be an array of elements that show up in the arrays that are unique to each array, but not elements that are shared across all the arrays. In other words elements that are intersections for onw or more of the arrays will not be included in the resulting array. So then the lodash xor method is yet another method in lodash that can be used to create a new array from a collection of other arrays. There is then more than one way to go about doing what the xor method does with other lodash methods, as well as with plain old vanilla javaScript as well.

Read More