Saturday, December 31, 2016

JS30 Challenge Day1 - JS Drum Kit

Here are the things I learned from Day 1 of the JS30 challenge:

Github Link
  • HTML/CSS

Reminded me of putting the following in every project
<html lang="en-US">
<meta charset="UTF-8">
and optionally
<meta name="author" content="Arjun Khode">

To add the stylesheet, we use href and not src.
<link rel="stylesheet" href="style.css">

-We can find the keyCode of each key on the site keycode.info

What <kbd> does
The HTML Keyboard Input Element <kbd> represents user input and produces an inline element displayed in the browser's default monospace font.

I gave a transparent background to the drum item using rgba()

In box shadow, the 0 0 15px was not bright enough, so I used the 4th parameter ‘spread’ to make the shadow-spread more vivid, as: 0 0 15px 5px

The align-items in the flexbox wasn’t working by default because it had no height of its own. I had to give a height of 100vh to the flexbox element to get the contents to appear in the vertical center.


  • JS

We bind an event to our keys when they are pressed, as follows:
window.addEventListener(‘keydown’, function(e){}) //note keydown is in quotes. And it is window, not document.
document stands for DOM
and window is the global object in a browser, or the root object of the DOM

Inside the function, we write
const audio=document.querySelector(‘’);
the document.querySelector acts like $() in jQuery

Inside the querySelector, we write
`audio[data-key=“{e.key}”]` //where data-key has to have its value in double quotes, the whole querySelector expression has to be in back ticks (`) for template literal notation and the value is a variable inside the event e, which is called keyCode, a property of event 'e'.

${} is just syntactic sugar. Read more about it here (look for “Expression interpolation”)

So we get
const audio = document.querySelector(`audio[data-key=“${e.keyCode}”]`);

audio.play();
if we keep hitting a key, it needs to rewind to the beginning
so we add,
audio.currentTime=0; before audio.play(); The 0 stands for seconds.

I have defined a .play class in CSS which makes the items glow when the corresponding key is pressed

To add a class to an element, we use item.classList.add(‘className’);
This is the same as element.addClass(‘className’); in jQuery

Instead of removing the class play normally, we remove the play class on the transitionend event of the transform property

Regarding forEach, it is not just forEach but items.forEach(); which means that forEach function is a property of an array.

One final comment:
This app does not work well on Safari because it takes too long for Safari to parse the keydown event.
It works great on Chrome though.

UPDATE:

Here is the code to enable playing by clicking on the buttons as well



//code for click functionality
const items=document.querySelectorAll('.item');

function clickTrigger(){
let key=(this.dataset.key);
const audio=document.querySelector(`audio[data-key="${key}"]`);
const item=this;
item.classList.add('play');
audio.currentTime = 0;
audio.play();

}

function unclickTrigger(){
this.classList.remove('play');
}
items.forEach(item=>item.addEventListener('mousedown',clickTrigger));
items.forEach(item=>item.addEventListener('mouseup',unclickTrigger));

Explanation:

1.Select all item divs and call them "items"

const items=document.querySelectorAll('.item');

2. Attach mousedown and mouseup events to every item in "items" using forEach

items.forEach(item=>item.addEventListener('mousedown',clickTrigger));
items.forEach(item=>item.addEventListener('mouseup',unclickTrigger));

3. Create function clickTrigger and unclickTrigger

4. clickTrigger function explanation:

In clickTrigger, "this" variable will select the particular "item" div clicked.
Inside "this" we have a data-key property.

To access any data- element in JS, we use "dataset" property
So, if you have data-key, it becomes:

dataset.key

Store the data-key of the clicked item in a variable called "key"
let key=(this.dataset.key);

Then using key, select corresponding audio to trigger
const audio=document.querySelector(`audio[data-key="${key}"]`);

(Notice how "key" variable has been slid into the template string)

Then simply add the regular code to add to item a class "play" (for the animation)
and play the audio
audio.play();

