Skip to content

Instantly share code, notes, and snippets.

View tusharmath's full-sized avatar
😑
Imploding

Tushar Mathur tusharmath

😑
Imploding
View GitHub Profile
{
"keys": [
{
"kty": "RSA",
"use": "sig",
"alg": "RS256",
"kid": "I48qMJp566SSKQogYXYtHBo9q6ZcEKHixNPeNoxV1c8",
"n": "ksMb5oMlhJ_HzAebCuBG6-v5Qc4J111ur7Aux6-8SbxzqFONsf2Bw6ATG8pAfNeZ-USA3_T1mGkYTDvfoggXnxsduWV_lePZKKOq_Qp_EDdzic1bVTJQDad3CXldR3wV6UFDtMx6cCLXxPZM5n76e7ybPt0iNgwoGpJE28emMZJXrnEUFzxwFMq61UlzWEumYqW3uOUVp7r5XAF5jQ_1nQAnpHBnRFzdNPVb3E6odMGu3jgp8mkPbPMP16Fund4LVplLz8yrsE9TdVrSdYJThylRWn_BwvJ0DjUcp8ibJya86iClUlixAmBwR9NdStHwQqHwmMXMKkTXo-ytRmSUobzxX9T8ESkij6iBhQpmDMD3FbkK30Y7pUVEBBOyDfNcWOhholjOj9CRrxu9to5rc2wvufe24VlbKb9wngS_uGfK4AYvVyrcjdYMFkdqw-Mft14HwzdO2BTS0TeMDZuLmYhj_bu5_g2Zu6PH5OpIXF6Fi8_679pCG8wWAcFQrFrM0eA70wD_SqD_BXn6pWRpFXlcRy_7PWTZ3QmC7ycQFR6Wc6Px44y1xDUoq3rH0RlZkeicfvP6FRlpjFU7xF6LjAfd9ciYBZfJll6PE7zf-i_ZXEslv-tJ5-30-I4Slwj0tDrZ2Z54OgAg07AIwAiI5o4y-0vmuhUscNpfZsGAGhE",
"e": "AQAB"
}
directive @server(
"""
some documentation for enableIntrospection
"""
enableIntrospection: Boolean
"""
some documentation for enableQueryValidation
"""
enableQueryValidation: Boolean
"""
@tusharmath
tusharmath / index.html
Created May 30, 2019 13:45
Megamorphic issue with deoptigate
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>deoptigate</title>
<style async type="text/css" media="screen">
@import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,600);@import url(https://fonts.googleapis.com/css?family=Source+Code+Pro);/*! TACHYONS v4.9.0 | http://tachyons.io *//*! normalize.css v7.0.0 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,footer,header,nav,section{display:block}h1{font-size:2em;margin:.67em 0}figcaption,figure,main{display:block}figure{margin:1em 40px}hr{box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace,monospace;font-size:1em}a{background-color:transparent;-webkit-text-decoration-skip:objects}b,strong{font-weight:inherit}b,strong{font-weight:bolder}code{font-family:monospace,monospace;font-size:1em}mark{background-color:#ff0;color
@tusharmath
tusharmath / trampoline.ts
Last active March 31, 2023 01:05
Trampolining in Typescript
// stub for typescript
declare function BigInt(n: number): number
abstract class Trampoline<A> {
abstract map<B>(ab: (a: A) => B): Trampoline<B>
abstract flatMap<B>(ab: (a: A) => Trampoline<B>): Trampoline<B>
zip<B>(tb: Trampoline<B>): Trampoline<[A, B]> {
const ta = this
return ta.flatMap(a => tb.map(b => [a, b] as [A, B]))
@tusharmath
tusharmath / batch.ts
Created October 4, 2018 14:21
Run Tasks in Batch
interface Task {
(): void
}
interface IdleCallback {
timeRemaining(): number
}
declare function requestIdleCallback(cb: (id: IdleCallback) => void): number
@tusharmath
tusharmath / init.ts
Created September 6, 2018 15:10
PWA Component
type init<State, Args extends any[]> = {
(...t: Args): State
}
@tusharmath
tusharmath / component.ts
Last active September 6, 2018 15:09
PWA Component
interface Component<State, Params, Args extends any[]> {
init(...t: Args): State
update(action: Action<any>, state: State): State
command(action: Action<any>, state: State): State
view<VNode>(e: Emitter, s: State, p: Params): VNode
}
@tusharmath
tusharmath / object-diff.ts
Created August 16, 2018 01:00
Finds diff between objects
type Change<T> = {
path: Array<string>
right: T
left: T
}
function isPrimitive(value: any): boolean {
const type = typeof value
return ['number', 'date', 'boolean', 'string'].indexOf(type) > -1

Scala Cheatsheet

Type Constructors

case classes that help use create new type of objects. For instance List is a type constructory.

Higher Kinded Types

Generic types that take parameters such as —

trait Foo[T[_]] {
 def bar(x: T[Int]): Unit