Skip to content

Instantly share code, notes, and snippets.

View built's full-sized avatar

Matt Youell built

View GitHub Profile
@built
built / gist:1955147
Created March 2, 2012 02:43
First naive (n^2) PDXErlang intersection implementation
-module(larray).
-include_lib("eunit/include/eunit.hrl").
-export([intersection/2]).
intersection(ListA, ListB) ->
[X || X <- ListA, lists:member(X, ListB)].
@built
built / gist:1955231
Created March 2, 2012 03:00
Later PDXErlang intersection implementation w/ Tim. Much more performant.
-module(larray).
-include_lib("eunit/include/eunit.hrl").
-export([intersection/2]).
intersection(ListA, ListB) ->
Numbers = lists:foldl( fun(N, Ranking) -> dict:update_counter(N, 1, Ranking) end , dict:new(), ListA ++ ListB),
lists:usort([Unique || Unique <- dict:fetch_keys(Numbers), dict:fetch(Unique, Numbers) > 1]).
%% helper functions to create big lists of random integers
large_random_array(N, MaxValue) ->
@built
built / reddit.com.js
Created March 14, 2012 07:52
An improvement for the Reddit killer
$(document).ready(function() {
$('body').empty();
document.title = "REDDIT IS A WASTE OF TIME";
});
@built
built / gist:2896420
Created June 8, 2012 16:00
Dictionary comprehension in C#
// Initial version w/ explicit types:
Dictionary<string, string> users = db.Users.Where(u => u.Account.Id == accountID).ToDictionary<User, string, string>(u => u.Id.ToString(), u => u.Login.Username);
// Without explicit type info.
var users = db.Users.Where(u => u.Account.Id == accountID).ToDictionary(u => u.Id.ToString(), u => u.Login.Username);
@built
built / zeke.rb
Created July 5, 2012 01:48
Rearranging deck chairs on this resume.
class EzekielTemplin
def initialize
@birthdate = Date.parse('1983-06-29')
@gender = "male"
end
def age
#still derp
Date.today.year - @birthdate.year
end
@built
built / wtf.js
Created October 29, 2012 22:17
The secret is to realize that there is no spoon.
if ( response && response.Status ) {
if ( response.Status.Status == 'OK' ) {
this.reloadBrowser();
} else {
console.log( response );
console.log( status );
this.reloadBrowser();
}
} else {
console.log( response );
@built
built / Camus
Created February 4, 2013 17:15
Footnote from the Myth of Sisyphus
I have heard of an emulator of Peregrinos, a post-war writer who, after having finished his first book, committed suicide to attract attention to his work. Attention was in fact attracted, but the book was judged no good.
@built
built / gist:5462795
Created April 25, 2013 20:18
My encoded twitter bio. It's fairly simple and a complete and utter waste of time.
0011011000110001001101110011001100110111001100110011011100110000001101100011010100110110011001010011011001100101001101100011100100110110001101010011011100110011
@built
built / gist:5558450
Last active December 17, 2015 05:29
Notes from first exposure to Go programming.
Meta about Tour of Go
Use of packages is nice.
Import syntax with quotes, as in Ruby. I don't like this. You quote the package name but then refer to the imported thing with a plain identifier? Why not omit the quotes so it is uniform?
Types after identifiers is weird, but I get the motivation. Should have gone all the way so everything works uniformly though.
Pointer syntax didn't have to be a star. Other options available.
Result parameters are interesting. But why do I have to say "return" at all?
@built
built / gist:5572803
Created May 14, 2013 00:56
Freeman Dyson on Education
(From Slashdot Q&A http://science.slashdot.org/story/13/05/13/1410230/interviews-freeman-dyson-answers-your-questions)
How has your education helped or hindered you? You are the "ideal" educated man. In our (American) culture, we don't seem to be producing people devoted to learning, discovering, thinking, inventing, etc. What in your opinion can an educational system do to foster what you've become?
Dyson: I was extremely lucky because I came through the British education system during the war when everything was screwed up. The whole system depended on written examinations and we did not have enough ships to import paper. So there was no paper and no exams. Also there was a high shortage of teachers since all the young people were away fighting the war. As a result, I was in class only seven hours a week. A wonderful time to get an education. We had maximum freedom, and the kids learned more from one another than we would have learned from teachers.
The kids today spend far too much time in class and a