Skip to content

Instantly share code, notes, and snippets.

View xlson's full-sized avatar

Leonard Gram xlson

View GitHub Profile
@xlson
xlson / gist:1771096
Created February 8, 2012 17:06
clojure slingshot stacktrace
java.io.FileNotFoundException: Could not locate slingshot/core__init.class or slingshot/core.clj on classpath:
- Exception
java.lang.RuntimeException: java.io.FileNotFoundException: Could not locate slingshot/core__init.class or slingshot/core.clj on classpath:
at clojure.lang.Util.runtimeException(Util.java:165) ~[clojure-1.3.0.jar:na]
at clojure.lang.Compiler.eval(Compiler.java:6476) [clojure-1.3.0.jar:na]
at clojure.lang.Compiler.eval(Compiler.java:6455) [clojure-1.3.0.jar:na]
at clojure.lang.Compiler.load(Compiler.java:6902) [clojure-1.3.0.jar:na]
at clojure.lang.RT.loadResourceScript(RT.java:357) ~[clojure-1.3.0.jar:na]
at clojure.lang.RT.loadResourceScript(RT.java:348) ~[clojure-1.3.0.jar:na]
at clojure.lang.RT.load(RT.java:427) ~[clojure-1.3.0.jar:na]
@xlson
xlson / gist:1363542
Created November 14, 2011 08:39
Installing graphite on debian/ubuntu
Setup deps graphite
aptitude install python2.6
aptitude install python-cairo
aptitude install python-django
aptitude install python-django-tagging
aptitude install python2.6-twisted-core
aptitude install apache2
aptitude install libapache2-mod-wsgi
aptitude install memcached python-memcache
@xlson
xlson / listnodes.groovy
Created November 9, 2011 12:57
Listing node metadata on ec2 with jclouds
@GrabResolver(name='jclouds snapshot', root='https://oss.sonatype.org/content/repositories/snapshots')
@Grab('org.jclouds:jclouds-allcompute:1.3.0-SNAPSHOT')
import org.jclouds.compute.ComputeServiceContextFactory
def accesskeyid = '...'
def secretkey = '...'
def context = new ComputeServiceContextFactory().createContext("aws-ec2", accesskeyid, secretkey)
def nodes = context.getComputeService().listNodes()
@xlson
xlson / gist:1303759
Created October 21, 2011 12:50
basic-pallet-ec2
(ns quickstart.core
(:require pallet.core
pallet.compute
pallet.phase
pallet.crate.automated-admin-user))
(def basicnode
(pallet.core/node-spec
:image {:os-family :ubuntu :os-version-matches "10.10"}
:hardware {:min-cores 2 :min-ram 512}
@xlson
xlson / runner.sh
Created October 4, 2011 06:40
Generic run-script for a java app
#!/bin/sh
# Presumes this script is in the bin folder
HOME=`dirname $0`/..
cd $HOME
java -cp "lib/*" test.Main $@
@xlson
xlson / pom.xml
Created September 30, 2011 10:11
Example pom: GMaven with Groovy 1.8
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated from archetype; please customize. -->
<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>
<groupId>com.xlson.example</groupId>
<artifactId>gmaven-example</artifactId>
@xlson
xlson / pom.xml
Created September 29, 2011 17:31
Can't get @field working with gmaven and 1.8
...
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.8.0</version>
</dependency>
</dependencies>
@Grab('com.xlson.groovycsv:groovycsv:1.0')
import com.xlson.groovycsv.CsvParse
def csv = '''Name-Lastname
Mark-'Anderson-Nielsen'
Pete-Hansen'''
def data = new CsvParser().parse(csv, separator: '-', quoteChar: "'")
for(line in data) {
println "$line.Name $line.Lastname"
}
@xlson
xlson / whereto
Created September 6, 2011 14:37
Checks where a shortened url points to
#!/usr/bin/env groovy
def url = args[0]
def connection = url.toURL().openConnection()
connection.instanceFollowRedirects = false
if(connection.responseCode in [300, 301]) {
def redirectsTo = connection.getHeaderField('Location')
println "Redirects to: $redirectsTo"
} else {
@xlson
xlson / gist:1194252
Created September 5, 2011 06:40
working usage of groovycsv-1.0-SNAPSHOT in groovy console and plain groovy
@GrabResolver(name="blah", root="https://oss.sonatype.org/content/groups/public/")
@Grab("com.xlson.groovycsv:groovycsv:1.0-SNAPSHOT")
import com.xlson.groovycsv.CsvParser
def csv = '''apple,12
pear,24'''
new CsvParser().parse(readFirstLine:true, columnNames:['fruit', 'qty'], csv).each { println it }
println com.xlson.groovycsv.CsvParser.class.protectionDomain.codeSource.location