Skip to content

Instantly share code, notes, and snippets.

View chandru89new's full-sized avatar

druchan chandru89new

View GitHub Profile
@chandru89new
chandru89new / okta.go
Created October 16, 2023 22:19
saml2
// Copyright 2016 Russell Haering et al.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@chandru89new
chandru89new / wordle-prevent-keypress.js
Created August 11, 2023 18:01
prevent wordle keypress for used-but-not-present alphabets
let preventThisKey = (e) => {
if (Array.from(document.querySelectorAll('button[data-state="absent"]')).map((el) => el.innerText.toLowerCase()).includes(e.key)) {
e.stopPropagation();
e.preventDefault();
}
};
document.addEventListener("keydown", preventThisKey);
@chandru89new
chandru89new / index.js
Created August 4, 2023 03:38
concurrent promises with limit
const groupsOf =
(number = 0) =>
(arr = []) => {
return arr.reduce(
(acc, curr, idx) => {
const step_ = acc.step.concat(curr);
if (idx === arr.length - 1 || step_.length === number) {
return { final: acc.final.concat([step_]), step: [] };
}
return { final: acc.final, step: step_ };
@chandru89new
chandru89new / d.yaml
Last active March 18, 2023 18:18
test yaml file for something
sections:
- name: Skills
items:
- name: Frontend Engg
description: Next.js, React, Vue, Elm, GraphQL, Typescript, HTML/CSS.
- name: Backend Engg
description: NodeJS, Express, API design, SQL.
- name: Product Engg
description: Idea, wireframing, UX, testing.
- name: Management
@chandru89new
chandru89new / processor.elm
Last active March 16, 2023 02:28
Elm types parsing (for Harbor project)
module Codegen exposing (..)
import Elm.Parser as Parser
import Elm.Processing as Processing
import Elm.Syntax.Declaration exposing (Declaration(..))
import Elm.Syntax.Node exposing (Node, value)
import Elm.Syntax.TypeAnnotation exposing (TypeAnnotation(..))
sampleString =
@chandru89new
chandru89new / sequencemaybe.elm
Created February 13, 2022 02:54
sequence list maybe a
seqMaybe : List (Maybe a) -> Maybe (List a)
seqMaybe list =
let
go : List (Maybe a) -> Maybe (Array a) -> Maybe (Array a)
go l acc =
case l of
[] ->
acc
head :: tail ->
@chandru89new
chandru89new / watcher.sh
Last active October 18, 2021 16:53
bash-based watcher
#!/bin/bash
### Set initial time of file and the path to file/directory
LTIME=`stat src/*`
while true
do
ATIME=`stat src/*`
if [[ "$ATIME" != "$LTIME" ]]
then
@chandru89new
chandru89new / mapObject.ts
Last active June 22, 2021 12:23
map fn over object
type MapObject = <A, B>(fn: (a: A) => B) =>
<C extends {[key: string]: A }>(obj: C) => { [key in keyof C]: B}
export const mapObject: MapObject = (fn) => (obj) => {
if (!obj) return {};
const kvPairs = Object.entries(obj);
const mapped = kvPairs.map((kvPair) => [kvPair[0], fn(kvPair[1])]);
return Object.fromEntries(mapped);
};
@chandru89new
chandru89new / event-way-config.yaml
Last active November 18, 2019 06:35
Component architecture examples
// config yaml/json
// this decides the layout, the items that go into a component's props etc
pages:
- name: clusters
title: Clusters
layout: type2
children:
- name: clusters-scatterplot
component: Chart
props:
@chandru89new
chandru89new / res
Created January 10, 2015 10:34
resolutions (from Chrome Developer console)
pixel ratio 1
-------------
320 x 480
360 x 640
480 x 854
600 x 1024
720 x 1280
768 x 1024