Skip to content

Instantly share code, notes, and snippets.

@vishnuvyas
vishnuvyas / EditableTable.tsx
Created April 26, 2023 22:15
Verison of Editable Table in react and typescript
import React, { useState, useRef } from "react";
const Table = ({ columns, data }) => {
const [rows, setRows] = useState<{ [key: string]: any }[]>(data);
const [editMode, setEditMode] = useState(false);
const inputRef = useRef<HTMLInputElement[]>();
const addRow = () => {
setRows([...rows, {}]);
};
@vishnuvyas
vishnuvyas / iterm2-solarized.md
Created December 5, 2020 23:11 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@vishnuvyas
vishnuvyas / ContextExtractor.java
Created April 3, 2020 04:29
Way to extract the context around a particular hit
import java.util.*;
import java.util.stream.*;
class ContextExtractor {
public static class TagResult {
public String token;
public int start;
public int end;
@vishnuvyas
vishnuvyas / metrics api definition
Created June 15, 2018 22:57
metrics api definition
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
TAGGER.put("psych:","psych:")
TAGGER.put("rectal:","rectal:")
TAGGER.put("overview normal.","overview normal.")
TAGGER.put("abdom:","abdom:")
TAGGER.put("speech normal","speech normal")
TAGGER.put("follow-up","follow-up")
TAGGER.put("chronic","chronic")
TAGGER.put("extensive","extensive")
TAGGER.put("resulting","resulting")
TAGGER.put("denied","denied")
@vishnuvyas
vishnuvyas / bintree-dict.scm
Created September 18, 2011 05:06
A simple key-value style dictionary implementation in scheme (uses binary trees)
(define (make-table-cell key val)
;; make a symbol table - atleast one table is required.
(cons (cons key value) (cons #f #f)))
;; some functions to access individual table cells
(define (get-key table-cell) (caar table))
(define (get-value table-cell) (cdr (car table)))
(define (get-left table-cell) (car (cdr table)))
(define (get-right table-cell) (cdr (cdr table)))
@vishnuvyas
vishnuvyas / levenshtein.clj
Created May 6, 2011 05:29
A purely functional implementation of levenshtein distance in clojure
(ns levenshtein
^{:doc "A purely functional implementation of the levenshtien distance in clojure"})
(defn- compute-next-row
"computes the next row using the prev-row current-element and the other seq"
[prev-row current-element other-seq pred]
(reduce
(fn [row [diagonal above other-element]]
(let [update-val
(if (pred other-element current-element)
@vishnuvyas
vishnuvyas / gramgen.clj
Created April 5, 2011 12:06
A port of a simple grammar generator in PAIP from common lisp to clojure
(ns gramgen
{:doc
"GramGen generates sentences from a CFG. Comes with an inbuilt cfg - This is based on the program on
chapter 2, and it can be written much simpler, but this program is written the way it is because I wanted
to try out some new features of clojure.
to generate a random tree use the function generate-tree, which generates a random parse tree from
the grammar we have provided. If you want to use a more advanced grammar, then use the create grammar
function to create a complex grammars. Grammars are represented as seqences where the first of the
seqence is the LHS for the grammar and the rest are RHS choices for the grammar. If the rhs itself