Skip to content

Instantly share code, notes, and snippets.

View kshirish's full-sized avatar
👨‍💻

k kshirish

👨‍💻
View GitHub Profile
// 2, 8, 10, 4, 3, 6, 7
class Stack {
constructor() {
this.list = [];
this.pointer = 0;
}
push(value) {
this.list.push(value);
// 2, 8, 10, 4, 3, 6, 7
class Queue {
constructor() {
this.list = [];
this.pointer = 0;
}
enqueue(value) {
this.list.push(value);
// 2 <-> 8 <-> 10 <-> 4 <-> 3 <-> 6 <-> 7
// {prev, value, next}
class Node {
constructor(value) {
this.prev = null;
this.value = value;
this.next = null;
@kshirish
kshirish / linkedlist.js
Last active August 11, 2024 04:22
with head & tail
// 2 -> 8 -> 10 -> 4 -> 7
// {value, next}
class Node {
constructor(value) {
this.value = value;
this.next = null;
}
@kshirish
kshirish / linkedlist.js
Last active August 11, 2024 03:40
with head
// 2 -> 8 -> 10 -> 4 -> 7
// {value, next}
class Node {
constructor(value) {
this.value = value;
this.next = null;
}
}
@kshirish
kshirish / App.jsx
Created June 9, 2023 03:43
Dynamic render through JSON schema
import * as React from "react";
const Text = (props) => {
return (
<div style={{ border: "1px solid red", padding: "20px" }}>
<p>this is text</p>
<div>{props.children}</div>
</div>
);
};
@kshirish
kshirish / settings.json
Created August 24, 2021 13:51
vscode settings
{
"editor.snippetSuggestions": "top",
"editor.suggestSelection": "first",
"editor.cursorSmoothCaretAnimation": false,
"editor.smoothScrolling": true,
"editor.fontSize": 14,
"editor.fontFamily": "Monaco",
"editor.fontWeight": "bold",
"editor.formatOnSave": true,
"emmet.triggerExpansionOnTab": true,
@kshirish
kshirish / play.ts
Created July 10, 2020 10:37
Learning typescript
// Typescript Documentation:
// https://www.typescriptlang.org/docs/
// Basic Types
const message: string = "Hello world";
const messageArr: Array<string> = [message];
console.log(message);
console.log(messageArr);
const isValid: boolean = false;
@kshirish
kshirish / rxjs.js
Last active March 4, 2019 11:40
Hands on RxJS
// https://npmcdn.com/@reactivex/[email protected]/dist/global/Rx.umd.js
Rx.Observable.create(function(observer) {
let counter = 0;
setInterval(function() {
observer.next((counter += 2));
}, 2000);
}).subscribe(
function(val) {
@kshirish
kshirish / acl.js
Created February 21, 2018 16:30
Access Control
// users
const users = [
{
id: 0,
name: "Rocky"
},
{
id: 1,
name: "John"
},