Skip to content

Instantly share code, notes, and snippets.

View davidrupp's full-sized avatar

David Rupp davidrupp

View GitHub Profile
@davidrupp
davidrupp / gemmate.rb
Created January 14, 2010 20:38 — forked from bguthrie/gemmate.rb
gemmate
#!/usr/bin/env ruby
if ARGV.empty?
puts "Usage: gemmate <name-of-gem>"
else
src = `gem which #{ARGV[0]}`.split.last
lib_dir = src.slice 0, src.rindex("lib")
`mate -a '#{lib_dir}'`
end
@davidrupp
davidrupp / gist:1212189
Created September 12, 2011 19:47 — forked from retr0h/gist:1001477
RVM + HomeBrew + Nokogiri
BREW_HOME=$HOME/.homebrew
$ brew install libxml2
$ brew link libxml2
$ brew install https://github.com/adamv/homebrew-alt/raw/master/duplicates/libxslt.rb
$ brew link libxslt
$ brew install libiconv
$ brew link libiconv
$ gem install nokogiri -- --with-xml2-dir=$BREW_HOME/Cellar/libxml2/2.7.8 --with-xslt-dir=$BREW_HOME/Cellar/libxslt/1.1.26 --with-iconv-dir=$BREW_HOME/Cellar/libiconv/1.13.1/
@davidrupp
davidrupp / gist:1304294
Created October 21, 2011 16:42 — forked from xlson/gist:1303759
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}
@davidrupp
davidrupp / pallet.snippets.clj
Created October 25, 2011 15:48 — forked from hhutch/pallet.snippets.clj
Pallet snippets that are useful
(defn nodes-in-group
"Build a list of nodes in a given security-group"
[security-group]
(filter #(= (% 0) security-group)
(map #(vector (pallet.compute/group-name %)
(pallet.compute/primary-ip %)
(pallet.compute/id %)
(pallet.compute.jclouds/node-locations %) )
(pallet.compute/nodes srvc))))
@davidrupp
davidrupp / cron-s3-rsync.clj
Created October 25, 2011 15:56 — forked from hhutch/cron-s3-rsync.clj
create a script with stevedore, schedule it with cron
(defn install-backup-scripts
"Creates a script in stevedore and installs it as a shell script in the administrative user's home dir
and installs it as a cron. This will override the crontab."
[request]
(let [administrative-user (:username (pallet.session/admin-user request))
admin-home-dir (str "/home/" administrative-user)
raw-instance-id (-> request :target-node (pallet.compute/id))
instance-id (apply str (interpose "_" (clojure.string/split raw-instance-id #"/")))
instance-group (-> request :target-node (compute/group-name))
s3-dir (str "/mnt/s3logstore/" instance-id "." instance-group)
@davidrupp
davidrupp / jetty.clj
Created October 29, 2011 03:43 — forked from minimal/jetty.clj
Websockets with clojure + jetty
;; Copyright (c) James Reeves. All rights reserved.
;; 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 epl-v10.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.
(ns compojure.server.jetty
"Clojure interface to start an embedded Jetty server."
;; -*- Mode: Clojure; indent-tabs-mode: nil -*-
;;
;; Licensed to the Apache Software Foundation (ASF) under one or more
;; contributor license agreements. See the NOTICE file distributed
;; with this work for additional information regarding copyright
;; ownership. The ASF licenses this file to you under the Apache
;; License, Version 2.0 (the "License"); you may not use this file
;; except in compliance with the License. You may obtain a copy of the
;; License at http://www.apache.org/licenses/LICENSE-2.0 Unless
;; required by applicable law or agreed to in writing, software
@davidrupp
davidrupp / lithp.rb
Created January 25, 2012 19:22 — forked from fogus/lithp.rb
class Lisp
def initialize
@env = {
:label => lambda { |(name,val), _| @env[name] = val },
:quote => lambda { |sexpr, _| sexpr[0] },
:car => lambda { |(list), _| list[0] },
:cdr => lambda { |(list), _| list.drop 1 },
:cons => lambda { |(e,cell), _| [e] + cell },
:eq => lambda { |(l,r), _| l == r },
:if => lambda { |(cond, thn, els), ctx| eval(cond, ctx) ? eval(thn, ctx) : eval(els, ctx) },
@davidrupp
davidrupp / gist:1861116
Created February 18, 2012 21:56 — forked from jlongster/gist:1712455
traditional lisp macros
;; outlet code for implementing traditional macro expansion
;; macros
(define (expand form)
(cond
((variable? form) form)
((literal? form) form)
((macro? (car form))
(expand ((macro-function (car form)) form)))
@davidrupp
davidrupp / clojure.md
Created April 16, 2012 05:22
Setting Up Clojure on OS X

Setting Up Clojure on OS X

I spent a lot of time trying to find a pretty optimal (for me) setup for Clojure… at the same time I was trying to dive in and learn it. This is never optimal; you shouldn't be fighting the environment while trying to learn something.

I feel like I went through a lot of pain searching Google, StackOverflow, blogs, and other sites for random tidbits of information and instructions.

This is a comprehensive "what I learned and what I ended up doing" that will hopefully be of use to others and act as a journal for myself if I ever have to do it again. I want to be very step-by-step and explain what's happening (and why) at each step.

I appreciate the effort you've put into documenting this, but there are a number of inaccuracies here that need to be addressed. We get