Skip to content

Instantly share code, notes, and snippets.

View mstump's full-sized avatar
😀

Matt Stump mstump

😀
View GitHub Profile
#!/usr/bin/ruby
#
# I deliberately didn't DRY /usr/local references into a variable as this
# script will not "just work" if you change the destination directory. However
# please feel free to fork it and make that possible.
#
# If you do fork, please ensure you add a comment here that explains what the
# changes are intended to do and how well you tested them.
#
# 30th March 2010:
(defn __findIntegerTriaglesWithIntRatio [p a bseq output]
(if (empty? bseq)
output
((def a (findArea p a (first bseq)))
(if (integerRatio? a p)
(recur p a (rest bseq) (conj output a))
(recur p a (rest bseq) output)))))
@mstump
mstump / broken.clj
Created February 3, 2012 23:32
Unexpected third parameter from Cascalog aggregator
(ns test.core
(:use cascalog.api)
(:require [cascalog [vars :as v]])
(:gen-class))
(def sample_data
[{:path nil, :javadoc? :not_present, :bundle_docurl nil, :bundle_symname nil, :bundle_name nil, :bundle_exportsrv nil, :prefix nil, :lastmodified 1127001651000, :bundle_importpkg nil, :groupid "xfire", :bundle_description nil, :version "1.0-20050917.231235", :size 21774, :packaging "jar", :remoteurl nil, :classnames nil, :signature? :not_present, :bundle_license nil, :source? :not_present, :sha1 "eed564da25682c728f7ad3da557656f0766376de", :repository nil, :bundle_exportpkg nil, :bundle_version nil, :fname nil, :description nil, :artifiactid "xfire-plexus", :md5 nil, :fextension "jar"}
{:path nil, :javadoc? :not_present, :bundle_docurl nil, :bundle_symname nil, :bundle_name nil, :bundle_exportsrv nil, :prefix nil, :lastmodified 1162775407000, :bundle_importpkg nil, :groupid "xfire", :bundle_description nil, :version "1.0-20050917.231219", :size -1, :packaging nil, :remoteurl nil, :classnames nil, :s
;; this one outputs to stdout until it dies due to 'Exceeded max jobconf'
(defn format-package-repo-for-cassandra
[source-type base-attributes sink repo]
(cio/with-fs-tmp [_ tmp]
(let [packages (package-seq repo)]
(if-not (empty? packages)
(let [lazy-tap (ops/lazy-generator tmp packages)]
(?<- (stdout)
[?row-key ?col ?val]
@mstump
mstump / topo_and_bolt.clj
Created April 20, 2012 06:51
data leaves spout, but doesn't arrive at bolt
(defbolt build-package-hash-bolt ["package"]
[tuple collector]
(emit-bolt! collector [(build-package-hash (:message tuple))] :anchor tuple)
(ack! collector tuple))
(defbolt json-deser-bolt ["message"]
[tuple collector]
(try
(emit-bolt! collector [(json/parse-string (:message tuple))] :anchor tuple)
(ack! collector tuple)
@mstump
mstump / gist:2472982
Created April 23, 2012 18:42
properties, why you exceed stack size?!?
(defn load-npm-callback
[err npm]
(.ls (. npm -commands) [] true print-deps))
(ns courier.test.storm.ruby
(:use [backtype.storm clojure]
[backtype.storm bootstrap testing]
clojure.test
midje.sweet)
(:require [courier.db :as db]
[courier.util :as util]
[courier.lib.ruby.core :as ruby]
[courier.storm.ruby :as sruby]
[courier.models.package :as pkg]
cljsc src '{:optimizations :simple :pretty-print true :target :nodejs}' > lib/sample.js
@mstump
mstump / error.log
Created December 10, 2012 17:06
immutant 0.7.0 deploy errors IMMUTANT-190
╰─$ lein immutant undeploy && lein immutant deploy && lein immutant run
Undeployed courier from /Users/mstump/.lein/immutant/current/jboss/standalone/deployments
Deployed courier to /Users/mstump/.lein/immutant/current/jboss/standalone/deployments/courier.clj
Starting Immutant: /Users/mstump/.lein/immutant/current/jboss/bin/standalone.sh
=========================================================================
JBoss Bootstrap Environment
JBOSS_HOME: /Users/mstump/.lein/immutant/current/jboss
@mstump
mstump / bit_index.cpp
Created July 9, 2013 15:22
Cross platform implementation of ffsll. Find the index of the first set bit of a 64 bit unsigned int. It uses the intrinsics available via clang, gcc and mvcc.
#include <stdint.h>
#include <iostream>
#include <boost/lexical_cast.hpp>
#ifndef ffsll
#ifdef _WIN32
inline char
ffsll(uint64_t x)
{
char index = 0x00;