Skip to content

Instantly share code, notes, and snippets.

@robbywashere-zz
robbywashere-zz / .git-completion.bash
Created November 13, 2013 23:18
.git-completion.bash
#!bash
#
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]>
# 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-zz
robbywashere-zz / chat.go
Created August 28, 2016 02:28
simple golang chat server
package main
import (
"bufio"
"net"
)
type Client struct {
incoming chan string
outgoing chan string
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-zz
robbywashere-zz / index.js
Created March 24, 2018 12:17
Permutations the lazier way (Sorry Heap's Algo)
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-zz
robbywashere-zz / goolgeApiAuthTokens.js
Created July 4, 2018 10:27
get google api auth tokens with client_id and client_secret
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');
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-zz
robbywashere-zz / HousePainter.js
Created November 23, 2018 01:19
House Painter Problem / Coding Problem A Day / Minimum non adjacent matrix indices
/*
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-zz
robbywashere-zz / json_parser.js
Last active January 15, 2019 22:16
a (very naive) json parser in javascript
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];
class Graph {
constructor(){
this.nodes = {};
}
addNode(n){
if (!this.nodes[n]) this.nodes[n] = [];
}
addDirEdge(a,b){
class Graph {
constructor(){
this.nodes = {};
}
addNode(n){
if (!this.nodes[n]) this.nodes[n] = [];
}