Skip to content

Instantly share code, notes, and snippets.

View mohanmca's full-sized avatar

Mohan Narayanaswamy mohanmca

View GitHub Profile
@mohanmca
mohanmca / ShortestSubarrayWithSumAtLeastKFull.java
Created October 12, 2021 03:55 — forked from johnyleebrown/ShortestSubarrayWithSumAtLeastKFull.java
Shortest Subarray with Sum at Least K (partial solution)
class Solution
{
public int shortestSubarray(int[] A, int K)
{
IMQ q = new IMQ(K);
q.push(new Item(0, -1));
for (int i = 0; i < A.length; i++)
{
// rewriting array with prefix sums
@mohanmca
mohanmca / .block
Created May 24, 2019 22:41 — forked from mbostock/.block
Bullet Charts
license: gpl-3.0
@mohanmca
mohanmca / richhickey.md
Created April 18, 2018 13:47 — forked from prakhar1989/richhickey.md
richhickey.md

Rich Hickey on becoming a better developer

Rich Hickey • 3 years ago

Sorry, I have to disagree with the entire premise here.

A wide variety of experiences might lead to well-roundedness, but not to greatness, nor even goodness. By constantly switching from one thing to another you are always reaching above your comfort zone, yes, but doing so by resetting your skill and knowledge level to zero.

Mastery comes from a combination of at least several of the following:

@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.