Skip to content

Instantly share code, notes, and snippets.

View jballanc's full-sized avatar

Joshua Ballanco jballanc

View GitHub Profile
@jballanc
jballanc / Background.md
Created May 20, 2012 16:14
Golfing Rule 110

What is Rule 110?

Rule 110 is an algorithm for a cellular automaton. The automaton works on of an infinite tape of 1s and 0s. It has a write head that can write to a specific position on the tape, and a read head that reads the position under the write head as well as the positions to either side. The set of three values read determines the value written by the write head according to the following rules:

Values Read111110101100011010001000
Value Written01101110

If you notice, the value to write for each set of three values read corresponds to the position of the bits in the binary representation of the number 110. Hence, the name of the rule. Wikipedia has more information here.

set nocompatible " We're running Vim, not Vi!
syntax on " Enable syntax highlighting
filetype off " Disable filetype detection to keep Vundle happy
set shiftwidth=2 " That's a good tab width
set expandtab " ...and we don't like tab chars
set softtabstop=2
set tw=90 " 90 chars fits two columns on my screen
set wrap
set fdm=syntax " Use syntax to define folding
set fdls=99 " ...but start off unfolded
;; -*- mode: dotspacemacs -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration."
(setq-default
;; List of additional paths where to look for configuration layers.
;; Paths must have a trailing slash (ie. `~/.mycontribs/')
dotspacemacs-configuration-layer-path '()

Personally, when conducting technical interviews, I try to keep the interviewee right at the limits of their knowledge and ability. It's sort of like standing blindfolded in a room and walking in different directions until you hit a wall to get a sense of the size of the room (don't try this at home). So this often involves starting overly complex, then walking back until you find the interviewee's comfort zone. Let them demonstrate their knowledge for a while (and hopefully gain back some confidence), then push them out to the complexity zone again until they stop answering/start looking uncomfortable again.

To give a concrete example of what that would look like with this question (let's call "A" the interviewer and "B" the interviewee):

A: Thanks for coming in today! We here at CompuMegaCorp are glad you decided to interview with us, and personally, I hope you're enjoying the day so far...

B: Uh...yeah (shifts nervously in seat)

A: Great! So, for the projects you'd be working on here, we make heavy use

> mkdir -p foo/src/foo
> cd foo
> echo "(ns foo.core (:gen-class)) (defn -main [& args] (println \"Hello, world\"))" > src/foo/core.clj
> boot -s src pom -p foo -v 0.1.0 jar -m foo.core
Writing pom.xml and pom.properties...
Writing foo-0.1.0.jar...
> java -jar target/foo-0.1.0.jar
Error: Could not find or load main class foo.core
> boot -s src pom -p foo -v 0.1.0 uber jar -m foo.core
Writing pom.xml and pom.properties...
@jballanc
jballanc / -
Created September 1, 2016 02:07
59CGHPjM$X]r+n38WYp<KVD4z!1&0`u
function f(x)
if x > 0
unshift!(f(x-1), 1)
else
[1]
end
end
function crash(low, i, high)
try
@jballanc
jballanc / flatteno.clj
Last active January 2, 2016 13:18
Utility functions for Clojure's core.logic that can unwrap or flatten an arbitrarily deeply nested list (or list of lists).
(ns core.logic.util.flatteno
(:require [clojure.core.logic :as cl]))
(cl/defna unwrapo
"Unwrapps an arbitrarily deeply nested list"
[l o]
([[e] o]
(unwrapo e o))
([[f . r] o]
(cl/conso f r o)))
// So, ECMAScript 6 Harmony arrow_function_syntax says:
// ----8<----8<----8<----
// ''=>'' has only lexical ''this'', no dynamic ''this''
const obj = {
method: function () {
return () => this;
}
};
assert(obj.method()() === obj);
#include <stdlib.h>
#include <stdio.h>
#include <luajit-2.0/lua.h>
#include <luajit-2.0/lualib.h>
#include <luajit-2.0/lauxlib.h>
#include "main.h"
#define CHECK_LOADED(i) if(i) {\
fprintf(stderr, "Problem loading: %s\n",\
lua_tostring(L, -1));\