Skip to content

Instantly share code, notes, and snippets.

View kyleburton's full-sized avatar

Kyle Burton kyleburton

View GitHub Profile
@kyleburton
kyleburton / gist:106079
Created May 3, 2009 17:55
clojure ftp example
(ns tiger
(:import ( org.apache.commons.net.ftp FTP FTPClient))
(:require [com.github.kyleburton.sandbox.ftp :as ftp])
(:use [ clojure.contrib.str-utils :as str]))
(def *tiger-ftp-url* "ftp://anonymous:user%40host.com@ftp2.census.gov/geo/tiger/TIGER2008/")
(ftp/list-all *tiger-ftp-url*)
(ftp/list-files *tiger-ftp-url*)
(ftp/list-directories *tiger-ftp-url*)
(defn dbf->tabfile [dbfile tabfile]
(with-open [dbf (org.xBaseJ.DBF. dbfile)]
(with-open [outp (java.io.PrintWriter. tabfile)]
(binding [*out* outp]
(println (str/str-join "\t" (field-names dbf)))
(for-each-row
(fn [recno fields]
(println (str/str-join "\t" (map #(.trim (.get %)) fields))))
dbf)))))
#!/usr/bin/env ruby
#
# Pipe mysql through this:
#
# mysql -uuser database_name -e 'select * from some_table' | rec-view.rb
#
# and it will produce a 'portrait' view of the records
#
# Record[1]
# [ 1] ID : 1
/*
* Use to await multiple async ajax requests in a 'fire and forget' approach, with an even triggered
* on completion. We used this to hold back the display of a lightbox until the outstanding requests
* had fetched the data necessary for display - provided the user with a fully rendered lightbox, rather
* than a skeleton within which multiple elements then shifted around or popped in.
*
* $(document).bind('data.retrieved',showMyLightbox);
* multiGet('data.retrieved', {
* url: '/redata/us-states/',
* success: function(d) { populateSelectList('select#st',d); },
cat scripts/monitor.sh
CMD=$(cat <<END_OF_COMMAND
echo;
echo '*** LISTING QUEUES for myvhost ***';
echo 'name, consumers, messages_ready, messages_unacknowledged';
rabbitmqctl -q list_queues -p 'myvhost' name consumers messages_ready messages_unacknowledged ;
echo;
echo '*** LISTING CONNECTIONS ***' ;
[Kyle Burton] kburton@phikburton-mb ~/development/loc-counts$ bash count.sh
Creating filelist for clojure
Have a non-directory at the top, so creating directory top_dir
Adding /Users/kburton/development/loc-counts/./count.sh to top_dir
Creating filelist for java
Creating filelist for javascript
Creating filelist for ruby
Creating filelist for sh
Categorizing files.
Finding a working MD5 command....
require 'java'
#require 'clojure-1.0.0.jar'
Dir["#{File.dirname(__FILE__)}/*.jar"].each { |jar| puts "requiring: #{jar}"; require jar }
import "clojure.lang.RT"
class CljHelper
def initialize *pkgs
@mappings = {}
@ns_map = RT.var "clojure.core", "ns-map"
@symbol = RT.var "clojure.core", "symbol"
import scala.io.Source
import scala.xml._
object SbtDepsFromPom {
def main ( args: Seq[String] ) {
val pomContents = Source.fromFile(args(0)).mkString
var xml = XML.loadString(pomContents)
var deps = (xml \\ "dependency") map { (dep) =>
List( (dep \\ "groupId")(0).text,
(dep \\ "artifactId")(0).text,
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..','lib','our_chef'))
node[:our_config] ||= {}
node[:our_config][:jvm_opts] ||= {}
node[:our_config][:jvm_opts][:max_heap] ||= "256m"
bash "create user servicerunner" do
user "root"
code <<-EOF
useradd -s /bin/bash -m servicerunner
#!/bin/sh -e
. /lib/lsb/init-functions
PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/var/lib/the-clj-service/the-clj-service.sh
NAME=the-clj-service
# any args passed to the process
SERVICES_OPTS="${2:-}"
PIDDIR="/var/run/the-clj-service"