Skip to content

Instantly share code, notes, and snippets.

@adambard
adambard / common.clj
Created April 3, 2013 17:59
Enlive code for Wagr
(ns wagr.views.common
(:require
[net.cgrand.enlive-html :as enlive]
))
(enlive/defsnippet show-bet "templates/index.html" [:.latest-bet-item]
[{better :better bettee :bettee bet :bet wager :wager}] ; ARGS
; TRANSFORMATIONS
[:.better] (enlive/content better)
@adambard
adambard / core.clj
Last active December 15, 2015 09:49
(ns nurblizer.core
(:gen-class :name nurblizer.core)
(:use compojure.core nurblizer.helpers)
(:require
[clojure.string :as str]
[ring.adapter.jetty :as ring]
[compojure.core :as compojure]
[compojure.route :as route]
[compojure.handler :as handler]))
(ns nurblizer.helpers
(:require
[clostache.parser :as clostache]))
(defn read-template [template-file]
(slurp (clojure.java.io/resource (str "templates/" template-file ".mustache"))))
; Quick-and-dirty Mustache renderer.
(defn render
import re
from flask import Flask, render_template, request
app = Flask(__name__)
# Read in the nouns file
with open("nouns.txt") as f:
NOUNS = [l.strip().lower() for l in f]
@adambard
adambard / app.rb
Last active December 15, 2015 09:39
require 'sinatra'
# configure block is a Sinatra feature
configure do
@@nouns = File.open('nouns.txt').map{|line|
line.strip.downcase
}
end
<?php
$nouns = file("nouns.txt", FILE_IGNORE_NEW_LINES);
function nurble($text){
$text = strtoupper($text);
$words = preg_split(
'/\w/',
preg_replace('/[^a-z ]/', '', strtolower($text)));
<?php include '_header.php'; ?>
<h1>Nurblizer</h1>
<form action="/nurble.php" method="post">
<fieldset>
<ul>
<li>
<label>Text to nurblize</label>
<textarea name="text"></textarea>
</li>
@adambard
adambard / gist:3890437
Created October 15, 2012 01:48
config.ru and Procfile for twilio voicemail email thingy
#### config.ru
require './app'
run Sinatra::Application
#### Procfile
web: bundle exec thin -R config.ru -p $PORT start
@adambard
adambard / Gemfile
Created October 15, 2012 01:31
Config files for voicemail
#### Gemfile
source "https://rubygems.org"
gem "sinatra"
gem "twilio-ruby"
gem "pony"
gem "thin"
@adambard
adambard / app.rb
Created October 15, 2012 01:12
Voicemail-by-email with Twilio
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>"