Skip to content

Instantly share code, notes, and snippets.

View mohanmca's full-sized avatar

Mohan Narayanaswamy mohanmca

View GitHub Profile
@mohanmca
mohanmca / destructuring.js
Created August 19, 2017 06:52 — forked from mikaelbr/destructuring.js
Several demos and usages for ES6 destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
@mohanmca
mohanmca / protips.js
Created August 19, 2017 06:48 — forked from nolanlawson/protips.js
Promise protips - stuff I wish I had known when I started with Promises
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");
@mohanmca
mohanmca / easing.js
Created August 19, 2017 06:19 — forked from gre/easing.js
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
// no easing, no acceleration
linear: function (t) { return t },
// accelerating from zero velocity
easeInQuad: function (t) { return t*t },
// decelerating to zero velocity
@mohanmca
mohanmca / answer.md
Created August 19, 2017 03:46 — forked from non/answer.md
answer @nuttycom

What is the appeal of dynamically-typed languages?

Kris Nuttycombe asks:

I genuinely wish I understood the appeal of unityped languages better. Can someone who really knows both well-typed and unityped explain?

I think the terms well-typed and unityped are a bit of question-begging here (you might as well say good-typed versus bad-typed), so instead I will say statically-typed and dynamically-typed.

I'm going to approach this article using Scala to stand-in for static typing and Python for dynamic typing. I feel like I am credibly proficient both languages: I don't currently write a lot of Python, but I still have affection for the language, and have probably written hundreds of thousands of lines of Python code over the years.

@mohanmca
mohanmca / hyperapp-intro.md
Created August 14, 2017 11:41
HyperApp – 1 KB JavaScript Library for Building Front-End Applications
@mohanmca
mohanmca / The Technical Interview Cheat Sheet.md
Created July 23, 2017 09:59 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.

4 problems with callback

  • Call back hell
  • Underyling concurrency is complex
  • callback called more than once
  • changes the error sequence (not like try-catch)

Event Handler

  • Events are not handled as first-class value in handler, as handlers ignores return value of handler
  • Can't compose two event handlers
@mohanmca
mohanmca / scalacheatsheet.md
Created June 2, 2017 01:49 — forked from lncohn/scalacheatsheet.md
Scala Cheat Sheet

Cheat Sheet

This cheat sheet originated from the forum, credits to Laurent Poulain. We copied it and changed or added a few things.

Evaluation Rules

  • Call by value: evaluates the function arguments before calling the function
  • Call by name: evaluates the function first, and then evaluates the arguments if need be