Skip to content

Instantly share code, notes, and snippets.

View dsp's full-sized avatar
💭
it's complicated

David Soria Parra dsp

💭
it's complicated
View GitHub Profile
(ns net.experimentalworks.clojure.outdegree
(:import
(edu.kit.ipd.sonar.server.centralities Centrality Centrality$Type CentralityImpl)
(java.util HashMap))
(:gen-class
:extends edu.kit.ipd.sonar.server.centralities.CentralityImpl))
(defn -getType [this] Centrality$Type/NodeCentrality)
(defn -getName [this] "Outdegree (Clojure)")
(defn -getVersion [this] 1)
public class OutdegreeCentrality extends CentralityImpl {
/**
* Return the Type of centrality.
*
* @return The type.
*/
public Type getType() {
return Type.NodeCentrality;
}
package net.experimentalworks.scala
import edu.kit.ipd.sonar.server._
import edu.kit.ipd.sonar.server.centralities.CentralityImpl
import edu.kit.ipd.sonar.server.centralities.Centrality
import scala.collection.JavaConversions._
import scala.collection.mutable.Map
import java.util.{HashMap => JavaHashMap}
/**
* Indegree calculations done in Scala.
(devmode) BuenosAires:~/dev/java/pse/> hg book -r 677 current
** Unbekannter Fehler, Details folgen
** Problemdetails bitte bei http://www.selenic.com/mercurial/bts
** oder mercurial@selenic.com melden
** Mercurial Distributed SCM (version 1.4.3+4-d9aa5b368e36+20100202)
** Erweiterungen geladen: ignoresubrepo, pager, patchbomb, bookmarks, color, mq, graphlog, rebase, mbox, histedit, hgk
Traceback (most recent call last):
File "/opt/local/bin/hg", line 27, in <module>
mercurial.dispatch.run()
File "/opt/local/lib/python2.6/site-packages/mercurial/dispatch.py", line 16, in run
@dsp
dsp / gist:294152
Created February 3, 2010 23:09
HSV Colorspace to RGB Colorspace transformation and vice versa
(defn hsv2rgb
([x] (apply hsv2rgb x))
([h s v] (map #(* 255 %)
(let [u (int (/ h 60.0))
f (- (/ h 60.0) u)
p (* v (- 1 s))
q (* v (- 1 (* s f)))
t (* v (- 1 (* s (- 1 f))))]
(condp = u
0 (list v t q)
(ns net.experimentalworks.clojure.outdegree
(:import
(edu.kit.ipd.sonar.server.centralities Centrality
Centrality$Type CentralityImpl)
(java.util HashMap))
(:gen-class
:extends edu.kit.ipd.sonar.server.centralities.CentralityImpl))
(defn -getType [this] Centrality$Type/NodeCentrality)
(defn -getName [this] "Outdegree (Clojure)")
(ns net.experimentalworks.clojure.comp
(:use compojure))
(defroutes helloworld-routes
(GET "/*"
(html [:html [:body [:p "Hello World"]]])))
(run-server {:port 8080}
"/*" (servlet helloworld-routes))
(ns net.experimentalworks.clojure.comp
(:use compojure))
(defroutes helloworld-routes
(GET "/*"
(html [:html [ :body [ :p "Hello World"]]])))
(decorate helloworld-routes (with-session :memory))
(run-server {:port 8080}
(ns net.experimentalworks.clojure.comp
(:use compojure))
(defroutes helloworld-routes
(GET "/login/:user"
[(session-assoc :loggedin (:user params))
(html [:html [:body [:p "You are now logged in as " (:user params)]]])])
(GET "/*"
(if (contains? session :loggedin)
(html [:html [:body [:p "Welcome back " [:b (:loggedin session)]]]])
(ns net.experimentalworks.clojure.comp
(:use compojure))
(defroutes helloworld-routes
(GET "/login/:user"
[(session-assoc :loggedin (:user params))
(html [:html [:body [:p "You are now logged in as " (:user params)]]])])
(GET "/logout"
(if (contains? session :loggedin)
[(session-dissoc :loggedin)