Skip to content

Instantly share code, notes, and snippets.

View wilkes's full-sized avatar

Wilkes Joiner wilkes

View GitHub Profile
{-
public void take(int v) {
if (currentMode == Mode.accumulating) {
int digits = (int)Math.pow(10, (int)Math.log10(v) + 1);
int x = stack.pop();
x *= digits;
x += v;
stack.push(x);
}
{-# LANGUAGE FlexibleInstances #-}
module PivotalTeam.Html where
import Happstack.Server
import Text.XHtml.Strict
import PivotalTeam.State
instance HTML (TeamMember, Bool) where
toHtml (TeamMember n _, b) =
orderedForkIO :: [IO a] -> IO [a]
orderedForkIO actions = do
-- create a blocking container to hold the results for each IO action
mvars <- replicateM (length actions) newEmptyMVar
-- fork and run the action then put the result in the container
let run mvar action = forkIO $ action >>= putMVar mvar
-- fork and run each action with a container in the local run function
forkIO $ zipWithM_ run mvars actions
-- collect all the results, blocking until they are finished
mapM takeMVar mvars
(defn render-template
"Loads a StringTemplate off the classpath and binds the params"
[template-name & params]
(doto (. (StringTemplateGroup. "tmpls") getInstanceOf template-name)
(set-attrs! (partition 2 params))))
(defn set-attrs! [t attr-pairs]
(doseq [[k v] attr-pairs]
(. t setAttribute (name k) v)))
(regexp-opt '("defn" "defn-"
"defmulti" "defmethod"
"defmacro" "defmacro-"
"deftest"
"defstruct" "defstruct-"
"def"
"defonce" "defonce-"
"defnk"
"defvar" "defvar-"
"defunbound" "defunbound-"
(defn parse-qs [qs]
(let [split (fn [s v] (seq (.split s v)))
pairs (split qs "&")
parse-pair (fn [p] (map url-decode (split p "=")))]
(apply hash-map (mapcat parse-pair pairs))))
:formatted-report (run-report
(build-query (parse-report billing)
{"call_date_start" startdate
"call_date_end" enddate
"main_account_number_equals" account})
billing-formatter)
(ns floyd.reports
(:use [clojure.contrib.seq-utils :only [includes?]]
[floyd.formatters :only [billing-minutes billing-seconds as-minutes]]
[floyd.str-utils :only [join-str to-display-str]]))
(defparseable column-descriptor
[:table-column {:required true}]
[:name {:type :pair :default :table-column}]
[:label {:type :pair :default (fn [this] (to-display-str (:name this)))}]
[:calc {:enums #{:sum :avg :count}}]
(defn is-in? [v vs]
(some #{true} (map #(= % v) vs)))
var GoogleChartURL = "http://chart.apis.google.com/chart",
CPGoogleVeriticalStackedBarChart = @"bvs",
CPGoogleHorizontalStackedBarChart = @"bhs"
CPGoogleVeriticalGroupedBarChart = @"bvs",
CPGoogleHorizontalGroupedBarChart = @"bhs",
CPGoogleLineChart = @"lc",
CPGooglePieChart = @"p",
CPGooglePieChart3D = @"p3";
...