object.create, applying prototypes

prototyping chaining, object extension for all the modern programmers var Ninja = function () {}; Ninja.prototype.throw = function (item) { console.log('Throwing ' + item); }; var Shinobi = function () {}; Shinobi.prototype = Object.create(Ninja.prototype); var shinobi = new Shinobi; shinobi.throw('knife'); // Throwing knife

1 min read
Read more →

frozen objects

objects are frozen, never to be extended or altered again class Ninja { constructor() { this.dead = false; Object.freeze(this); } } var shinobi = new Ninja(); shinobi.dead = true; console.log(shinobi); // Ninja { dead: false }

1 min read
Read more →

information hiding

object oriented information hiding done. closures: private methods class Person { constructor(name, dob) { var dob = dob; this.name = name; this.getBirthyear = () => new Date(dob).getFullYear(); } } var person = new Person('thejsninja', '1985-12-04'); console.log(person.getBirthyear()); // 1985

1 min read
Read more →

javascript, still a thing?

Javascript is a great, and expressive language. You can be as succinct or vague as you like, you can scratch the surface or leverage a really powerful event loop. alert('Annoying popup'); Lots of people just think of the annoying browser popup, but you can deeper than that. Classes can be defined, albeit through some syntax sugar over the top of javascript’s prototype inheritance. 'use strict'; class Person { constructor(firstname, lastname) { this.

1 min read
Read more →

what i am listening to june 2013

I think these posts might turn into a series! I was searching through soundcloud the other day and came across TheBluesMobile.com a blues show on soundcloud. The interview and bio/history of Hot Tuna brought me in, but then on came The California Honeydrops a blues / gospel / new orleans jazz band. I am now hooked and as soon as pay day comes around will be buying their new album Like you mean it.

1 min read
Read more →

get a stream of tweets

The first part of the course I have been taking on data science deals with analysis of Twitter data. This is aimed at discerning the overall sentiment of a Tweet or collection of tweets. To get this going the first thing you need is a big collection of tweets in a format that is easy for a program to digest. Step in JSON, a text based output that represents data in a collection of arrays.

2 min read
Read more →

what i am listening to: may 2013

It has been a while since I last put anything up here so I thought just sticking up a post with my latest listening experience might be the way to go. A while ago Wil Wheaton stuck a Zoe Keating track on This is my Jam called Tetrishead, fell in love with it while walking around the downs in Bristol (UK). So today while at my day job I am listening to Zoe Keating’s Album “Into the Trees”.

1 min read
Read more →

centre without text align center

CSS is great for changing things around on a page but knowing the best way to accomplish something when you are just starting out is difficult. So how do you centre block level elements, and what on earth are block level elements anyway? Well for a list of html elements that are block level check out the MDN site here: https://developer.mozilla.org/en-US/docs/HTML/Block-level_elements So now we know what they are what is the best way to centre them on a page or within a parent element?

2 min read
Read more →

testing login to an smtp server using telnet

So if you are having problems sending emails there is always one sure fire way to establish if the problem is your connection or not. This can be done using the telnet application, a command line tool that is included in most operating systems. To do this you will need to open the command prompt, on windows you can do this by pressing the windows key and tapping the R button once.

2 min read
Read more →

the c in css

CSS is a very powerful tool for web designers and developers, as with all great tools you need to know how to use it effectively to get things right. This article covers some fundamentals about the Cascading part of CSS to give you a better handle on how your CSS affects the HTML content of sites you work on. Cascade based on style location So, what does it mean by Cascade?

2 min read
Read more →