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 user) | |
(def users (atom #{})) | |
(defn full-name [{:keys [fname lname]}] (str fname " " lname)) | |
(defn all-names [] (map full-name @users)) |
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 user-expectations | |
(:use expectations user)) | |
(expect "John Dory" (full-name {:fname "John" :lname "Dory"})) | |
(ns user-expectations.scenarios | |
(:use expectations.scenarios user)) | |
(scenario | |
(with-redefs [users (atom #{{:fname "Mary", :lname "Dory"} {:fname "John", :lname "Dory"}})] |
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 user-expectations | |
(:use expectations user)) | |
(expect "John Dory" (full-name {:fname "John" :lname "Dory"})) | |
(expect ["Mary Dory" "John Dory"] | |
(with-redefs [users (atom #{{:fname "Mary", :lname "Dory"} {:fname "John", :lname "Dory"}})] | |
(all-names))) |
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
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<link href="css/web-repl.css" rel="stylesheet" type="text/css"> | |
<script src="js/lib/jquery-1.5.min.js" type="text/javascript"></script> | |
<script src="js/lib/jquery.websocket-0.0.1.js" type="text/javascript"></script> | |
<script src="js/lib/jquery.console.js" type="text/javascript"></script> | |
<script src="js/web-repl.js" type="text/javascript"></script> | |
<title>Web REPL</title> | |
</head> |
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 ws = null; | |
$(document).ready(function () { | |
ws = $.websocket("ws://" + window.location.host + "/websocket", { | |
events: { | |
'web-repl-response': function(info) { | |
currentCallback([ | |
{msg: info.response, | |
className:"jquery-console-message-value"} | |
]); |
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 web-repl | |
(:require clojure.main) | |
(:use [clojure.stacktrace :only [root-cause]])) | |
(defonce repl-sessions (ref {})) | |
(defn current-bindings [] | |
(binding [*ns* *ns* | |
*warn-on-reflection* *warn-on-reflection* | |
*math-context* *math-context* |
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
; the code I work with has a publish-fn that we use to publish json back to a web-socket. | |
; therefore, the following line is all we need to add to our application to get the web REPL working | |
(publish-fn (hash-map :type :web-repl-response :response (web-repl/do-eval command publish-fn)))) |
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
#console { | |
height: 820px; | |
background: #eee; | |
margin: 10px; | |
border-radius: 5px; | |
-moz-border-radius: 5px; | |
border: 1px solid #aaa; | |
} | |
#console div.jquery-console-inner { |
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
ruby did you know: | |
$ ruby --version | |
ruby 1.8.7 | |
$ irb | |
>> {[:a], "a", [:b], "b", [:c], "c"} | |
=> {[:b]=>"b", [:a]=>"a", [:c]=>"c"} |
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
require 'spec_helper' | |
describe MyController do | |
describe "create" do | |
it "filters sensitive data from the log" do | |
invocations = Rails.logger.spy_on.add | |
post :create, :myobj => {:social_security_number => "123-45-6789"} | |
invocations.grep(/Parameters:/).first.should include('"social_security_number"=>"[FILTERED]"') |
OlderNewer