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
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]
@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 / 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 / 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 / Install Ruby On EC2
Created June 22, 2013 10:06
In order for you to very quickly get up and running with rbenv & the latest Ruby MRI. Just copy it and run it. Original Author: Parker J. Moore
# Taken from http://blog.parkermoore.de/2013/02/06/install-rbenv-on-ubuntu-12-dot-04/
# Author: Parker J. Moore
# I couldn't find the Gist...
sudo apt-get install zlib1g-dev openssl libopenssl-ruby1.9.1 libssl-dev libruby1.9.1 libreadline-dev git-core make make-doc
cd ~
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL # Restart the shell
@kikofernandez
kikofernandez / Berksfile
Last active December 20, 2015 16:09
chef-solo code for installing nginx and datomic
site :opscode
cookbook 'nginx'
cookbook 'chef-leiningen'
@kikofernandez
kikofernandez / Vagrantfile
Last active August 29, 2015 14:12
Ubuntu Trusty 64 bits: Development environment with GHC 7.8.3, cabal 1.20, clang, g++, valgrind, git, emacs and vim
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
@kikofernandez
kikofernandez / .gitignore
Created January 23, 2015 14:33
Global .gitignore
# Mac OS X hidden files
.DS_Store
# Vim swap files
.*.sw?
# Pow and Powder config
/.pow*
# RVM and rbenv
[Socket]1<-1[Server]
[Server]1-1>[Database]
[Server]++1-1>[Match]
[Match]++1-1>[Strategy]
[ABCClient]*-1>[Socket]
[ABCClient]^-[Responder]
[ABCClient]^-[Requester]
[Requester]uses -.- *>[Request]
@kikofernandez
kikofernandez / workaround.md
Created September 12, 2016 20:07 — forked from kgrz/workaround.md
Possible workaround for installing nokogiri 1.6.8 on OSX with brewed libxml2 2.9.4

Problem:

The following commands fail on OSX:

gem install nokogiri
gem install nokogiri -- --use-system-libraries
gem install nokogiri -- --use-system-libraries --with-xslt-dir=/usr/local/opt/libxslt --with-xml2-dir=/usr/local/opt/libxml2

Version: