Skip to content

Instantly share code, notes, and snippets.

View Ridermansb's full-sized avatar
🤔
Always thoughtful

Riderman de Sousa Barbosa Ridermansb

🤔
Always thoughtful
View GitHub Profile
import {assert} from 'chai';
export namespace Dictionaries {
/**
* Create a deep copy of a dictionary such that all of the origina keys are maintained
* and copied into a new dictionary.
*
* This is used when we have to create a copy of a dictionary to prevent concurrent mutation
* or when we need to copy it and then make changes to the new dictionary.
@Ridermansb
Ridermansb / RingBuffer.ts
Last active July 5, 2021 12:00 — forked from burtonator/RingBuffer.ts
ring buffer...
import {assert} from 'chai';
/**
* Implement a class named ring buffer with fixed capacity such that
*
* constructor: takes the capacity for the ring buffer
*
* push: adds a value to the ring buffer.
* pop: removes the last value from the ring buffer or undefined if it's empty.
* peek: returns the current value of the most recent value added or undefined if none have been added
@Ridermansb
Ridermansb / useLocalStorageState.ts
Last active July 5, 2021 11:52 — forked from burtonator/useLocalStorageState.ts
useLocalStorageState.ts
import React from 'react';
/**
* Implement a replacement for useState which keeps values in the localStorage.
*
* The idea here is that all calls to use useState can be replaced with
* useLocalStorageState(key, initialValue) and implement the same behavior.
*
* The first time useLocalStorageState is called the value will be initialValue
* because nothing is stored in localStorage.
@Ridermansb
Ridermansb / taskgit
Last active August 29, 2015 14:27 — forked from unode/taskgit
#!/bin/sh
# copyright 2014 Renato Alves
# distributed under the GPL licence
if [ -z "$TASKDIR" ]; then
#TODO Look for data location in rc:location instead of assuming ~/.taskrc
TASKDIR="$(grep data.location $HOME/.taskrc | cut -d '=' -f 2)"
fi