This file contains hidden or 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
#lang scheme | |
(provide Take) | |
(define (Take source . patterns) | |
(if (= (length patterns) 1) | |
(Take1 source (first patterns)) | |
(map (lambda (source) | |
(apply Take source (rest patterns))) | |
(Take1 source (first patterns))))) |
This file contains hidden or 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 maxX = 0, minX = Infinity; | |
images.each(function(item){ | |
var imageCoords = item.getCoordinates(seatingPlan); | |
maxX = Math.max(maxX, imageCoords.right); | |
minX = Math.min(minX, imageCoords.left); | |
}); | |
var dimensions = {'left': minX, 'right': maxX}; | |
//////////////////////////////////////////////////////////////////// |
This file contains hidden or 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
<?xml version="1.0"?> | |
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="32" height="32" style="position: absolute; left: 77px; top: 40px; "> | |
<desc>Created with Raphaël</desc> | |
<defs/> | |
<path fill="#333333" stroke="none" d="{paste the path string here}"/> | |
<rect x="0.5" y="0.5" width="32" height="32" r="0" rx="0" ry="0" fill="#000000" stroke="#000" style="opacity: 0; " opacity="0"/> | |
</svg> |
This file contains hidden or 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
function getContainerDimensions(elements, container){ | |
// Returns an object { top: ..., right: ..., bottom: ..., left: ... } | |
// so that the dimensions will cover all of `elements` | |
// | |
// `container` is the element that the dimensions are relative to | |
return Seq.from(elements) | |
.invoke('getDimensions', container) | |
.pluck('top', 'right', 'bottom', 'left') | |
.unzip().apply(function (tops, rights, bottoms, lefts){ |
This file contains hidden or 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 parsedate = function (str) { | |
// parsedate: String -> Date or null | |
// | |
// Decodes the timestamps from the ihackernews api, it seems like | |
// they're produced by the following proc from news.arc. | |
// | |
// (def text-age (a) | |
// (tostring | |
// (if (>= a 1440) (pr (plural (trunc (/ a 1440)) "day") " ago") | |
// (>= a 60) (pr (plural (trunc (/ a 60)) "hour") " ago") |
This file contains hidden or 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 (test) { | |
this.test = test; | |
}; | |
Set.prototype = { | |
'add': function(s) { | |
return Set.add(this, s); | |
}, | |
'complement': function () { | |
return Set.complement(this); |
This file contains hidden or 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
#lang racket | |
(require xml | |
net/url | |
web-server/servlet | |
web-server/servlet-env) | |
(define (svg-response svg) | |
(make-response/full | |
200 #"OK" | |
(current-seconds) #"image/svg+xml; charset=utf-8" |
This file contains hidden or 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
(function () { | |
// Reading Function Metadata | |
// ========================= | |
// | |
// !!!!! DO NOT USE ANY OF THIS CODE FOR ANY PURPOSE IT WILL EAT YOU KIDS | |
// | |
// Because `Function.prototype.toString()` returns something like | |
// function source-code, we can parse it for metadata like the names of | |
// the formal arguments or the name of the function. | |
// |
This file contains hidden or 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
// Counting frames per second | |
// ========================== | |
// | |
// My basic strategy is to divide the time taken over the | |
// last n frames and return n seconds / time seconds. | |
// | |
// I must provide a method to say that a frame is done, so that | |
// the time can be recorded and a method to get the current FPS, | |
// and I must store the last n + 1 (because of the fencepost | |
// problem) times. |
This file contains hidden or 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
// Calc | |
// ---- | |
// | |
// A dumb/simple embeddable language for performing simple calculations | |
// It's so simple that you know it won't throw errors or run forever. | |
// | |
// e.g. ($area % 0.96) x 1.05 units 0.96 | |
// $area x 0.05 | |
// (2 x $centreline_length) x (2 x $width) | |
// |