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
(import 'com.google.appengine.tools.development.testing.LocalUserServiceTestConfig) | |
(import 'com.google.appengine.tools.development.testing.LocalServiceTestHelper) | |
;; EVAL: | |
(new LocalServiceTestHelper (new LocalUserServiceTestConfig)) | |
> com.google.appengine.tools.development.testing.LocalUserServiceTestConfig | |
cannot be cast to | |
[Lcom.google.appengine.tools.development.testing.LocalServiceTestConfig; | |
[Thrown class java.lang.ClassCastException] |
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
(defproject guestbook "1.0.0-SNAPSHOT" | |
:author "FIXME: Me" | |
:description "FIXME: Simple guestbook." | |
:compile-path "war/WEB-INF/classes" | |
:library-path "war/WEB-INF/lib" | |
:dependencies [[org.clojure/clojure "1.2.0-master-SNAPSHOT"] | |
[org.clojure/clojure-contrib "1.2.0-SNAPSHOT"] | |
[compojure "0.4.0-SNAPSHOT"] |
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
;taken from clj-gae-datastore/src/example/clojure/com/freiheit/gae/datastore/example.clj | |
; short-cut to set-up the GAE environment for interactive programming with Clojure and GAE | |
(ns com.freiheit.gae.datastore.example | |
(:use | |
[clojure.contrib def]) | |
(:import | |
[com.google.apphosting.api ApiProxy ApiProxy$Environment] | |
[java.io File] | |
[java.util HashMap] |
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 | |
(:import (com.google.appengine.api.users User UserService UserServiceFactory))) | |
(defn get-user-service [] | |
(UserServiceFactory/getUserService)) | |
(def *user* nil) | |
(defn inside-with-user-block? [] | |
(not= nil *user*)) |
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 app | |
(:gen-class :extends javax.servlet.http.HttpServlet) | |
(:use (compojure.http routes servlet helpers) | |
compojure.html) | |
(:use com.freiheit.gae.datastore.datastore-access-dsl | |
com.freiheit.gae.datastore.datastore-query-dsl | |
com.freiheit.gae.datastore.datastore-types) | |
(:import (com.google.appengine.api.users User UserService UserServiceFactory) | |
(com.google.appengine.api.datastore Query) | |
java.util.Date)) |
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
# Aliases | |
alias la="ls -a" | |
alias ll="ls -l" | |
# Show git branch | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[\1] /' | |
} |
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 savings-balance | |
[& accounts] | |
(->> (seq accounts) | |
(filter #(= (:type %) 'savings)) | |
(map :balance) | |
(apply +))) | |
;; Use case for 'same higher order function. | |
;; That's better. |
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 ack) | |
(in-ns 'ack) | |
(defn pow [x y] | |
(if (zero? y) 1 | |
(reduce * (repeat y x)))) | |
(defn up [a n b] | |
(cond (= n 1) (pow a 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
(let [precedence-counter (atom 0)] | |
(defn make-agent | |
{:post [(instance? clojure.lang.Agent %)]} | |
[& state] | |
(let [state (apply array-map state) | |
agent-type (or (:type state) ::agent) | |
state (dissoc state :type) | |
a (agent (with-meta | |
(merge {:name nil |
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
;;; Project 1, 6.001, Spring 2005 | |
(ns basebot | |
(:use clojure.test)) | |
(in-ns 'basebot) | |
;;; idea is to simulate a baseball robot | |
;; imagine hitting a ball with an initial velocity of v |