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
#include <stdio.h> | |
inline int max(int a, int b) { | |
return a > b ? a : b; | |
} | |
int main(int argc, char** argv) { | |
printf("Max of 3 and 5: %d\n", max(3, 5)); | |
return 0; | |
} |
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 comp3.core | |
(:use compojure.core) | |
(:require [compojure.route :as route] | |
[ring.adapter.jetty :as jetty])) | |
(defn simple-logging-middleware [app] | |
(fn [req] | |
(println req) | |
(app req))) |
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
;; The middleware takes 'app' as its parameter. In this | |
;; context app is going to be either another middleware | |
;; or the route handler. | |
;; | |
;; The return value is a new function that does the | |
;; processing you need and continues the middleware | |
;; chain. | |
(defn my-middleware [app] | |
(fn [request] | |
;; This is where you'd do any processing on the request |
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 comp2.core | |
(:use compojure.core) | |
(:require [compojure.route :as route] | |
[ring.middleware.session :as session] | |
[ring.adapter.jetty :as jetty])) | |
(defn set-session-var [session] | |
(if (:my-var session) | |
{:body "Session variable already set"} | |
{:body "Nothing in session, setting the var" |
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 comp1.core | |
(:use compojure.core) | |
(:require [compojure.route :as route] | |
[ring.adapter.jetty :as jetty])) | |
(defroutes helloworld-routes | |
(ANY "/" {} {:body "Hello Compojure!"}) | |
(route/not-found "Page not found")) |
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
(defproject comp1 "1.0.0-SNAPSHOT" | |
:description "FIXME: write" | |
:dependencies [[org.clojure/clojure "1.2.0"] | |
[org.clojure/clojure-contrib "1.2.0"] | |
[compojure "0.5.3"] | |
[ring/ring-jetty-adapter "0.3.1"]] | |
:keep-non-project-classes true | |
:main comp1.core) |