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
-module(pm). | |
-export([perimiter/1,area/1,enclosure/1,linearBits/1,bits/1]). | |
%% Shape objects: | |
%% | |
%% For the sake of brevity, all shape values | |
%% are expected to be positive integers. | |
%% | |
%% {circle, Radius} | |
%% {rectangle, {Width,Height}} |
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 fs = require('fs'); | |
var request = require('request'); | |
var cheerio = require('cheerio'); | |
var saveFile = function(url) { | |
var file = url.split('/').pop(); | |
request(url).pipe(fs.createWriteStream(file)); | |
console.log('Downloading ' + file); | |
return true; | |
}; |
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
smtpd_banner = $myhostname ESMTP $mail_name (FreeBSD) | |
biff = no | |
# appending .domain is the MUA's job. | |
append_dot_mydomain = no | |
readme_directory = no | |
smtpd_tls_cert_file=/etc/ssl/certs/dovecot.pem | |
smtpd_tls_key_file=/etc/ssl/private/dovecot.pem |
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
// sort items array and return the first three items | |
{{#items.sort(function() { return .5 - Math.random(); }).splice(0,3)}} |
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
;; helpers | |
(define (nth n l) | |
(if (or (> n (length l)) (< n 0)) | |
(error "Index out of bounds.") | |
(if (eq? n 0) | |
(car l) | |
(nth (- n 1) (cdr 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
;; helpers | |
(define (sum l) | |
(if (null? l) | |
0 | |
(+ (car l) (sum (cdr l))))) | |
(define (sqr x) | |
(* x x)) |
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
;; e4 | |
(define (e4) | |
(define (e4-inner x y) | |
(let ((i (* x y))) | |
(if (> x 999) | |
'() | |
(if (< y 999) | |
(if (= i (rev i)) | |
(cons i (e4-inner x (+ y 1))) |
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
;; e3 | |
(define (e3 n) | |
(define (e3-inner num div) | |
(if (> num 1) | |
(if (= (modulo num div) 0) | |
(e3-inner (/ num div) (- div 1)) | |
(e3-inner num (+ div 1))) | |
(+ div 1))) | |
(e3-inner n 2)) |
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
;; helpers | |
(define (sum l) | |
(if (null? l) | |
0 | |
(+ (car l) (sum (cdr l))))) | |
;; e2 | |
(define (fib x) |
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
;; e1 | |
(define (mod-three-or-five? x) | |
(if (or | |
(= (modulo x 3) 0) | |
(= (modulo x 5) 0)) #t #f)) | |
(define (e1 x) | |
(sum | |
(filter |
NewerOlder