Showing posts with label JavaScript. Show all posts
Showing posts with label JavaScript. Show all posts

Monday, 13 April 2015

Type A/B, jQuery, Loops in JavaScript

1. Type A and Type B

The original Type A and Type B tests were funded by the tobacco industry and the link between heart disease and personality type is disputed.

2. jQuery

jQuery was originally called JSelect but because the domain jselect.com was taken, John Resig had to come up with a new name. Apparently, there was also Java SQL library also called jQuery, before JavaScript's jQuery, but they had let the domain lapse. Source: Annotations on an early version of jQuery by John Resig.

3. Loops in JavaScript

There are risks with hoisting and scope when using for-loops in JavaScript so in general it's better to use underscore's _.each function. However, for a simple loop and where response time is critical, creating _.range in order to use _.each outweighs the benefits.

Saturday, 11 April 2015

Vaccinations, TypeScript, Hebrew Numbers

1. Vaccinations in the UK

It's important for the population for a large percentage (usually somewhere around 90% depending on the disease) to be vaccinated to provide herd immunity (if enough are vaccinated, the disease can't jump from person to person and so is unable to spread much.) Herd immunity helps to protect children too young to have the vaccine, and those who have compromised immune system such as those receiving cancer treatments or with AIDS.

Different countries have different policies to attempt to achieve this. In the article Should childhood vaccination be compulsory in the UK?, I learnt some of the issues determining policies. One of the problems of forcing children to be vaccinated is that it erodes trust between the parents and health provider, and between the parents and government. Parents who do not vaccinate their children tend to do so because of a fear of doing harm, a fear as to the safety of vaccines, or the belief that their child will not catch the infection, or if they do, it will not be severe.

Vaccination in the UK is not compulsory, yet there is a high uptake.

2. TypeScript

TypeScript is a superset of JavaScript which means that any JavaScript file is already a TypeScript file. TypeScript compiles into JavaScript (ES3, ES5 or ES6). It has type annotation, where you declare a type such as in

var x: number = 3;
and type inference, where it knows the type from what you set the variable equal to. In the next example, it infers that x is of type number.

var x = 3;

Since TypeScript is compiled into JavaScript, it has no impact on runtime.

3. Hebrew Numbers

Hebrew numbers are written using the letters in the alphabet, so א is used to represent 1. In order to show that it's the number 1 instead of the letter, it is prepended by ׳ giving ׳א. Numbers not represented by the letters of the alphabet, are formed by summing, so 12 is written using the symbols for 10 (י) and 2 (ב) giving י״ב. The ״ is used to show that it is a number rather than a word. It is placed before the last number (reading right to left) so 780 would be written as תש״פ where פ is 80, ת is 300, and פ is 400. Note that Hebrew is written from right to left, with the usual convention that the smallest number is on the left. There are some exceptions. To avoid writing the names of god, 15 is written as 9+6 ט״ו‎, and 16 as 9+7 ט״ז‎‎. Sometimes the order is rearranged to avoid words with negative connotations.

Wednesday, 1 April 2015

Grep, Dry Skin, W3C Tools

1. What grep stands for

The first thing I learnt today is that grep stands for globally (g) search a regular expression (re) and print (p). (Thanks Jennie.)

2. Dry Skin

Apparently udder cream is really good for very dry skin. Yes, udder as in the thing cows have. I'd never heard of udder cream before.

3. W3C tools

Unicorn

I knew about W3C's HTML validator and CSS validator but I didn't know there is a combined tool called unicorn.

Cheatsheet

All I can say about this is how did I not know about it?

w3c cheatsheet showing search box and tabs

The cheatsheet has search functionality for HTML, JavaScript, CSS, SVG, and XPath, as well as guidelines on accessibility, mobile best practices, typography, and internationalisation.

The Beginning

I'm going to challenge myself to learn three things every day. They can be small things like the meaning of a new word or bigger things like a whole new concept, or maybe how to make something, or a new cooking technique or just cementing a concept. So what are today's new things?

1. JavaScript and NaN

JavaScript has so many gems. Consider the following:

var x = NaN;
var y = x === x;

So what is y? Is it true or false? Spoiler (highlight area to read): It's false. I knew what NaN === NaN would give but then I wondered whether using a variable would make a difference? For instance, {} === {} is false, but what is y in the following?

var x = {};
var y = x === x;

In this case what is y? Spoiler: It's true.

2. The Importance of Companies Showing They Care

Yesterday, I finished off the Thinkful Modern Web Design course, and today I had my exit interview. The exit interview was for me to give feedback on the course. Someone taking the time to ask me what I thought of the course, to listen to my feedback and to show appreciation of the feedback, harsh as it was, gave me a very positive view of the company and whether their courses are worth taking. (My mentor was amazing, but I think the course itself needs some work. Given that someone took the time to personally gather feedback by meeting with me, I am confident that Thinkful takes feedback seriously and will actively work towards improving their courses.) For me, this cements the idea that it doesn't matter what a company might say about caring, what really matters to me as a consumer of their services is the action. They showed me they care.

3. Software Engineering Myths

I thought that the 10x engineer term that I've heard a lot recently was just a trendy over-the-top description that didn't mean anything. I found out today that it is based on data from the 1970s, a whole different world in computing. I can imagine that maybe back then, it could be true that one programmer was 10x better than some other since there was no Google, no easy way to look things up, no quick cycle to test and correct your code, and it could even take a day to see if your code runs properly.