Skip to content

Instantly share code, notes, and snippets.

💻
Working on my own projects

Sal Rahman shovon

💻
Working on my own projects
Block or report user

Report or block shovon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@shovon
shovon / README.md
Created Dec 9, 2019
An implementation of a Trie data structure.
View README.md

Usage

A trie is a key-value pair data structure, that allows you to store a value, by associating it with some string value. If you happen to know what that string value is, then you can retrieve the original value associated with the string.

If the string value is not associated to any value, then a null is returned.

As opposed to an associative array, tries actually save memory, by not storing redundant character prefixes of strings.

import Trie from './trie';
@shovon
shovon / http-tcp.go
Last active Aug 28, 2019
A dumb little HTTP server that works on top of TCP.
View http-tcp.go
package main
import (
"bufio"
"errors"
"fmt"
"io"
"log"
"net"
"net/http"
View README.md

Usage

import React from 'react';
import { useValidation, useFormFeedback } from './use-validation';

type InputItemProps = {
  name,
  value
} & FieldProps<string>
@shovon
shovon / marshal_json_omit_empty.go
Last active Jul 28, 2019
`IsZero` is potentially a method that can be called in order to determine if an instance of a struct is a "zero value". json.Marshal, however, does not yet implement this, and so, this is a solution to the problem, for now
View marshal_json_omit_empty.go
package lib
import (
"encoding/json"
"reflect"
"strings"
)
// IsZeroer implement this if you want some special definition of "zero"
type IsZeroer interface {
@shovon
shovon / monad.go
Last active Jul 26, 2019
Some initial work on monads in Golang
View monad.go
package monad
type ThenCallback func(interface{}) (Thenable, error)
type Thenable interface {
Then(ThenCallback) Thenable
Unwrap() interface{}
}
type Error struct {
@shovon
shovon / selects-to-checkboxes.js
Created Jul 17, 2019
Convert multi-select to checkboxes
View selects-to-checkboxes.js
const form = document.getElementById('form');
const multiSelects = [...form.querySelectorAll('select')]
.filter(el => el.multiple);
function *indexedIteration(iterable) {
let count = 0;
for (const item of iterable) {
yield [ item, count ];
count++;
View README.md

Linked List with Iterator

An example of flattening a linked list with generators.

Usage

const LinkedList = require('./linked-list');

const list = new LinkedList();
View README.md

Iterable Binary Search Tree

Iterators are so useful, that it has now become one of JavaScript's core features. Generators were devised in order to facilitate the creation of iterators. Better yet, with generators, you can nest iterators, and yield a "flattened" result.

The binary search tree is a classic example of where "nested" iterators will be useful.

Usage

const BinarySearchTree = require('./bst.js');
View README.md

Iterable Binary Search Tree

Iterators are so useful, that it has now become one of JavaScript's core features. Generators were devised in order to facilitate the creation of iterators. Better yet, with generators, you can nest iterators, and yield a "flattened" result.

The binary search tree is a classic example of where "nested" iterators will be useful.

Usage

const BinarySearchTree = require('./bst.js');
View README.md

Iterable Binary Search Tree

Iterators are so useful, that it has now become one of JavaScript's core features. Generators were devised in order to facilitate the creation of iterators. Better yet, with generators, you can nest iterators, and yield a "flattened" result.

The binary search tree is a classic example of where "nested" iterators will be useful.

Usage

const BinarySearchTree = require('./bst.js');
You can’t perform that action at this time.