Skip to content

Instantly share code, notes, and snippets.

View anandnimkar's full-sized avatar

Anand Nimkar anandnimkar

View GitHub Profile
# solution from https://blog.tinned-software.net/rewrite-author-of-entire-git-repository/
git fetch origin
git reset --hard origin/master
git for-each-ref --format='delete %(refname)' refs/original | git update-ref --stdin
git reflog expire --expire=now --all
git gc --prune=now
@anandnimkar
anandnimkar / index.test.ts
Created June 29, 2018 03:42
toEqual does not deep equal check custom error objects
export class EError extends Error {
type: string;
data: { [key: string]: any } | undefined;
constructor(message: string, type: string, data?: { [key: string]: any }) {
super(message);
this.type = type;
this.data = data;
this.name = this.constructor.name;
@hyamamoto
hyamamoto / string.hashcode.js
Created September 30, 2016 07:19
JavaScript Implementation of String.hashCode() .
/**
* Returns a hash code for a string.
* (Compatible to Java's String.hashCode())
*
* The hash code for a string object is computed as
* s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
* using number arithmetic, where s[i] is the i th character
* of the given string, n is the length of the string,
* and ^ indicates exponentiation.
* (The hash value of the empty string is zero.)