Skip to content

Instantly share code, notes, and snippets.

View teaforthecat's full-sized avatar

Chris Thompson teaforthecat

View GitHub Profile
@teaforthecat
teaforthecat / tile processor
Created January 17, 2013 16:39
dragonfly custom processor to create pyramidal tiff images to be used by iipsrv
class TileProcessor
def tile temp_object,tile_size=256
geom = "#{tile_size}x#{tile_size}"
temf = Tempfile.open('o.ptif')
`convert #{temp_object.path} -define tiff:tile-geometry=#{geom} -compress jpeg 'ptif:#{temf.path}'`
temf
end
end
tiled_images.processor.register(TileProcessor)
@teaforthecat
teaforthecat / clj-kafka-test.clj
Last active December 2, 2015 04:44
trying to fetch data from kafka, not being able to use "take"
(defn consumer-config [] {"zookeeper.connect" "localhost:2182"
"group.id" (str (java.util.UUID/randomUUID))
"auto.offset.reset" "smallest"
"auto.commit.enable" "false"})
(defn fetch-first [topic]
(with-resource [c (zk/consumer (consumer-config))]
zk/shutdown
(first (zk/messages c topic))))
@teaforthecat
teaforthecat / mongoid-models-summary.rb
Created September 23, 2012 03:04
Showing validation/error reporting problem with associated Mongoid models
class Artist
include Mongoid::Document
has_many :history_events, autosave: true, validate: true
end
class HistoryEvent
include Mongoid::Document
belongs_to :artist
validates_presence_of :headline
@teaforthecat
teaforthecat / PollStation.js.coffee
Created August 9, 2012 20:36
javascript timing mechanism to allow multiple machines to sync to the same time, within 50 milliseconds
class PollStation
start: => @runner = setInterval @oneSecond, 50
stop: => clearInterval(@runner)
runner: undefined
doOn: (num, func, args) =>
$(document).on 'poll:oneSecond', (e, second, epochSecond) ->
if (epochSecond % num) == 0
$(document.body).trigger("poll:#{num}Second")
func()
oneSecond: =>
@teaforthecat
teaforthecat / gist:2252216
Created March 30, 2012 15:16 — forked from jherrm/gist:1054913
startup script for unicorn with rvm global installation
#!/bin/bash
### BEGIN INIT INFO
# Provides: APPLICATION
# Required-Start: $all
# Required-Stop: $network $local_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start the APPLICATION unicorns at boot
# Description: Enable APPLICATION at boot time.
### END INIT INFO
@teaforthecat
teaforthecat / *slime-events*
Created January 28, 2012 03:43
swank debugger error in *slime-events*
:indentation-update
(("with-bindings" . 1)))
(:return
(:ok
(("Unable to resolve symbol: break! in this context" " [Thrown class java.lang.RuntimeException]" nil)
(("QUIT" "Quit to the SLIME top level"))
((0 " Util.java:156 clojure.lang.Util.runtimeException"
(:restartable nil))
(1 " Compiler.java:6720 clojure.lang.Compiler.resolveIn"
(:restartable nil))
@teaforthecat
teaforthecat / pianobar compile error
Created November 11, 2011 17:55
pianobar compile error
src/libwaitress/waitress.c: In function ‘WaitressHandleHeader’:
src/libwaitress/waitress.c:670:31: warning: assignment from incompatible pointer type
src/libwaitress/waitress.c: In function ‘WaitressFetchCall’:
src/libwaitress/waitress.c:1017:29: warning: assignment from incompatible pointer type
src/libwaitress/waitress.c:1018:22: warning: assignment from incompatible pointer type
src/libwaitress/waitress.c:1019:23: warning: assignment from incompatible pointer type
src/libwaitress/waitress.c:1022:23: warning: assignment from incompatible pointer type
src/libwaitress/waitress.c:1023:24: warning: assignment from incompatible pointer type
src/libwaitress/waitress.c:1039:5: warning: passing argument 2 of ‘gnutls_transport_set_pull_function’ from incompatible pointer type
/usr/include/gnutls/gnutls.h:910:8: note: expected ‘gnutls_pull_func’ but argument is of type ‘ssize_t (*)(struct WaitressHandle_t *, char *, size_t)’
client
dev tun
proto tcp
remote hostname 1194
resolv-retry infinite
nobind
mode server
tls-server
local xxx.xxx.xxx.xxx ## ip/hostname of server
port 1194 ## default openvpn port
proto tcp-server
dev tun
persist-key
@teaforthecat
teaforthecat / ruby-change-block.el
Created July 16, 2011 11:19
elisp -ruby change block from do to {
(defun ruby-change-block()
(interactive)
(save-excursion
(let (beg end start-char end-char start-line end-line block-content one-liner)
(ruby-beginning-of-block)
(progn
(re-search-forward "do")
(backward-kill-word 1);; kill "do"
(setq beg (point)