Skip to content

Instantly share code, notes, and snippets.

# Given a complete binary tree (every level full, except possibly the last level,
# but full left to right in any case; no gaps):
# count the number of nodes in the tree
# 1. go down left side of tree -> lg N time to do; number of nodes will be between
# 2 ** (leftmost depth - 1) to 2 ** (leftmost depth) - 1
# where depth includes the root:
# Size = 2 ** 2 (4) -> 2 ** 3 - 1 (7)
# Depth = 3
#
@mjec
mjec / wordsplit.sh
Created June 28, 2016 19:58
Split a string into two English words, if possible
#!/bin/bash
# A solution to the two word version of
# http://thenoisychannel.com/2011/08/08/retiring-a-great-interview-problem
# in bash, because I can.
length_of_input=`echo -n "$1" | wc -c`
for len in `seq $length_of_input`
do
@mjec
mjec / data_store.py
Last active January 12, 2016 20:45
Recurse Center database server pairing task
# Python 3
from http.server import HTTPServer, BaseHTTPRequestHandler
from urllib.parse import urlparse, parse_qs
class DataStore(object):
"""A generic data storage object"""
def __init__(self):

Keybase proof

I hereby claim:

  • I am mjec on github.
  • I am mjec (https://keybase.io/mjec) on keybase.
  • I have a public key whose fingerprint is A7AC CAF8 7492 E09E 148F 3459 2410 1EE9 EF53 230B

To claim this, I am signing this object:

@mjec
mjec / timerec.bat
Last active July 20, 2018 04:31
Time recording in timelog (*ledger) format
@echo off
REM Time recording utility - writes to timelog (*ledger) format.
REM A quick hack by Michael Cordover (mjec)
REM Released into the public domain.
cls
echo Time recording utility
set /p filename= "Enter file name: "
set task=
set oldtask=