This file contains hidden or 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
{- | |
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); | |
} |
This file contains hidden or 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
{-# 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) = |
This file contains hidden or 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
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 |
This file contains hidden or 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
(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))) |
This file contains hidden or 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
(regexp-opt '("defn" "defn-" | |
"defmulti" "defmethod" | |
"defmacro" "defmacro-" | |
"deftest" | |
"defstruct" "defstruct-" | |
"def" | |
"defonce" "defonce-" | |
"defnk" | |
"defvar" "defvar-" | |
"defunbound" "defunbound-" |
This file contains hidden or 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
(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)))) |
This file contains hidden or 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
:formatted-report (run-report | |
(build-query (parse-report billing) | |
{"call_date_start" startdate | |
"call_date_end" enddate | |
"main_account_number_equals" account}) | |
billing-formatter) |
This file contains hidden or 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
(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}}] |
This file contains hidden or 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
(defn is-in? [v vs] | |
(some #{true} (map #(= % v) vs))) |
This file contains hidden or 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 GoogleChartURL = "http://chart.apis.google.com/chart", | |
CPGoogleVeriticalStackedBarChart = @"bvs", | |
CPGoogleHorizontalStackedBarChart = @"bhs" | |
CPGoogleVeriticalGroupedBarChart = @"bvs", | |
CPGoogleHorizontalGroupedBarChart = @"bhs", | |
CPGoogleLineChart = @"lc", | |
CPGooglePieChart = @"p", | |
CPGooglePieChart3D = @"p3"; | |
... |