Skip to content

Instantly share code, notes, and snippets.

View hk-skit's full-sized avatar
👨‍💻
On deep learning mode.

Hitesh Kumar hk-skit

👨‍💻
On deep learning mode.
View GitHub Profile
class RangeIterator {
constructor({
start = 0,
end = 1000,
step = 1
}) {
this.start = start;
this.end = end;
this.step = step;
@hk-skit
hk-skit / IteratorDemo.js
Last active January 27, 2019 05:08
Data Structures with Iterable Protocol
class IteratorDemo {
// Iterator Method with @@iterator key
// i.e. Symbol.iterator constant
[Symbol.iterator]() {
// Method stub which returns an iterator object.
}
}
@hk-skit
hk-skit / js-oneliner.js
Last active January 9, 2024 23:46
Useful Array One-liners.
// Remove Duplicates from an array
const removeDuplicates =
arr => arr.filter((item, index) => index === arr.indexOf(item));
const removeDuplicates1 = array => [...new Set(array)];
const removeDuplicates2 = array => Array.from(new Set(array));
// Flattens an array(doesn't flatten deeply).
@hk-skit
hk-skit / IComponentLoader.ts
Last active May 22, 2017 18:02
Component Loader Component
export interface IComponentLoader {
data: any;
}
@hk-skit
hk-skit / Stack.ts
Last active December 7, 2020 21:23
Generic Stack in TypeScript
interface StackConstructor<T> {
new <T>(n: number): Stack<T>
}
export class Stack<T>{
private data: T[] = [];
static readonly OVERFLOW = 'OVERFLOW';
static readonly UNDERFLOW = 'UNDERFLOW';
constructor(private size: number) {
}
push(item: T): number | string {
@hk-skit
hk-skit / index.html
Created November 10, 2016 17:09
Hello World with UI-Router
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hello ui-router</title>
<link rel="stylesheet" href="style.css">
</head>
<body ng-app="HelloWorld">
<header>
<nav>
<ul>