5.unTrigger function explanation:

Simply remove the class play from "this" (which is the item div on which mouseup has happened)
This removes the animation

Friday, December 30, 2016

The 30 day Vanilla JavaScript challenge.

Hey guys! Today my friend Joel suggested me to take the 30 day vanilla JavaScript challenge. I'm just about to start the challenge. Basically you build a unique, working JavaScript program each day.
No jQuery, no pre-processors, no frameworks.
Videos are there to help. Check it out over here:

30 Day Vanilla JavaScript Challenge

You might need to signup with your email ID to receive the solutions to the problems.

Have fun and happy coding.
Cheers!

Audioengine D1 DAC Review

The first dilemma I had buying the Audioengine D1 was whether I should buy an audio interface like the Scarlett 2i2 or a dedicated DAC.

I chose the Audioengine D1 DAC because it has an optical input which can support a sampling rate of 192kHz. Just like more pixels per inch produce a crispier, sharper image, I believe that better sampling rate improves the profile of the audio.

So the first question is, does an external DAC make a difference in the audio quality?
My answer is, if you have $50 headphones or better, it surely does.
Firstly, it bypasses the circuit noise induced by the peripherals in the inbuilt sound-card of a pc. No noise itself refines the profile of the audio a great deal.
I tested this by connecting my Boss GT-100 guitar processor to my mac and bypassing the built-in audio. I connected headphones the the GT-100 and voila! Better sound quality! (And the D1 does it even better)

Secondly, a dedicated DAC that costs as much as an external audio interface is logically better. It is built for a specific function and the Audioengine D1 does the job well. To be honest, I was first disappointed in the quality of the D1 because it wouldn't produce bass. But that was until I connected my optical cable to the DAC and selected "digital optical output" in the Audio Settings. As soon as I did that, I got to experience 192kHz of deep thumping crisp, deep, heavy bass on my 1More triple driver headphones.

Finally, I love the overall quality of the D1. I got to hear things I have never heard in the songs I listen to everyday. For instance, noticing that Tove Lo has given backing vocals in Ellie Goulding's "Love me like you do". I noticed Tove Lo's high pitched backing vocals in the first chorus!
I'm sure there are a lot many things do discover in music and it's amazing how well the device renders audio for even Low-Fi music with just one guitar in it, like John Mayer's "Slow dancing in a burning room" from the Village Sessions.

An external DAC definitely makes a difference in the sound quality and renders better instrument separation. So if you're thinking of getting one and are not a pig who overlooks details in audio quality, you are good to go! It's worth the $169.

Don't make me think (Steve Krug) summary - Ch. 1& 2

Download link for the book:

Steve Krug - Don't make me think (Free download)

Ch. 1.Don't make me think

*Krug's first law of usability
Don't make me think.

Imagine you're using a site and think the following to yourself:
that's there, so this is that, here it is *click
That is what an ideal web experience should sound like

But web experience comes with questions. So, it is the designer's job to remove the questions.
Imagine thinking to yourself:
Where should I start? Why did they call it that? Are these two things the same? Can I click on that?

It is our job as designers to remove these questions.
Here are some solutions to remove some of these questions:

1.If there are doubts naming things, it is better to lean towards the more obvious, even if it is cliche. Imagine yourself searching for jobs online and find the following:

Jobs *yes, click
Employment opportunities *Hmm, jobs. Click
Job-O-Rama *Is it jobs or something else?

2.A user should never have to spend an extra millisecond thinking if some link or button is meant to be clicked or not. Consider the following:

A button that has gradients on the borders and reads 'Results' *Click
A button with no gradients that reads 'Results' *Hmm, click
An unordered list link that reads 'Results' *Is this meant to be clicked?

Also, it goes without saying that an arrow should turn into a pointing finger when hovering over clickable items. In CSS this can be done by a single line of code:
cursor:pointer;

