Skip to content

Instantly share code, notes, and snippets.

yorbb robbywashere

Block or report user

Report or block robbywashere

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
robbywashere / varidiac.ts
Created Jan 23, 2019
combine functions with varidiac rest parameters types
View varidiac.ts
function combine<T extends any[]>(...args: ((...fnArgs: T) => void)[]) {
return (...a: T) => args.forEach(fn => fn(...a));
function foo(n: number, o: string){
console.log(`string ${n} ${o}`);
function bar(n: number, o: string){
View firstSundays.js
function monthDays(year){
const m = (new Array(12)).fill(1).map((_,x)=>x%2?30:31);
if (year % 4) m[1] = 28;
else if (year % 100) m[1] = 29;
else if (year % 400) m[1] = 28
else m[1] = 28;
return m;
robbywashere / swagger2ts.js
Created Feb 9, 2019
Convert Swagger 2 spec to typescript superagent api client
View swagger2ts.js
function typify(spec, reqParams) {
return walk(null, spec, new Set(reqParams));
function walk(name, prop, req = new Set()) {
const {
name: propName,
required = [],
robbywashere / lru.ts
Last active Feb 13, 2019
simple LRU cache typescript implementation
View lru.ts
import { strict as assert } from "assert";
type Node<V> = { parent?: Node<V>; next?: Node<V>; value: V };
class DoublyLinkedList<V> {
private _head?: Node<V>;
private _tail?: Node<V>;
get head() {
return this._head!;
robbywashere / rx.js
Last active Feb 17, 2019
simple wild card regex implementation in javascript (interview question)
View rx.js
Implement regular expression matching with the following special characters:
* . (period) which matches any single character
* * (asterisk) which matches zero or more of the preceding element
That is, implement a function that takes in a string and a valid regular
robbywashere / erato.js
Created Mar 11, 2019
The Sieve of Eratosthenes in Javascript
View erato.js
function erato(n){
let map = new Map((new Array(n-1).fill(1)).map((n,i)=>[i+2,true]));
for (let i = 2; i <= Math.sqrt(n);i++){
if (!map.get(i)) continue
for (let j = i*2; j <= n; j += i) map.set(j,false)
return Array.from(map).filter(([n,b])=>b).map(([n])=>n);
robbywashere / email_validator.go
Last active Nov 2, 2019
Email validation JSON endpoint, any error is returned as `code` non-zero value with message else "ok"
View email_validator.go
package main
import (
You can’t perform that action at this time.