Skip to content

Instantly share code, notes, and snippets.

@gilbertw1
gilbertw1 / samplemacro.clj
Created July 29, 2013 21:27
->>> Sample Macro
(defn replace-if-underscore [element val]
(if (= element '_)
val
element))
(defn replace-underscores [form val]
(map #(replace-if-underscore % val) form))
(defn convert-forms [val [next-form & other-forms]]
(if (nil? next-form)
@return1
return1 / bitcoin-cpuminer.sh
Last active July 8, 2024 19:21
install a bitcoin cpuminer on ubuntu/debian
# install dependencies
sudo apt-get install libcurl4-openssl-dev libncurses5-dev pkg-config automake yasm
# clone cpuminer
git clone https://github.com/pooler/cpuminer.git
# compile
cd cpuminer
./autogen.sh
./configure CFLAGS="-O3"
@emasaka
emasaka / ltsv.clj
Last active December 12, 2015 08:39
LTSV parser by Clojure
;; LTSV (Labeled Tab-separated Values) parser by Clojure
(use '[clojure.string :only [split]])
(defn ltsv-parse-line
"Parses one LTSV line. Returns a map."
[^String line]
(reduce (fn [r s] (let [[k v] (split s #":" 2)] (assoc r k v)))
{} (split line #"\t") ))
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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?"
@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"))
@agnoster
agnoster / README.md
Last active September 25, 2024 09:27
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

@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
@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.

@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