3.Spend on parsing whenever feasible. A user should have to worry about framing their questions as less as possible. On some bookstore sites, you need to select from a drop-down 'title', 'keywords', 'author' or 'ISBN' and then enter the query. Amazon on the other hand just lets you type whatever you like and does the figuring out on its own.

4.Just like a good song, a self-evident page passes by quickly. Users spend effort on finding your web page. Users on the web are always on the go, they don't like to stop. But if a page is not self-evident, they still try to break their heads over finding what they are looking for in your page. This implies a good, optimistic leap of faith a designer must take, making the design of a page more self-evident.

Ch. 2.How we really use the web

There is a difference between how we think users read web pages and how they really read them. Mostly, they just glance over the page to find out if the page contains something interesting and clickable.

3 Facts of reading/glancing
1.We don't read web pages, we scan them.
We scan for phrases that match with our intention.

2.We don't make optimal choices
On the web, we often make decisions like we are in a hurry so we suffice with the first reasonable match we find.

3.We don't figure out how things work, we just muddle through.
An example is just how many people exist who try to enter URLs into Google's search box because they think Google is the internet.

Conclusion:
We thus learn the most important thing; it is not necessary to carefully craft exquisite literature inside a bulky web page, because users scan, not read.
A final quote,
"If your audience likes to treat web pages like billboards, design great billboards"

How to instantly improve the sound quality of your Mac

I am an audiophile and I love to push my audio quality to the limit.
So here's a quick way to improve your Mac's audio quality:
Open "Audio MIDI Settings"
Click on the Built-in audio tab
Select 2 Channel 32bit 96kHz
Voila! If you have good headphones (around $50 or more) you will surely begin to feel the panning and positioning of instruments spacially. It also makes instruments separation clear.
The logic behind this is that you are increasing the bit depth to 32bits and sampling frequency to 96kHz.
Sampling rate is the number of samples of digital sound (audio snapshots) that are taken per second. So just as more pixels per inch forms a clearer, sharper image, more sampling rate forms a clearer audio profile.
The default sampling rate is 44kHz, but if you have an optical TOSLINK cable, you can even push the sampling rate to 192kHz.
You would need an external DAC to run such a sampling rate though. The most popular DAC is the Audioengine D1 DAC. It acts like an external soundcard that bypasses your PCs sound circuit thus avoiding any circuit noise that gets mingled with the digital audio signal.
And that's your audiophile knowledge for the day!

Brainwavz M2 in-ear headphones review / Brainwavz M2 vs. 1More triple driver earphones

The Brainwavz M2 are the headphones to go for, if you're looking for comfort and a sound-quality that matches with headphones twice its cost.

First of all, these headphones come with a 2 year warranty and they cost around $50 on Amazon.
I have done sheer damage to these headphones while running and they fell off and came under my feet. I have stretched the wires by stepping on them at times, and they still ran well for 6 months.

The customer service is amazing! They care about their customers a lot. They have replaced and given me completely new pairs twice in 1.5 years. Both the times, the right ear had started to die out.

