Skip to content

Instantly share code, notes, and snippets.

View siscia's full-sized avatar

Simone Mosciatti siscia

View GitHub Profile
@siscia
siscia / ABR.py
Created July 24, 2011 15:58
Una banale implementazione di un Albero Binario di Ricerca con Test TDD
# -*- coding: utf-8 -*-
class Nodi(object):
"""Implementazione dei nodi per un ABR"""
def __init__(self, value, father):
super(Nodi, self).__init__()
self.value = value
self.father = father
self.DX = None
self.SX = None
@siscia
siscia / gist:1572006
Created January 6, 2012 19:25
prova clojure jaudiotagger
(defproject audiotagger "1.0.0-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[org.clojure/clojure "1.3.0"]
[org/jaudiotagger "2.0.3"]]
:java-source-path [["src/java"]]
:main audiotagger.core)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(ns audiotagger.core
@siscia
siscia / core.clj
Created January 10, 2012 20:46
prove su clojutag
(ns clojutag.core
(:gen-class)
(:import [org.jaudiotagger.audio AudioFileIO]
[org.jaudiotagger.tag Tag FieldKey])
(:require [clojure.string :as str]))
(defn -main [& args]
(let [fl (new java.io.File "C:/Users/mosciatti/Desktop/Rihanna Umbrella PARODY Chris Brown - Copy.mp3")
inputfile (new AudioFileIO)
audiofile (.readFile inputfile fl)
@siscia
siscia / echonest example
Created January 18, 2012 04:14
echonest example
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package echo_nest;
import com.echonest.api.v4.*;
import java.io.File;
import java.io.IOException;
@siscia
siscia / veve
Created January 19, 2012 18:57
erver
(ns clojutag.core
(:gen-class)
(:import [org.jaudiotagger.audio AudioFileIO]
[org.jaudiotagger.tag Tag FieldKey]
[org.jaudiotagger.audio.real RealTag]
[com.echonest.api.v4 Song EchoNestAPI])
(:require [clojure.string :as str]))
(def api-key "SP3VJBGXDTYFD6IBT")
user> (use 'lamina.core 'aleph.tcp 'gloss.core)
nil
user> (defn handler [ch client-info]
(receive-all ch
#(enqueue ch (str "You said " %))))
#'user/handler
user> (start-tcp-server handler {:port 10000, :frame (string :utf-8 :delimiters ["\r\n"])})
#<netty$start_server$reify__6969 aleph.netty$start_server$reify__6969@aa85638>
user> (tcp-client {:host "localhost", :port 5635, :frame (string :utf-8 :delimiters ["\r\n"])})
<< ... >>
@siscia
siscia / gist:3111539
Created July 14, 2012 14:12
Simple first approach to a DAG
(ns bayle.core
(require clojure.set))
(defprotocol NODE
(change [this key new-value])
(add-parent [this new-parent])
(add-non-descendent [this new])
(node? [this])
(add-chile [this child]))
(deftype Node [name table]
Object
(equals [this other]
(= (:name this) (:name other)))
(hashCode [this]
(.hashCode (:name this))))
;; if i try
(set [(Node. :a "mmm") (Node. :a "bbbb")])
#!/bin/bash
# The logic to start up your application should be put in this
# script. The application will work only if it binds to
# $OPENSHIFT_INTERNAL_IP:8080
# save as .openshift/action_hooks/start
export HTTP_CLIENT="wget --no-check-certificate -O"
export PORT=$OPENSHIFT_INTERNAL_PORT
export HOST=$OPENSHIFT_INTERNAL_IP:8080
export HOME=$OPENSHIFT_DATA_DIR/home
@siscia
siscia / facebook-models-views.clj
Created November 30, 2012 17:33
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