Skip to content

Instantly share code, notes, and snippets.

View siscia's full-sized avatar

Simone Mosciatti siscia

View GitHub Profile
@siscia
siscia / morganmodelssocial.clj
Created November 30, 2012 17:35
Login with facebook in clojure
;;; MODELS
(ns morgan.models.social
(:require [clj-http.client :as client])
(:import [org.scribe.oauth OAuthService]
[org.scribe.builder ServiceBuilder]
[org.scribe.model Token Verifier OAuthRequest Verb])
(:import [org.scribe.builder.api FacebookApi TwitterApi]))
(def facebook-service
@siscia
siscia / morgan.models.social.clj
Created December 5, 2012 18:41
Login with twitter in clojure
(ns morgan.models.social
(:require [clj-http.client :as client])
(:import [org.scribe.oauth OAuthService]
[org.scribe.builder ServiceBuilder]
[org.scribe.model Token Verifier OAuthRequest Verb])
(:import [org.scribe.builder.api FacebookApi TwitterApi$Authenticate]))
(def twitter-service
(-> (doto
<?php
$dict = array (
"ftp" => function($input){
if (preg_match("/^([A-Za-z0-9_\-\.])+$/", $input)){
return TRUE;
}else{
return FALSE;
}
}
<?php
$dict = array (
"ftp" => function($input){
if (preg_match("/^([A-Za-z0-9_\-\.])+$/", $input)){
return TRUE;
}else{
return FALSE;
}
},
@siscia
siscia / skiplist.clj
Created January 9, 2013 21:22
basic implementation of skiplist
(ns skiplist.core)
(defn probability [& {:keys [p] :or {p 1/2}}]
(> p (rand)))
(defn remove-duplicate [s]
(distinct s))
(def c (atom 0))
(ns parallel-colt-matrix.core
(:require [core.matrix.protocols :as mp])
(:import [cern.colt.matrix.tobject.impl DenseObjectMatrix1D DenseObjectMatrix2D DenseObjectMatrix3D]))
(defn find-right-dimension [[vector]] ;;Need a better way to do this
(cond
(vector? (first (first vector))) (throw (Exception. "To be Done")) ;[(Class/forName "[[[Ljava.lang.Object;")]
(vector? (first vector)) [(Class/forName "[[Ljava.lang.Object;")]
:else [clojure.lang.PersistentVector]))
@siscia
siscia / DenseDoubleMatrix2D.clj
Created January 20, 2013 17:43
Very basic and questionable implementation of parallel-colt, only for DenseDoubleMatrix in 2 dimension.
(ns parallel-colt-matrix.impl
(:use [core.matrix.protocols])
(:require [core.matrix.implementations :as imp])
(:import [cern.colt.matrix.tdouble.impl DenseDoubleMatrix2D]))
(extend-type DenseDoubleMatrix2D
PImplementation
(implementation-key [m]
"Returns a keyword representing this implementation.
@siscia
siscia / DenseDoubleMatrix2D.clj
Created January 21, 2013 20:00
Basic implementation of parallel colt's DenseDoubleMatrix2D
(ns parallel-colt-matrix.impl
(:use [core.matrix.protocols])
(:require [core.matrix.implementations :as imp])
(:import [cern.colt.matrix.tdouble.impl DenseDoubleMatrix2D])
(:import [cern.colt.matrix.tdouble.algo DenseDoubleAlgebra]))
(extend-type DenseDoubleMatrix2D
PImplementation
(implementation-key [m]
In my life I want to be founder, an entrepreneur.
Make bussiness, make money, offer value, hire people, change the world and stuff like that.
November 2011 zhitomirskiy (http://en.wikipedia.org/wiki/Ilya_Zhitomirskiy) took his life, Aaron Swartz (http://en.wikipedia.org/wiki/Aaron_Swartz) did the same 20 days ago, and Jody Sherman (http://blog.launch.co/blog/should-we-talk-about-the-fact-that-jody-sherman-didnt-just-d.html) did too yesterday.
Now, I am not even close to those mind, but we can say that those guys up there are the prototype of person I want to be...
Like it turns out it is not a very healty sport... But it is what I wanna be.
However I also want to finish my life in a healty way, and I don't even yet know how, what and where it is gonna be.
(defn map-over-nested
([f ar]
(if (> (vector-dimensionality ar) 1)
(mapv (fn [a] (map-over-nested f a)) ar)
(mapv f ar)))
([f ar br]
(if (> (vector-dimensionality ar) 1)
(mapv (fn [a b] (map-over-nested f a b)) ar br)
(mapv f ar br)))