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 users-comp [x y] | |
(let [xsolved (count (:solved x)) | |
ysolved (count (:solved y)) | |
xlastlogin (:last-login x) | |
ylastlogin (:last-login y)] | |
(cond (> xsolved ysolved) 1 | |
(< xsolved ysolved) -1 | |
(and xlastlogin (nil? ylastlogin)) 1 | |
(and ylastlogin (nil? xlastlogin)) -1 | |
(and xlastlogin ylastlogin (.after xlastlogin ylastlogin)) 1 |
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
# Given a integer between 1 and 50 convert it to its Roman Numeral | |
def convert_to_roman (arabic) | |
ones_translation = | |
[ 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'] | |
tens_translation = | |
[ 'X', 'XX', 'XXX', 'XL', 'L'] | |
tens = "" |
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("Mocking Ajax Calls", function() { | |
beforeEach(function() { | |
loadFixtures('test.html'); | |
//mocking ajax call with Jasmine Spies | |
var fakeData = "You can put your return data here"; | |
spyOn($, "ajax").andCallFake(function(params) { | |
params.success(fakeData); | |
}); | |
}); |
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
function mymethod() | |
{ | |
var url = contextPath + "/bar.ajax"; | |
$.ajax({ | |
type: "POST", | |
url: url, | |
data: { type: "test"}, | |
success: function(json){ | |
$('#mydiv').html("Happy Face"); |
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
;;;;April Showers bring May Flowers | |
(ns my.april.showers) | |
(def sleep-time 20) | |
(def frame (java.awt.Frame.)) | |
(defn show-frame [frame x y] | |
(doto frame | |
(.setVisible true) | |
(.setSize (java.awt.Dimension. x y)) )) |
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 bowling-game.game) | |
(defrecord Frame [pins-hit-list]) | |
(defrecord Game [frame-list]) | |
(defn construct-frame [pins] | |
(Frame. [pins])) | |
(defn construct-empty-frame [] |
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
# An example of Mutual Recursion. | |
# A simple lexer for our parser. We only return tokens for :numbers | |
# and +, - and new lines. | |
class Lexer | |
attr_reader :token, :type | |
def initialize(stream) | |
@stream = stream | |
@tokens = [] |
NewerOlder