Skip to content

Instantly share code, notes, and snippets.

View ggauravr's full-sized avatar

Gaurav Ramesh ggauravr

  • OpenTable
  • San Francisco
View GitHub Profile
@ggauravr
ggauravr / iris_plot.py
Last active December 27, 2015 03:48
this code demonstrates and describes basic visualization(2 out of four features) of the Iris Dataset, provided in the sklearn package.
from matplotlib import pyplot as plt
from sklearn.datasets import load_iris
import numpy as np
# load the dataset to be used
iris = load_iris()
# get the 150*4 features into varibale features
features = iris.data
@ggauravr
ggauravr / undeclared-typeof.js
Last active January 21, 2016 23:52
typeof with undeclared variable
(function() {
'use strict';
console.log(typeof someVariable); // prints "undefined"
})();
(function() {
'use strict';
console.log(typeof someVariable); // prints "undefined"
console.log(typeof anotherVariable); // also prints "undefined"
var someVariable;
var anotherVariable = "Defined";
})();
(function() {
'use strict';
var someVariable = undefined;
var anotherVariable = undefined;
console.log(typeof someVariable); // prints "undefined"
console.log(typeof anotherVariable); // also prints "undefined"
anotherVariable = "Defined";
(function() {
'use strict';
console.log(typeof someVariable); // ReferenceError!
let someVariable = "Defined";
})();
(function() {
'use strict';
let someVariable; // not even initialized to undefined, FTW !!
console.log(typeof someVariable); // ReferenceError
someVariable = "Defined";
})();
@ggauravr
ggauravr / popular-movies-2015-imdb.js
Last active February 21, 2016 21:14
Most Popular Hollywood Movies of 2015 from IMDb
@ggauravr
ggauravr / top-grossers-2015.js
Last active February 21, 2016 21:21
A list of top 100 grossers of 2015
var titleLinks = document.querySelectorAll('table a[href^="/movies/?id"]'),
titleArray = Array.prototype.slice.call(titleLinks),
titles = titleArray.map(function(link) {
return link.innerText + '@' + link.href;
});
// titles is an array like this:
// ["Star Wars: The Force Awakens@http://www.boxofficemojo.com/movies/?id=starwars7.htm",
// "Jurassic World@http://www.boxofficemojo.com/movies/?id=jurassicpark4.htm",
// "Avengers: Age of Ultron@http://www.boxofficemojo.com/movies/?id=avengers2.htm",
@ggauravr
ggauravr / array_iteration_thoughts.md
Last active October 3, 2021 02:40 — forked from ljharb/array_iteration_thoughts.md
Array iteration methods summarized

While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.

Intro

JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it much simpler to think about both the old list and the new one, what they contain, and

ModuleParseError: Module parse failed: /Users/gramesh/Documents/projects/start-page-nodejs/restaurant-profile/src/components/button/index.js Unexpected token (6:4)
You may need an appropriate loader to handle this file type.
| export default function Button(props) {
| return (
| <button type='button' className={styles.button}>{props.children}</button>
| );
| }
babelrc
{