Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am benjic on github.
* I am benjic (https://keybase.io/benjic) on keybase.
* I have a public key ASAKwtTcKO_8lK0DXtobWBdV8ok2QMAzrp8iGlGA2BjJuAo
To claim this, I am signing this object:
@benjic
benjic / main.go
Created April 13, 2017 23:19
GH Authentication Proxy
package main
import (
"encoding/base64"
"fmt"
"net/http"
"net/http/httputil"
"net/url"
"os"
)
@benjic
benjic / README.md
Created December 18, 2016 18:13
Day 2: Bathroom Security

--- Day 2: Bathroom Security ---

You arrive at Easter Bunny Headquarters under cover of darkness. However, you left in such a rush that you forgot to use the bathroom! Fancy office buildings like this one usually have keypad locks on their bathrooms, so you search the front desk for the code.

"In order to improve security," the document you find says, "bathroom codes will no longer be written down. Instead, please memorize and follow the procedure below to access the bathrooms."

The document goes on to explain that each button to be pressed can be found by starting on the previous button and moving to adjacent buttons on the keypad: U moves up, D moves down, L moves left, and R moves right. Each line of instructions corresponds to one button, starting at the previous button (or, for the first line, the "5" button); press whatever button you're on at the end of each line. If a move doesn't lead to a button, ignore it.

You can't hold it much longer, so you decide to figure out the code as you walk to the ba

@benjic
benjic / add.go
Created September 28, 2016 02:14
package add
func Add(a, b int) int {
return a + b
}

Keybase proof

I hereby claim:

  • I am benjic on github.
  • I am benjic (https://keybase.io/benjic) on keybase.
  • I have a public key ASCOmrDL6thNQj3_vx9Wdn1X0TlfknKRg-vyciKcjbNzIQo

To claim this, I am signing this object:

@benjic
benjic / mergesort.hs
Created May 13, 2016 05:00
Haskell MergeSort
module Main where
mergeSort :: (Ord a) => [a] -> [a]
mergeSort ns
-- Recursively call merge s
| length ns > 1 = merge (mergeSort left, mergeSort right)
-- This is the base case where recursion stops
| otherwise = ns
where
-- Split the list in half
@benjic
benjic / week1.py
Created February 1, 2016 00:51
Solution to week 1 quiz for PHSX218 Lab
import math
import numpy as np
def rule4(Q, A, dA, m, B, dB, n):
"""Computes the error propagation for the form c A^m * B^n"""
return abs(Q) * math.sqrt((m * (dA / A))**2 + (n * (dB / B))**2)
# Capture measurements
height = 22.65e-3 # meters
radius = 8.60e-3 / 2 # meters
@benjic
benjic / solution.js
Created January 21, 2016 03:53
Elevator Saga solution -- http://play.elevatorsaga.com/
{
init: function(elevators, floors) {
var elevator = elevators[0]; // Let's use the first elevator
// Whenever the elevator is idle (has no more queued destinations) ...
elevator.on("idle", function() {
// let's go to all the floors (or did we forget one?)
elevator.goToFloor(0);
elevator.goToFloor(1);
});
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.