Skip to content

Instantly share code, notes, and snippets.

View kikofernandez's full-sized avatar

Kiko Fernandez-Reyes kikofernandez

View GitHub Profile
@kikofernandez
kikofernandez / handler.clj
Last active December 17, 2015 12:09
Small example of Compojure handler working with the LinkedIn API using REST Web Services.
(ns linkedin-clojure.handler
(:use compojure.core)
(:require [compojure.handler :as handler]
[compojure.route :as route]
[hiccup.page :as hpage]
[hiccup.form :as form]
[cheshire.core :as parse]
[ring.util.response :as response]
[clj-http.client :as client]))
@kikofernandez
kikofernandez / MapReduce.java
Last active May 10, 2019 10:23
Example of a MongoDB map-reduce with a composite key, sorting the result set in the reduce operation. JavaScript example and its correspondent equivalent in Java
Mongo mongo = new Mongo(hosts);
String mapFn = "function(){ var value = {"+
"title: this.title,"+
"author: this.author,"+
"ISBN: this.ISBN,"+
"description: this.description"+
"};"+
"emit({rating: this.rating, author: this.author.id}, value);"+
"}";
@kikofernandez
kikofernandez / detail.html
Last active December 16, 2015 11:49
we are going to show how to use and forge a friendship between the back-end and front-end. For the back-end, we are going to use Clojure (Compojure + Hiccup + Ring + Sandbar), and for the front-end, we are going to use AngularJS. We are going to use AngularJS for building small mini-applications that do something very specific, call it domain dr…
<label>Título: </label>
<input type="text" name="titulo" ng-model="question.title">
<label>Respuestas: </label>
<ul ng-repeat="answer in answers" ng-model="answers">
<li>{{answer.title}}</li>
</ul>
<input type="text" name="answer" ng-model="answer">
@kikofernandez
kikofernandez / handler.clj
Created April 5, 2013 17:45
Small example of using sessions in Compojure using sandbar. The function is called stateful-route and is in the file handler.clj .In private.clj you can find an example of using and initializing a session using sandbar in Compojure.
(ns project-name.handler
(:require [compojure.handler :as handler]
[compojure.route :as route]
[ring.middleware.params :as params]
[sandbar.stateful-session :as session]
[project-name.controllers.private :as private]))
(defn- stateful-route
"Calls the routeFn adding stateful session."
[routeFn]