Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A collection of Clojure functions for things we like to do.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 src
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 CHANGELOG.md
Octocat-spinner-32 LICENSE.html
Octocat-spinner-32 README.md
Octocat-spinner-32 project.clj
README.md

Sosueme (pronounced "So, sue me!") is a collection of Clojure functions for things we like to do.

Setup

The jar is available on Clojars at http://clojars.org/factual/sosueme .

Include it in your project.clj :dependencies:

[factual/sosueme "0.0.14"]

Contents

Sosueme provides the following functionalily, organized by namesapce:

conf namespace

Simple convenience functions for loading in file and resource based configuration data.

load-when

Takes a path to a file on the classpath, interprets the contents of the file as Clojure data, and returns the result. Example:

(println (:host (load-when "myconf.clj")))

load-file!

Loads and merges configuration from a specified path into current configuration data. This allows you to conveniently build up configuration data and refer to it from anywhere in your application.

get-key

Returns the value of a specific key, from current configuration data.

all

Returns all configuration data that was loaded via load-file!.

Example Use Case

Say you have a file called myconf.clj with this content...

{:host "my.server.com"
 :port 8081}

...then your app could do this:

(conf/load-file! "myconf.clj")
(let [host (conf/get-key :host)]
  ... )

hawaii namespace

Hawaiian style functions!

newname

Example:

> (repeatedly 6 newname)
("kiwihei" "nehe" "naimaiku" "lahehei" "wenani" "haikimi")

io namespace

I/O stuff, e.g. load content from the classpath.

slurp-cp

Slurps content from the classpath. Example:

(slurp-cp "somefile.txt")

net namespace

Nnetworking stuff, e.g. get local hostname.

local-hostname

Returns your local host name.

sys namespace

System stuff, e.g. get current process id.

pid

Returns the current process's PID, as a String.

time namespace

Time stuff, e.g. get Unix epoch value for "25 minutes ago".

now

Returns the Unix epoch value for the current time.

minutes-ago

Returns the Unix epoch value for N minutes ago. Example:

(minutes-ago 25)

txt namespace

Text handling stuff.

pretty

Uses Clojure's pprint to return a prettily formatted String representation of data, including line breaks for readability.

Example use:

(println (pretty {:a "b" :b "this is b it is a long thing" :c {:x "X" :y '(this is a long list of things)}}))

throwables namespace

stack-trace-str

Returns, as a String, the formatted stack trace from a throwable. Example use:

;; Assuming you have an Exception instance, e
(let [msg (stack-trace-str e)]
  ;; do something with msg, such as put it in a log
)

License

The use and distribution terms for this software are covered by the Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which can be found in the file LICENSE.html at the root of this distribution. By using this software in any fashion, you are agreeing to be bound by the terms of this license. You must not remove this notice, or any other, from this software.

Something went wrong with that request. Please try again.