Posts

How to do an upload using REST (Swagger) and Clojurescript (ajav

Hoping to help someone else that is also struggling with this. I have used Luminus with Reagent to try this. Luminus come with Swagger for REST API, it's a great tool because it gives you the possibility to try the API as soon as you have write it. This is the code to write a REST end-point that accept a file in upload (ns your-clojure-ns   (:require [ring.util.http-response :refer :all]             [compojure.api.sweet :refer :all]             [schema.core :as s]             [ring.swagger.upload :as upload]) (defapi service-routes   {:swagger {:ui "/swagger-ui"              :spec "/swagger.json"              :data {:info {:version "1.0.0"                            :title "Sample API"                 ...

First project with Luminus and Reagent... impressions.

Ok I have started a project for a friend https://github.com/marcomanzi/arcatron, it's web application to charge customers for calls done. I'm using Luminus with Reagent as frontend... how it is going... I will compare this with my experience in doing something similar using Java, with Spring and Vaadin. During this development I had more feeling coming out, these are the things I want to share (not ordered by relevance) Fun: Well, this is a totally new experience, I have Terminator with 3 windows, one with lein test-refreh, one with lein run and one with lein figwheel. I really enjoy that I see happening in my browser while I change them. It's a new experience because with Vaadin every little change I had to restart the application server (it does not take long though) Creativity: Because there is not a clear path written (with Spring a Vaadin you are taken by hand and they guide you to the final result like a parent with a child) I was able to come out with my soluti...

SICP in Clojure: Chapter 2 (part 1)

Going on with my study of SICP, this is the first part of chapter 2 (that is a very big chapter and also has a lot of great examples). I also updated the code in the first chapter for some issues with chapter 2 names that were replicated (I made some private definitions there to use refer all here). The painter example of this book was really cool and actually you can create a painter with Quil library if you want to see it works. (ns sicp.chapter-2 (:require [sicp.chapter-1 :refer :all])) ;Common functions (defn null? [l] (and (seq? l) (empty? l))) ;Chapther 2: Building Abstractions with Data (defn linear-combination [a b x y] (+ (* a x) (* b y))) (declare add mul) (defn linear-combination [a b x y] (add (mul a x) (mul b y))) ;Chapter 2.1.1 (declare make-rat numer denom) (defn add-rat [x y] (make-rat (+ (* (numer x) (denom y)) (* (numer y) (denom x))) (* (denom x) (denom y)))) (defn sub-rat [x y] (make-rat (- (* (numer x) (denom y)) ...

What Clojure is missing...

Ok, now I have played with Clojure for a lot of time. I know how to write clojure programs, how to write in a functional style (on a base-medium level). What is my main work, what kind of applications I build for my company... Web Applications, batch programs for some heavy computations. Our main application is built with Grails, and I can't say that I'm am so found on Grails..... buuut .... Lately I built a web app to handle the deployment through Docker of our Web Application and I was thinking about using Clojure. This is how the discussion went (more or less): Marco : "I would like to use Clojure, is great, it gives immediate feedback and I would like to try because I feel I can do a good job" Other People  (in this company before starting we discuss pro and contro of every decision): "Mmm I heard of it.. yes it can be an idea, but what are you going to use, what is the standard. Let's say that you start the application and then you have to move on...

SICP in Clojure: Chapter 1

With a new year some new objectives should be set. Learn French Understand better functional programming Use Clojure in a real project (if you need help in some real project let me know :) ) This post is about the 2nd point. To learn more about functional programming I'm reading  Structure and Interpretation of Computer Programs .  This is really a great book but all the examples are in Lisp. To make it more actual I'm rewriting all the examples in clojure (and some exercises too).    I think it can be useful to others too, so here it is chapter 1: (ns sicp.chapter-1) ;1.1 Expressions (+ 137 349) (- 1000 334) (* 5 99) (/ 10 5) (+ 2.7 10) (+ 21 35 12 7) (* 25 4 12) (+ (* 3 5) (- 10 6)) (+ (* 3 (+ (* 2 4) (+ 3 5))) (+ (- 10 7) 6)) (+ (* 3 (+ (* 2 4) (+ 3 5))) (+ (- 10 7) 6)) ;1.2 Naming and the Environment (def size 2) size (* 5 size) (def pi 3.14159) (def radius 10) (* pi (* radius radius)) (def circumference (* 2 pi radius)) c...

Light Table

Ok after some work with it I have to say that it's really one of the easiest IDE to start with Clojure. The auto complete is very well done and is the only ide that make possible to start trying clojure without any issue with the IDE. ps: if you create a leiningen project LightTable will use the clojure version that you set in it, by default it will instead use the clojure 1.5.1

Clojure Ide: LightTable

Ok it has been some time since I start using clojure. I have to restart... and what is better than starting with the IDE. I want to give LightTable a try again, it was interesting last time I tried it. It's open source (under MIT) and I like the design. Here the first problems I find, I'm used to projects, so I would like to see a "Start new project" or something like that. Instead in LightTable you don't have that. Actually you don't have either a way to start easily a clojure project.... Ok let's read docs.. "With Clojure... In the view menu click the   commands   item (or press Ctrl+Space) Where is the commands item....., ok I go with the Ctrl+Space, but I don't like when they point me to something that don't exist... Ok after a little (10 minutes... not so little) I was able to figure out how it works, you create a folder, then you open the folder and it become your workspace. Actually I would have like a way to create a works...