Having bought at-least 10 pairs of headphones in a year (I return the ones I don't like), the thing I have learned is that no matter how expensive the headphones are, they are useless if they don't fit well or hurt your ears.
The best part is that the Brainwavz M2 are super-comfy. I go to sleep wearing them almost everyday. The ear tips that come by default are soft and fit well. The isolation on these earphones is good, I would say about 65-70% of the acoustic noise is isolated by these. The cable is tangle free and makes no noise rubbing against clothes.

Brainwavz M2 vs. 1More Triple Driver Earphones

I had bought both these headphones about the same time.
I would have to say that, though Brainwavz M2 came for around $50 and the 1More for $100, the M2s give the 1More a tough competition.
The 1More do not fit very well and no matter which of the 10 ear tips they provide are used, they just bulge out of the ears, due to which, I'm not able to sleep on one side wearing them.
The 1More have 3 drivers and at times, you can tell that all the sound is coming from different places in the headphones. This makes them sound quite artificial as you would not want the bass of your guitar coming from a different point and the treble coming from another. It's like all the instruments' treble comes from one place and all of their bass comes from another.
The M2s on the other hand are single driver. They also have a much better bass response because of the excellent isolation they provide.
The clarity of the M2s is comparable with the 1More. The instrument separation is decent and is really good for $50 earphones. Almost at par with the 1More.

For me, the winner is M2s for the comfort, clarity, beautiful sound signature, sound quality, build and the customer service they provide. The 1More just come in a beautiful packaging, but their fit ruins everything. If the 1More came in the build shape of M2s I guess I would buy them again, but the M2s are clearly the winner and my go-to earphones for a few years until I buy custom made earphones or Bose for that matter.

Extra: Custom earphones ($69)
Check out this awesome Kickstarter for custom made earphones that uses AI and photography to match the shape of your ears:
HelloEar

What you must know to become a Front-end developer or Web-designer / Which one should you choose?

To become a great front-end developer, like any other skill, takes 10,000 hours of practice. That is around 4 years in 40 hour weeks. Here are some pointers I have gathered by reading about becoming a front-end developer and practicing the art over the course of 9 months:

-Start by learning to create layouts. No matter what, it is necessary to know semantically correct HTML inside-out. Although most of the people use boilerplate code, as the one I am using right now trying to learn React, it is important to fully understand how the layout of a web page works. This also includes learning about how a browser renders a page. (create the DOM tree > parse the style > render the layout > paint the page). It takes only 3 days to fully read and understand HTML, although every time you switch sources of learning, there is overlap of information. But it is worth it.
Once you learn CSS, you could go back to HTML to round off the information just right.

-Just like HTML, the next step is learning CSS. There are a few key concepts in CSS: Flexbox, float, the use of 'auto' in measuring dimensions, text-align, various types of 'display' and different types of 'position'. Currently, Flexbox is the holy-grail of layout creation, but a new technology called 'Grid' is coming out soon.
A great skill to invest in is SASS or SCSS. This helps you nest CSS containers inside one another, modularize the code and makes your job easy by taking care of cross-browser prefixes.

-After that, one must learn a little bit about JavaScript and jQuery; at least the DOM manipulation part. This much, both a web developer and designer must know. If you are looking to become a developer, you must start learning data structures and algorithms in JavaScript.
Here is a link to a free e-book about data structures and algorithms in JavaScript.

One must then start learning about advanced JavaScript technologies such as React and Angular.
React is currently gaining ground and Angular, losing ground as I have learned from a few front-end professionals.

If you are having doubts choosing between Web-development and Web-design or confused about how to enter the industry, there are various ways depending upon your qualifications. If you have a computer science background, it is almost always good to start as a web-developer. If you decide to invest serious time in UI-UX development, you could start as one provided you put in exclusive effort into it.
I had a designing phase in which I decided to just be a designer, but in my college at the time, I was mostly just coding. This lasted for 3 summer months, after which, I decided to embrace my education and become a web developer first, and then move to design slowly in the commercial ground.

This Quora article might help you understand the differences in fields to enter into the web industry.
And this Skillcrush article might help you know which one you should choose.

So, all the best for your career!


Welcome

Dive into the world to see how a Sagittarius: a poet, philosopher, abstract-thinker, a multi-phase, multi-tasking, over-indulgent artist immerses himself into the world of detail, scrutiny, careful planning, the perennial realm of web development.

Here, I will post everything I learn from here on out in front-end web development and maybe, it might help you.

-I am currently learning React.

I love design, eventually I want to become a graphic designer. My soul resides there. But contending for a masters degree in Software Engineering, I am also skilled in programming, development processes and team-work.

I like to treat myself by some unboxing therapy, especially headphones. In the Tech section of this blog, I will write reviews and opinions and some miscellaneous articles.

Welcome aboard. The flight to age 35, a.k.a the peak of one's career, takes off on the next post. Have fun!