Skip to content

Instantly share code, notes, and snippets.

View siscia's full-sized avatar

Simone Mosciatti siscia

View GitHub Profile
@siscia
siscia / tick.py
Last active August 29, 2015 13:56
from flask import Flask
app = Flask(__name__)
@app.route("/clean-up")
def cleanUp():
"Clean the database from the old users"
cleanDatabase()
@app.route("/bill")
def bill():
@siscia
siscia / tick.js
Last active August 29, 2015 13:56
var express = require('express');
app = express();
app.get('/tick/clean-database', function(req, res) {
/*Daily job*/
cleanDatabase()
});
app.post('/tick/bill-custumer', function(req, res) {
/*Monthly job*/
billCustumers()
require 'sinatra'
get '/tick/db' do
cleanDB()
end
post '/bill' do
billCustumers()
end
(defresource get-user
:allowed-methods #{:get}
:available-media-types ["application/json"]
:malformed? (fn [ctx]
(let [q-params (get-in ctx [:request :query-params])]
(if-let [email (get q-params "email")]
[false {:query
{:email email}}]
(if-let [username (get q-params "username")]
[false {:query
@siscia
siscia / e_ale92.sh
Last active August 29, 2015 14:02
per e_ale92
Prendiamo un qualunque repo si github, per esempio questo: https://github.com/milano-js/frontend-tools
Con relativo indirizzo git:
https://github.com/milano-js/frontend-tools.git
Entriamo in una shell:
=======
simo@simo:~$ git clone https://github.com/milano-js/frontend-tools.git
(defn update-world [world room action]
;; if action is something like pick up an object from the room
;; I will return a new world without such object in the room,
;; if, otherwise, you are moving between some room I will return the same
;; world but you will obviously change the room
)
(loop [world {:roomA {} :roomB {}
room :roomA]
(let [[new-world next-room] (update-world world room (get-input))
layout title description category tags
post
Manage (Mongodb's) ObjectId and json
clojure
mongo
mongodb
rest
REST

I was writing yet another REST interface in Clojure + MongoDB (this is the last time) and if you have ever mixed this technology there is a little issues that raise every single time.

layout title description category tags
post
Manage (Mongodb's) ObjectId and json
clojure
mongo
mongodb
rest
REST

I was writing yet another REST interface in Clojure + MongoDB (this is the last time) and if you have ever mixed this technology there is a little issue that raises every single time.

Maps are fundamental data structures in any clojure program.

They are extremely fast, simple to reason about and very handy. Declaration of maps

As you may know, maps are a correlation between two clojure 'object' and are defined as so:

{% highlight clojure %} {"key_a" "value_a" "key_b" (fn [b] "value_b")

@siscia
siscia / ruby-clojure
Last active August 29, 2015 14:06 — forked from mikel99/ruby-clojure
ruby/clojure