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
splitWith :: (a -> Bool) -> [a] -> [[a]] | |
splitWith p x = case dropWhile (not . p) x of | |
[] -> [] | |
nonEmpty -> pref : splitWith p suf | |
where (pref, suf) = span p nonEmpty |
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
constructor("Views.Rankings", View.Template, { | |
content: function() { with(this.builder) { | |
div({id: "ranking", 'class': "widget itemList"}, function() { | |
div({'class': "widgetContent"}, function() { | |
ol().ref("rankingOl"); | |
}).ref('widgetContent'); | |
}); | |
}}, | |
viewProperties: { |
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
specify "joins to groupings" do | |
blog_post_counts = | |
Blog.left_join_to(BlogPost). | |
group_by(Blog[:id]). | |
project(Blog[:id].as(:blog_id), BlogPost[:id].count.as(:num_posts)) | |
Blog.join_to(blog_post_counts).project(:title, :num_posts).to_sql.should be_like(%{ | |
select | |
blogs.title, | |
t1.num_posts | |
from |
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
describe "a right-associative 3-table inner join, with subqueries on either side" do | |
it "generates the appropriate sql" do | |
posts_comments = Post.join(Comment, Post[:id] => :post_id) | |
rel = Blog.where(:user_id => 1).join(posts_comments, Blog[:id] => :blog_id) | |
rel.to_sql.should be_like_query(%{ | |
select t1.id as t1__id, | |
t1.user_id as t1__user_id, | |
t1.title as t1__title, | |
t2.posts__id as t2__posts__id, |
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
Blog.where(:user_id => 1).join(Post).where(Post[:title] => "Foo").join(User).to_sql.should be_like_query(%{ | |
select t1.t2__id as t1__t2__id, | |
t1.t2__user_id as t1__t2__user_id, | |
t1.t2__title as t1__t2__title, | |
t1.posts__id as t1__posts__id, | |
t1.posts__blog_id as t1__posts__blog_id, | |
t1.posts__title as t1__posts__title, | |
users.id as users__id | |
from (select t2.id as t2__id, | |
t2.user_id as t2__user_id, |
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
(Blog.where(:user_id => 1) | Blog.where(:public => true)).join(Post).to_sql.should be_like_query(%{ | |
select t1.id as t1__id, | |
t1.user_id as t1__user_id, | |
t1.public as t1__public, | |
posts.id as posts__id, | |
posts.blog_id as posts__blog_id | |
from ((select * | |
from blogs | |
where blogs.user_id = :v1) | |
union |
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
var isCommonJS = typeof window == "undefined"; | |
/** | |
* Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework. | |
* | |
* @namespace | |
*/ | |
var jasmine = {}; | |
if (isCommonJS) exports.jasmine = jasmine; | |
/** |
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
var io = require('socket.io'), | |
ioClient = require('./io-client').io, | |
http = require('http'), | |
socketServer = require('../lib/socket_server'), | |
agent = require('superagent'); | |
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 | |
var socketServer |
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
setQuestionId: (questionId) -> | |
questionRelations = [Question, Answer, Ranking, Vote].map (r) -> r.where({questionId}) | |
Monarch.Remote.Server.fetch([User, questionRelations...]) | |
.onSuccess => @setQuestion(Question.find(questionId)) |
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
# Private: searches the skiplist in a stairstep descent, following the highest | |
# path that doesn't overshoot the index. | |
# | |
# * next | |
# An array that will be populated with the last node visited at every level | |
# | |
# Returns the leftmost node whose index is >= the given index | |
findClosestNode: (index, next) -> | |
currentNode = @head | |
for i in [@currentLevel..0] |
OlderNewer