Skip to content

Instantly share code, notes, and snippets.

View manjunatha-d's full-sized avatar

Manjunatha D manjunatha-d

View GitHub Profile
{
"version": "2.0.0",
"tasks": [
{
"label": "tsc watch",
"type": "shell",
"command": "./node_modules/.bin/tsc",
"isBackground": true,
"args": ["--watch", "--noEmit", "--project", "."],
"group": {
export function splitArray<T>(
array: ReadonlyArray<T>,
predicate: (value: T) => boolean,
): _.Dictionary<ReadonlyArray<T>> {
return array.reduce(
(accu, value) => {
if (predicate(value)) {
return {
...accu,
truthyPart: [...accu.truthyPart, value],
{
"editor.lineHeight": 25,
"workbench.editor.enablePreview": false,
"editor.fontFamily": "'Fira Code', 'Consolas', 'monospace' ",
"workbench.activityBar.visible": false,
"editor.minimap.enabled": false,
"files.insertFinalNewline": true,
"window.menuBarVisibility": "visible",
"window.restoreFullscreen": true,
"search.smartCase": true,
@manjunatha-d
manjunatha-d / promiseAll.js
Created August 2, 2018 04:31
Make Promise.all() wait until all the promises are resolved, regardless of their resolution (fulfilled or rejected)
const resolvedPromise1 = Promise.resolve('Resolved promise 1');
const rejectedPromise = Promise.reject('Rejected promise 1');
const resolvedPromise2 = Promise.resolve('Resolved promise 2');
Promise.all(
[resolvedPromise1, rejectedPromise, resolvedPromise2]
.map(promise => promise.catch(error => error))
)
.then(results => {
console.log(results);
import { Component } from 'react';
import PropTypes from 'prop-types';
class ScrollToTopOnMount extends Component {
componentDidMount() {
const { top = 0, left = 0, behavior = 'smooth' } = this.props;
window.scrollTo({
top,
left,
@manjunatha-d
manjunatha-d / react-countdown-timer
Last active June 30, 2018 18:42
React Countdown Timer
import React, { Component } from 'react';
function getTimeComponents(milliseconds = 0) {
const seconds = Math.floor((milliseconds / 1000) % 60);
const minutes = Math.floor((milliseconds / 1000 / 60) % 60);
const hours = Math.floor((milliseconds / (1000 * 60 * 60)) % 24);
const days = Math.floor(milliseconds / (1000 * 60 * 60 * 24));
return {
days: prefixWithZero(days),
@manjunatha-d
manjunatha-d / helloworld.txt
Created September 20, 2017 15:52
Hello World
Hello, you beautiful world!