Skip to content

Instantly share code, notes, and snippets.

@davidsantiago
davidsantiago / gist:926154
Created April 18, 2011 20:55
SSH Port forwarding in Pallet!
(defmacro with-ssh-tunnel->
"Execute the body with an ssh-tunnel available for the ports given in the
tunnels map. tunnels should be a map from local ports (integers) to either
1) An integer remote port. Remote host is assumed to be 'localhost'.
2) A vector of remote host and remote port. eg, [\"yahoo.com\" 80].
Automatically closes the connection (and port forwards) on completion."
[request tunnels & body]
`(clj-ssh/with-ssh-agent [(execute/default-agent)]
(let [user# (:user ~request)
node-address# (compute/node-address (:target-node ~request))
(ns pallet-cascalog.core
(:use [pallet.resource :only (phase)]
[pallet.crate.automated-admin-user
:only (automated-admin-user)])
(:require [pallet.core :as core]
[pallet.compute :as compute]
[pallet.crate.hadoop :as h]
[pallet.crate.java :as j]))
;; Okay, here's the good stuff. We're trying to get a system up and
(ns pallet-cascalog.node
(:use [pallet.thread-expr :only (for->)]
[pallet.resource :only (phase)]
[pallet.crate.automated-admin-user
:only (automated-admin-user)])
(:require pallet.compute.vmfest
[pallet.core :as core]
[pallet.compute :as compute]
[pallet.crate.hadoop :as hadoop]
[pallet.crate.java :as java])
(defn- hadoop-service
"Run a Hadoop service"
[request hadoop-daemon description]
(let [hadoop-home (parameter/get-for-target request [:hadoop :home])
hadoop-user (parameter/get-for-target request [:hadoop :owner])]
(->
request
(exec-script/exec-checked-script
(str "Start Hadoop " description)
(as-user
@tbatchelli
tbatchelli / pallet-vmfest.md
Created March 12, 2011 20:25
Setup pallet with vmfest
  1. Install VirtualBox on your machine
  2. Disable login credential: $ VBoxManage setproperty websrvauthlibrary null
  3. Download and uncompress the following image https://s3.amazonaws.com/vmfest-images/ubuntu-10-10-64bit-server.vdi.gz
  4. Clone the image to the directory where you want it to be permanently stored: $ VBoxManage clonehd /path/to/downloaded/ubuntu-10-10-64bit-server.vdi /path/to/permanent/location/ubuntu...-server.vdi
    • This should produce a uuid for your new image. Keep it around
  5. Start VirtualBox (the GUI) and:
    1. Create an new image Linux - Ubuntu (64bit)
  6. Select "Use existing hard disk" and if your newly cloned image doesn't appear in the drop-down list, click on the folder icon and find the image in your hard disk (the one you just cloned)
@jonromero
jonromero / get-last-mentions.clj
Created March 9, 2011 10:58
Gets the latest mention for my twit-name on twitter
(defn get-latest-twit []
(:text (first (:results (twitter/search "@jonromero")))))
@aufflick
aufflick / emacs-pipe.pl
Last active February 9, 2018 23:44
Piping to an emacs buffer with emacsclient
#!/usr/bin/env perl
# You can use this script in a pipe. It's input will become an emacs buffer
# via emacsclient (so you need server-start etc.)
# See http://mark.aufflick.com/o/886457 for more information
# Copyright (C) 2011 by Mark Aufflick <mark@aufflick.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
@klang
klang / compress_jpg.clj
Created February 20, 2011 09:45
change compression level without losing the metadata of a jpg file
(ns sandbox.compress-jpg
(meta {:description "change compression level without losing the metadata of a jpg file"
:url "http://blog.carsoncheng.ca/2011/02/how-to-change-jpeg-compression-in.html"})
(:require clojure.java.io)
(:import [javax.imageio IIOImage ImageIO]
[javax.imageio.plugins.jpeg JPEGImageWriteParam]))
(defn compress-jpg [inputFile outputFile compressionQuality]
(let [image-reader (.next (ImageIO/getImageReadersByFormatName "jpg"))
image-writer (.next (ImageIO/getImageWritersByFormatName "jpg"))]
@kencoba
kencoba / prover.clj
Created February 19, 2011 04:49 — forked from anonymous/prover.clj
(ns
^{:doc
"Simple Theorem Prover 'Programming Language Theory and its Implementation' Michael J.C. Gordon"
:author "Kenichi Kobayashi"}
prover
(:use [clojure.test])
(:require [clojure.walk :as cw]))
(def constant #{'+ '- '< '<= '> '>= '* '= 'T 'F 'DIV 'not 'and 'or 'implies})
(ns replproject.compojure
(:use compojure.core
ring.adapter.jetty)
(:require [compojure.route :as route]
[net.cgrand.enlive-html :as html]))
(html/deftemplate index "index.html"
[ctxt]
[:p#message] (html/content (:message ctxt) ))