Skip to content

Instantly share code, notes, and snippets.

View hrishikeshs's full-sized avatar

Hrishikesh S hrishikeshs

View GitHub Profile
@hrishikeshs
hrishikeshs / node-typescript-esm.md
Created November 21, 2023 17:48 — forked from khalidx/node-typescript-esm.md
A Node + TypeScript + ts-node + ESM experience that works.

The experience of using Node.JS with TypeScript, ts-node, and ESM is horrible.

There are countless guides of how to integrate them, but none of them seem to work.

Here's what worked for me.

Just add the following files and run npm run dev. You'll be good to go!

package.json

import Ember from 'ember';
export default Ember.Component.extend({
tagName: '',
});
import Ember from 'ember';
const { computed } = Ember;
export default Ember.Component.extend({
channels: ['california', 'bangalore'],
exampleCP: computed('record.propertyThatDoesntExistYet', function() {
return this.record.propertyThatDoesntExistYet ? 'foo' : 'bar';
}),
@hrishikeshs
hrishikeshs / service-workers.md
Created August 20, 2016 07:28 — forked from Rich-Harris/service-workers.md
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@hrishikeshs
hrishikeshs / slim-redux.js
Created April 30, 2016 15:49 — forked from gaearon/slim-redux.js
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@hrishikeshs
hrishikeshs / what-forces-layout.md
Last active September 19, 2015 16:20 — forked from paulirish/what-forces-layout.md
What forces layout/reflow in Chrome. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
function deepEquals(x, y) {
if (x === y) return true;
if (x !== x) return y !== y;
if (typeof x !== typeof y) return false;
if (typeof x !== 'object') return false;
var typeX = getType(x);
var typeY = getType(y);
if (typeX !== typeY) return false;