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
(ns dispatchers.call | |
(:require [clj-asterisk.manager :as manager] | |
[clj-asterisk.events :as events] | |
[dispatchers.model :as model]) | |
(:import java.util.UUID)) | |
;; Signal the end of the call to the waiting promise in order to | |
;; release the channel | |
(defmethod events/handle-event "Hangup" | |
[event context] |
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
(ns notify-blaster.models.validation.user) | |
(def rules | |
{ :username {:validations | |
{:required true | |
:unique true | |
:max-length 50} | |
:messages | |
{:required "User name is required" | |
:unique "User name %s is already in use, please choose another one" |
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
(ns notify-blaster.models.validation.core) | |
(def ^{:dynamic true} *is-unique?* (fn [value] false)) | |
(def ^{:dynamic true} *default-messages* {:unique "Value %s is aready taken, please choose another one" | |
:required "Field is required" | |
:min-length "Field is shorter than required" | |
:max-length "Field is longer than required" | |
:range "Field value %s is not in range" | |
:email "Field must be a valid email address" | |
:matches "Fields do not match"}) |
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
''' | |
(c) 2011, 2012 Georgia Tech Research Corporation | |
This source code is released under the New BSD license. Please see | |
http://wiki.quantsoftware.org/index.php?title=QSTK_License | |
for license details. | |
Created on September, 12, 2011 | |
@author: Tucker Balch | |
@contact: tucker@cc.gatech.edu |
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
select TagName, | |
avg(cast(ResponseTime as bigint)) as Average, | |
stdev(cast(ResponseTime as bigint)) as StandardDev | |
from | |
(SELECT | |
Questions.CreationDate, | |
Questions.Title, | |
Tags.TagName, | |
Answers.CreationDate as ResponseDate, | |
datediff(minute, Questions.CreationDate, |
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
DECLARE @tagname varchar(20) = ##language:string## | |
select ResponseHour, | |
avg(cast(ResponseTime as bigint)) as Average, | |
stdev(cast(ResponseTime as bigint)) as StandardDev | |
from | |
(SELECT | |
Questions.CreationDate, | |
Questions.Title, |
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
DECLARE @tagname varchar(20) = ##language:string## | |
select DifficultyGroup, Count(1) Total, | |
avg(cast(ResponseTime as bigint)) as Average, | |
stdev(cast(ResponseTime as bigint)) as StandardDev | |
from | |
(SELECT | |
Questions.CreationDate, | |
Questions.Title, | |
Tags.TagName, |
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
(defn run | |
[] | |
(let [symbols ["AAPL","GLD","GOOG","$SPX","XOM"] | |
start-day (date-time 2012 1 1) | |
end-day (date-time 2012 12 31) | |
time-of-day (hours 16) | |
timestamps (get-NYSE-days start-day end-day time-of-day) | |
symbols-data (read-symbols-data "Yahoo" symbols) | |
adj-close-data (incanter.core/to-dataset | |
(get-data timestamps symbols (keyword "Adj Close") symbols-data time-of-day))] |
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
(defmacro apply-filtered | |
"Given two sequences, apply a function to each pair of elements when condition is met | |
anaphoras n and m exists for each indexed element | |
e.g. (apply-filtered / [1 2 3] [1 0 3] when (> m 0)) => (1 nil 1) | |
" | |
[op a b & condition] | |
`(for [x# (range (count ~a))] | |
(let [n# (nth ~a x#) |
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
(defn select-value | |
"Given a dataset indexed by date, returns the value corresponding to a specified column | |
if existent for a specific date" | |
[ds column date] | |
(let [row (ds {:Date date})] | |
(when-not (nil? row) (incanter.core/$ 0 column row)))) | |
(defn get-data | |
"Given a list of `symbols`, its data and a list of specific `timestamps`, builds a matrix(sequence) | |
with each column corresponding to a stock and the value extracted using `column` |