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
#!/usr/bin/env python | |
""" | |
The filename is grandiose. All this does is find the files in the | |
web/templates/mustache directory, and dump them all into web/static/js/templates.js as | |
members of the window.templates object. | |
""" | |
import os | |
import re | |
import json |
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
function stupid_tricks | |
% I made some functional tools for MATLAB. | |
assert(reduce_(@(x, y) x + y, [1, 2, 3, 4]) == 10) | |
% They got a little out of hand. | |
join = @(sep, args) ... | |
if_(ischar(sep), @() ... % Input check | |
reduce_(@(x, y) [x sep y], ... % Reduce to string | |
map_(@num2str, args))); % Convert args to string. |
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
join = @(sep, lst) ... | |
functools.if(~ischar(sep), @()[], @() ... | |
functools.reduce(@(x, y) [x sep y], ... | |
functools.map(@num2str, lst))); |
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
fact = functools.Y(@(self) @(n) ... | |
functools.if(n < 2,... | |
@() 1, | |
@() n * self(n - 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
""" | |
Proxy smtp to a starttls server with authentication, from a local | |
connection. | |
""" | |
from inbox import Inbox | |
from smtplib import SMTP | |
inbox = Inbox() | |
SMTP_HOST = 'mail.example.com' |
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
try { | |
assert(evaluate() == true); | |
return true; | |
} catch (AssertionError e){ | |
return false; | |
} |
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
jQuery -> | |
class QuestionView extends Backbone.View | |
el: $('#main') | |
tmpl: mustache_templates.question | |
url: '' | |
events: | |
"click .answer": "check_answer" |
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
require 'sinatra' | |
require 'json' | |
require 'mustache' | |
## INITIALIZATION ########################## | |
configure do | |
LANGS_AVAILABLE = { | |
'de' => 'languages/de_20k_trans.txt', | |
'fr' => 'languages/fr_20k_trans.txt', |
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
; Throws an error | |
(with-open [f (RandomAccessFile. "test_file.tmp", "rws")] | |
(map #(.writeInt f %1) (range 1000))) | |
; Runs happily | |
(with-open [f (RandomAccessFile. "test_file.tmp", "rws")] | |
(dorun (map #(.writeInt f %1) (range 1000)))) |
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
require 'rubygems' | |
require 'twilio-ruby' | |
require 'sinatra' | |
require 'pony' | |
require 'open-uri' | |
# Config | |
MY_NUMBER = "+19995551234" | |
TO_EMAIL = "voicemail@adambard.com" | |
SMTP_HOST = "<SMTP hostname here>" |