Skip to content

Instantly share code, notes, and snippets.

View skuro's full-sized avatar

Carlo Sciolla skuro

View GitHub Profile
@skuro
skuro / context.xml
Created September 27, 2011 22:38
Initialize Clojure ns from Spring
<bean id="bootstrap_namespaces" parent="initClojureNs">
<property name="namespaces">
<list>
<value>/custom/ns</value>
</list>
</property>
</bean>
@skuro
skuro / stunnr.core.clj
Created October 6, 2011 09:50
stunnr.core.clj
(ns stunnr.core
(:require [http.async.client :as c]
[http.async.client.request :as r]))
(def results (atom []))
(def requests (atom []))
(defn fetch-url [^String url]
(swap! requests conj (future
@skuro
skuro / npe.clj
Created October 7, 2011 09:05
Clojure NPE
(defn alien-fn [str ns]
(let [cur *ns*
alien (in-ns ns)]
(eval (read-string str))
(in-ns cur)))
(alien-fn "(println *ns*)" (namespace 'yy))
java.lang.NullPointerException (NO_SOURCE_FILE:0)
@skuro
skuro / rename-files.clj
Created November 6, 2011 11:23
rename-files.clj
(defn rename-file [prefix file counter]
(.renameTo file (str prefix "-" counter)
(println (.getPath file))
(defn rename [dirpath prefix]
(map (partial rename-file prefix) (-> dirpath File. file-seq) (range)))
@skuro
skuro / code.clj
Created November 6, 2011 15:04
How to correctly make POST with async client
(require '[http.async.client :as c])
(require '[http.async.client.request :as r])
(let [cl (c/make-client)
vk "http://f0efff367fbb.rest.akismet.com/1.1/verify-key"
h {:content-type "application/x-www-form-encoded"
:user-agent "Development/1.0 | akismet/1.0-SNAPSHOT"}
b "key=f0efff367fbb&blog=http%3A%2F%2Fskuro.tk"
req (r/prepare-request :post vk :headers h :body b)
res (r/execute-request cl req)]
@skuro
skuro / test.clj
Created November 16, 2011 10:47
BDD in clojure
(ns test
(:use [lazytest.describe :only (describe it)]))
(defn sorter [seq]
(sort seq))
(describe sorter "A sorter"
(it "should return the given array in sorted order"
(= [1 2 3 4 5] (sorter [5 2 4 2 3])))
(it "should not throw any exception if the given array is empty"
@skuro
skuro / selector.sh
Created November 17, 2011 22:42
Eclipse multiple workspace selection
#!/bin/sh
VERSION=0.1
PRG=workspace
LS=`which ls` # avoid aliases
function usage()
{
echo "$PRG -- switch to Eclipse workspace for a specific environments"
echo "v$VERSION by Carlo Sciolla <carlo.sciolla@gmail.com>"
testDoFilter(com.backbase.portal.contentservices.web.filter.CmisAtomPubFilterBeanTest): null expected:<...Content Repository ([контент рипоситори])</cmis:productName>...> but was:<...Content Repository ([–∫–æ–Ω—Ç–µ–Ω—Ç —Ä–∏–ø–æ—Å–∏—Ç–æ—Ä–∏])</cmis:productName>...>
@skuro
skuro / Vagrantfile
Created April 20, 2012 11:47
Vagrant baby steps
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
config.vm.box = "lucid32"
config.vm.provision :puppet
config.vm.provision :puppet do |puppet|
puppet.manifests_path = "manifests"
puppet.manifest_file = "default.pp"
@skuro
skuro / pom.diff
Created May 6, 2012 19:08
Add David Thume to the contributors
Domus de Janas:plan-maven-plugin skuro$ git diff
diff --git a/pom.xml b/pom.xml
index 8677524..c3b3f7a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>