Skip to content

Instantly share code, notes, and snippets.

View bcjordan's full-sized avatar

Brian Jordan bcjordan

View GitHub Profile
/**
* Serial output (9600 baud):
*
* LIS3DH test!
* FF
* Couldnt start
*
*/
/**
#!/bin/bash
# Usage: git open-pr [<branch-name>]
#
# Navigates to the pull request for a branch using the web browser.
# Defaults to current branch.
set -e
branch="${1:-$(git symbolic-ref HEAD)}"
branch="${branch#refs/heads/}"
@bcjordan
bcjordan / balanced_delimiters.md
Last active August 29, 2015 14:10
Balanced delimiter solutions
  • Cameron McCallie in Javascript (gist)
  • Rohit Jamuar in Python (gist)
  • Shahriar Tajbakhsh in Python (gist)
  • Zachary Kanfer in Arc Lisp (blog with code), with a great writeup!
  • Kanat Bekt in Python (gist)
  • Mohammed El-Afifi in C++ (gist)
  • Jesse Sessler in Ruby (gist)
  • Fabian Foerg in Haskell (GitHub)
  • Mike Morton in Javascript (gist)
  • Roger Lamb in Scala (gist
@bcjordan
bcjordan / balance.hs
Created December 3, 2014 16:36
Randall
-- Coding For Interviews Problem #21
-- Problem: Balancing Delimeters
-- Author: Randall R. Van Why
-- Date: 2014-06-17
import Control.Monad
type Stack a = [a]
push :: a -> Stack a -> Stack a
@bcjordan
bcjordan / chrome34Workaround.js
Created May 15, 2014 18:09
chrome34Workaround.js
/**
* Blockly-dev-test-page-only temporary workaround for Chrome 34 SVG bug #349701
*
* - Loads jQuery from googleapis.com
* - Workaround mostly copied from Dashboard
* - Assumes 2 seconds is long enough for jQuery load
*
* Bug details: https://code.google.com/p/chromium/issues/detail?id=349701
* tl;dr: only the first clippath in a given svg element renders
*
@bcjordan
bcjordan / queue-two-stacks-solutions.md
Last active August 29, 2015 14:01
Queue w/ Two Stacks solutions
  • Michael Penkov in javascript (gist) Michael notes: Enqueing and dequeuing are both O(1), with the exception of the very first enqueue after a dequeue (or vice versa), which costs O(m), where m is the current number of elements. The reason for this cost increase is because I reverse the underlying stack between enqueue and dequeue operations. This reversal requires an extra stack and linear time.

    To implement getMinimum() in O(1), I keep a list within the queue. This list tracks the non-descending run of items since the current minimum. The current minimum is always at the front of this list. On enqueuing, the list is adjusted such that it includes the enqueued item AND remains non-descending.

  • Adelina Stanciu in C++ (github)

  • Damir Bucar's notes and drawings on (imgur)

Reading the Standard Libraries

A Coding for Interviews weekly practice problem group member mentioned during our Skype customer interview that reading through the Java collections library was the most valuable step he took while preparing for his Google interviews. In addition to getting a better understanding the standard data structures, hearing a candidate say "well the Java collections library uses this strategy..." is a strong positive signal.

Indeed, other HNers echoed the sentiment:

Wael Khobalatte writes (link added),

I usually have a fun time going from method to method just exploring any of the implementations in that library. Josh Bloch (One of the writers of the library I think) uses a lot of examples from the Java collections in his book "Effective Java", which I also recommend to everyone.

@bcjordan
bcjordan / eight-queens.md
Created November 22, 2013 01:50
Eight Queens problem solutions
  • Graham Enos in Python (imgur)
@bcjordan
bcjordan / level-order-print.md
Last active December 28, 2015 17:39
Level order print problem solutions

Submitted solutions

  • Rohit Jamuar in Python (gist)
  • Damir Bucar in Java (gist)
  • Pete Huang in Ruby (imgur) (single-array output)

  • Luís Armando Bianchin in Python (gist) (neat python list comprehensions!—an expected followup question would be: "can you do this without accessing the children twice per level?")
  • Bernie Margolis in Java (gist) (neat interfaces! uses lists on different levels of the call stack with recursion to track level advance)
@bcjordan
bcjordan / tail-calls.md
Last active December 28, 2015 08:39
Tail calls!

Tail calls are the last functions called in a parent function, often returning a value which is immediately returned by the parent function.


def any_old_function():
	# ...
	# do anything
	# ...
	return some_other_function() # this is a tail call!