Skip to content

Instantly share code, notes, and snippets.

View tgallant's full-sized avatar
🌁
☕️☕️☕️

Tim Gallant tgallant

🌁
☕️☕️☕️
  • San Francisco, CA
View GitHub Profile
@tgallant
tgallant / e5.scm
Created November 4, 2014 05:29
euler5
;; helpers
(define (sum l)
(if (null? l)
0
(+ (car l) (sum (cdr l)))))
(define (sqr x)
(* x x))
@tgallant
tgallant / e7.scm
Created November 5, 2014 06:53
euler7
;; 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)))))
// sort items array and return the first three items
{{#items.sort(function() { return .5 - Math.random(); }).splice(0,3)}}
@tgallant
tgallant / main.cf
Created February 3, 2015 04:21
Postfix main.cf
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
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;
};
@tgallant
tgallant / pm.erl
Last active February 26, 2017 20:42
-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}}