Skip to content

Instantly share code, notes, and snippets.

Avatar

yorbb robbywashere

View GitHub Profile
View .git-completion.bash
#!bash
#
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
@robbywashere
robbywashere / chat.go
Created Aug 28, 2016 — forked from drewolson/chat.go
simple golang chat server
View chat.go
package main
import (
"bufio"
"net"
)
type Client struct {
incoming chan string
outgoing chan string
View walknodes.js
import map from 'lodash/map';
import Promise from 'bluebird';
function isNode({ key, type, linkType } = {}) {
return (key === 'sys' && type === 'Link' && (linkType === 'Entry' || linkType === 'Asset'));
}
// TODO: combine these somehow
@robbywashere
robbywashere / index.js
Created Mar 24, 2018
Permutations the lazier way (Sorry Heap's Algo)
View index.js
function splice(arr, pos) {
let nArr = Array.from(arr);
return [ nArr.splice(pos,1), nArr ];
}
function p(arr, result = [], chr = []){
if (arr.length === 1) result.push(chr.concat(arr).join(''));
for (let i = 0; i <= arr.length-1; i++) {
const [c, n] = splice(arr,i);
p(n,result,chr.concat(c));
@robbywashere
robbywashere / goolgeApiAuthTokens.js
Created Jul 4, 2018
get google api auth tokens with client_id and client_secret
View goolgeApiAuthTokens.js
const CLIENT_ID = <CLIENT_ID>;
const CLIENT_SECRET = <CLIENT_SECRET>;
// Hardcoded dummy redirect URI for non-web apps.
const REDIRECT_URI = 'urn:ietf:wg:oauth:2.0:oob';
// The URL root for accessing Google Accounts.
const GOOGLE_ACCOUNTS_BASE_URL = 'https://accounts.google.com';
const path = require('path');
View Users.tsx
import React, { Component } from "react";
import gql from "graphql-tag";
import { graphql, ChildDataProps } from "react-apollo";
type Response = {
users: [User];
};
type Variables = {
q: string;
@robbywashere
robbywashere / HousePainter.js
Created Nov 23, 2018
House Painter Problem / Coding Problem A Day / Minimum non adjacent matrix indices
View HousePainter.js
/*
A builder is looking to build a row of N houses that can be of K different
colors. He has a goal of minimizing cost while ensuring that no two neighboring
houses are of the same color.
Given an N by K COSTS where the nth row and kth column represents the cost to
@robbywashere
robbywashere / json_parser.js
Last active Jan 15, 2019
a (very naive) json parser in javascript
View json_parser.js
function parse_json(jsonStr) {
let tokens = [];
for (let i = 0; i < jsonStr.length; i++) {
if (jsonStr[i] === '"') {
value = '';
i++ ;
while (jsonStr[i] !== '"') {
value += jsonStr[i];
View topo_sort.js
class Graph {
constructor(){
this.nodes = {};
}
addNode(n){
if (!this.nodes[n]) this.nodes[n] = [];
}
addDirEdge(a,b){
View bfs.js
class Graph {
constructor(){
this.nodes = {};
}
addNode(n){
if (!this.nodes[n]) this.nodes[n] = [];
}
You can’t perform that action at this time.