Skip to content

Instantly share code, notes, and snippets.

Avatar

Neel Mehta hathix

View GitHub Profile
View calendar-days-ago.js
/**
* Strips the time part away from a date so that it's a pure date (no time).
*/
function toPureDate(d: Date) : Date {
return new Date(d.getFullYear(), d.getMonth(), d.getDate(), 0, 0, 0, 0);
}
function hoursAgo(h: number) : Date {
const now: Date = new Date();
now.setTime(now.getTime() - h * 60 * 60 * 1000);
@hathix
hathix / proof-of-work.js
Created Feb 1, 2020
Bitcoin mining simulation
View proof-of-work.js
// Simulating Bitcoin's Proof-of-Work mining algorithm
// The challenge: choose a nonce that, when appended to "hello",
// yields an MD5 hash with at least 4 leading zeroes
for (let i = 0; i < 1000000; i++) {
out = md5("hello" + i);
if (out.startsWith("0000")) {
console.log(i, out)
}
}
View list-of-harvard-libraries.txt
Andover-Harvard Theological Library
Arnold Arboretum Horticultural Library
Arthur and Elizabeth Schlesinger Library on the History of Women in America
Baker Library
Baker Library Special Collections
Birkhoff Mathematical Library
Botany Libraries
Cabot Science Library
Chemistry and Chemical Biology Library
Countway Library of Medicine
View list-of-harvard-museums.txt
Fogg Museum
Busch-Reisinger Museum
Arthur M. Sackler Museum
Carpenter Center
Peabody Museum
Graduate School of Design
Harvard Semitic Museum
Arnold Arboretum
Collection of Historical Scientific Instruments
Harvard Museum of Natural History
@hathix
hathix / email-regex.txt
Created Oct 3, 2017
RegEx to find emails
View email-regex.txt
/\b[\w\d._%+-]+@[\w\d.-]+\.[\w]{2,}\b/g