This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (transpose m) | |
(apply map list m)) | |
(define (rotate-90 m) | |
(transpose (reverse m))) | |
(define matrix | |
(list (list 'a 'b 'c 'd) | |
(list 'e 'f 'g 'h) | |
(list 'i 'j 'k 'l) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* timers in action | |
* http://nodejs.org/api/timers.html | |
*/ | |
// lastly this one is called, because it isn't resolved on the queue until ~50ms | |
// long after all the other functions are queued up in the event loop | |
setTimeout(function() { | |
console.log(5); | |
}, 50); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# osx nasm compile using macho64 | |
NASM=/usr/local/bin/nasm | |
LD=/usr/bin/ld | |
all: hello | |
@./hello | |
hello: hello.o | |
@$(LD) -macosx_version_min 10.0 -o hello hello.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# hear the md5sum of a file! ♬ ♬ ♬ ♬ | |
# by liam (github.com/liamgriffiths) | |
function beat { | |
tput bel | |
} | |
function beats { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
borrowed: | |
- IR code/library from http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html | |
- ultrasonic sensor code from http://arduino.cc/en/Tutorial/Ping | |
*/ | |
#include <IRremote.h> | |
#include <Servo.h> | |
// pins pins pins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// merge sort | |
// https://en.wikipedia.org/wiki/Merge_sort | |
var sort = function(list) { | |
// if list contains one element, it is sorted | |
if (list.length <= 1) return list; | |
// divide list in half into 2 sublists | |
var middle = Math.floor(list.length / 2); | |
var left = list.slice(0, middle); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// quick sort | |
// https://en.wikipedia.org/wiki/Quicksort | |
var sort = function(list) { | |
if (list.length <= 1) return list; | |
var pivot = list.splice(Math.floor(list.length / 2), 1); | |
var less = [], greater = []; | |
while (list.length) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Binary Search Tree | |
* | |
* This is a tree data structure that orders the nodes of the tree such that: | |
* - The left subtree only contains nodes of lesser values | |
* - The right subtree only contains nodes of greater values | |
* - There are no duplicate nodes | |
* | |
* What this is good for: | |
* - Storing unique values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Set = function() { | |
this._items = {}; | |
}; | |
Set.prototype = { | |
values: function() { | |
return Object.keys(this._items); | |
}, | |
insert: function(val) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Binary Heap | |
* | |
* This is a heap which is built on top of a binary tree. The binary tree can | |
* be built using a regular array and some arithmetic to find the array indicies | |
* of a particular node's children. | |
* | |
* The Binary Heap is a 'complete tree', meaning that all levels of the tree are | |
* completely filled before going deeper. The levels of the tree are filled from | |
* left to right. |
OlderNewer