Skip to content

Instantly share code, notes, and snippets.

View kyleburton's full-sized avatar

Kyle Burton kyleburton

View GitHub Profile
(defn find-dupes-naieve [inp-seq]
(reduce (fn [res item]
(assoc res item (inc (get res item 0))))
{}
(map #(second (.split %1 "\t")) inp-seq)))
(defn find-dupes-with-bloom-filter [inp-seq expected-size fp-prob]
(let [flt (bloom/make-optimal-filter expected-size fp-prob)]
(reduce (fn [res item]
public class Main {
public static void main ( String args [] ) {
int size = 392000000;
int sampleSize = 20000;
System.err.println("Start: allocation");
int [] array = new int[size];
System.err.println("Done: allocation");
java.util.Random rnd = new java.util.Random();
System.err.println("Start: population w/line numbers");
SELECT column FROM table
ORDER BY RANDOM()
LIMIT 20000
(ns clj-etl-utils.sequences)
(def random-sample-seq
(let [rnd (java.util.Random.)]
(fn self [[item & population :as population-seq] population-size remaining-samples-needed]
(if (or (zero? remaining-samples-needed) (empty? population-seq))
nil
(if (< (.nextInt rnd population-size) remaining-samples-needed)
(lazy-cat
#!/usr/bin/env ruby
require File.join(File.dirname(__FILE__),'..','src','main','ruby','util')
require File.join(File.dirname(__FILE__),'deploy-check')
class ClojureServiceDeployer < ServiceUtils
def run
unless File.exist? release_jar_file
unless system("mvn assembly:assembly")
#!/bin/bash
SVC_HOME="/var/lib/the-clj-service/current"
# no args means we fork
if [ -z "${1:-}" ]; then
export SVC_JAR="$SVC_HOME/the-clj-servicejar"
if [ -z "$SVC_JAR" ]; then
echo "Error: SVC_JAR not found"
exit 1
#!/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"
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
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 '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"