Skip to content

Instantly share code, notes, and snippets.

;; this file is a walkthrough of Moustache features, a web framework for Clojure
;; http://github.com/cgrand/moustache/tree/master
;; Moustache allows to declare routes, apply middlewares and dispatch on http methods.
;; Moustache is compatible with all frameworks built on Ring, including Compojure
(ns demo
(:use net.cgrand.moustache)
(:use [ring.adapter.jetty :only [run-jetty]])) ;; hmmm Ring without servlets
@ckdake
ckdake / redis_
Created October 15, 2010 21:47
munin plugin for monitoring redis
#!/usr/bin/perl -w
#
## Copyright (C) 2009 Gleb Voronich <http://stanly.net.ua/>, 2010 Chris Kelly <http://ckdake.com/>
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License
## as published by the Free Software Foundation; version 2 dated June,
## 1991.
##
@prasincs
prasincs / sha1-hash.clj
Created February 15, 2011 08:36
clojure sha1 hash
(defn get-hash [type data]
(.digest (java.security.MessageDigest/getInstance type) (.getBytes data) ))
(defn sha1-hash [data]
(get-hash "sha1" data))
(defn get-hash-str [data-bytes]
(apply str
(map
#(.substring
@rcampbell
rcampbell / s3.clj
Created May 11, 2011 10:14
Storing and retrieving Clojure data structures as GZIP compressed JSON in Amazon S3
(ns aws.s3
(:refer-clojure :exclude [get])
(:use [clojure.walk :only (keywordize-keys stringify-keys)]
[clojure.contrib.def :only (defonce-)]
[clojure.contrib.json :only (read-json write-json)])
(:import [java.io PrintWriter InputStreamReader ByteArrayInputStream ByteArrayOutputStream]
[java.util.zip GZIPInputStream GZIPOutputStream]
[com.google.common.base Charsets]
[com.amazonaws.services.s3 AmazonS3Client]
[com.amazonaws.services.s3.model Region CreateBucketRequest ObjectMetadata
@DavidWittman
DavidWittman / notes.md
Created February 22, 2012 18:54
A Brief Introduction to Fabric

A Brief Introduction to Fabric

Fabric is a deployment management framework written in Python which makes remotely managing multiple servers incredibly easy. If you've ever had to issue a change to a group servers, this should look pretty familiar:

for s in $(cat servers.txt); do ssh $s service httpd graceful; done

Fabric improves on this process by providing a suite of functions to run commands on the servers, as well as a number of other features which just aren't possible in a simple for loop. While a working knowledge of Python is helpful when using Fabric, it certainly isn't necessary. This tutorial will cover the steps necessary to get started with the framework and introduce how it can be used to improve on administering groups of servers.

@tanakh
tanakh / gist:3017519
Created June 29, 2012 11:47
conduit-0.5, proxy server, simplified by using async-2.0
{-# LANGUAGE OverloadedStrings #-}
import Data.Conduit
import Data.Conduit.Network
import Data.Conduit.Text (encode, decode, utf8)
import qualified Data.Conduit.List as CL
import qualified Data.Conduit.Binary as CB
import Data.Text (toUpper)
import qualified Data.ByteString.Char8 as S8
@agnoster
agnoster / README.md
Last active April 6, 2024 22:35
My ZSH Theme

agnoster.zsh-theme

A ZSH theme optimized for people who use:

  • Solarized
  • Git
  • Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)

For Mac users, I highly recommend iTerm 2 + Solarized Dark

@swaroopch
swaroopch / core.clj
Created September 26, 2012 11:23
Figuring out how to use Monger (Clojure MongoDB library) with multiple databases
(ns scratchpad.core
(:require [monger.core :as mg]
[monger.collection :as mc]
[monger.query :as mq]))
(def local-mongodb
(.getDB (mg/connect-via-uri! "mongodb://127.0.0.1:27017/local") "local"))
anonymous
anonymous / gist:4383179
Created December 26, 2012 21:06
Google Analytics Tracker Ring middleware for custom apis
(:use [ring.util.codec :only [url-encode]])
(defn- make-query-string [m]
(->> (for [[k v] m]
(str (url-encode k) "=" (url-encode (str v))))
(interpose "&")
(apply str)))
(defn make-ga-url [utmp ip]
(let [gif-url "http://www.google-analytics.com/__utm.gif?"
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.