Skip to content

Instantly share code, notes, and snippets.

@tjdett
tjdett / MyScalatraServlet.scala
Last active May 24, 2018 05:29
Scala + Apache POI to read uploaded Excel doc
package com.example.app
import org.scalatra._
import servlet.{SizeConstraintExceededException, FileUploadSupport}
import scalate.ScalateSupport
import java.io.ByteArrayInputStream
import org.apache.poi.ss.usermodel.WorkbookFactory
import org.apache.poi.ss.usermodel.Cell
import org.apache.poi.ss.usermodel.DataFormatter
import org.apache.poi.ss.usermodel.DateUtil
@tjdett
tjdett / atom.rng.xml
Created January 24, 2013 04:06
Atom schema in RELAX NG XML Syntax Grammar
<?xml version="1.0" encoding="UTF-8"?>
<!--
-*- rnc -*-
RELAX NG XML Syntax Grammar for the
Atom Format Specification Version 11
Converted from Relax NG Compact Syntax Grammar,
as seen in RFC 4287.
-->
<grammar ns="http://www.w3.org/1999/xhtml" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:s="http://www.ascc.net/xml/schematron" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
@tjdett
tjdett / .tmux.conf
Created September 21, 2012 03:38
My tmux config
# Mouse
setw -g mode-mouse on
set-option -g mouse-resize-pane on
set-option -g mouse-select-pane on
set-option -g mouse-select-window on
set-option -g mouse-utf8 on
# Titles
set-option -g set-titles on
set-option -g set-titles-string '#S:#I.#P #W'
@tjdett
tjdett / postgres_and_identd.markdown
Created August 28, 2012 00:04
Postgres and Identd on Fedora 17 - HOW-TO

Why?

Most commonly because you'd like to use JDBC to connect to your local Postgres server without using password auth. Very quickly you'll realise Unix sockets aren't supported in Java, so you can't use peer authentication.

How?

First, ensure your /var/lib/pgsql/pg_hba.conf uses ident for TCP/IP connections:

# IPv4 local connections:
host    all             all             127.0.0.1/32            ident
@tjdett
tjdett / bottom-right.js
Created May 31, 2012 00:16
Bottom-right pusher
// Works, but has odd side-effects with complex content
var handlePullBottomRight = function() {
_.chain($(".pull-bottom.pull-right"))
.map(function(v) { return $(v).parent(); })
.uniq()
.each(function(v) {
var pusher = $('<div></div>').addClass('pusher pull-right')
.css('width','0px');
var items = $(v).find(".pull-bottom.pull-right");
@tjdett
tjdett / reload_usb.sh
Created May 24, 2012 05:04
Reloading USB controller in Fedora 17
# used to fix "unable to enumerate USB device on port"
lspci
# Replace "xx.x" with the controller to unload
echo -n "0000:00:xx.x" > /sys/bus/pci/drivers/ehci_hcd/unbind
echo -n "0000:00:xx.x" > /sys/bus/pci/drivers/ehci_hcd/bind
@tjdett
tjdett / Procfile
Created January 31, 2012 01:43
Test case for Foreman Issue #97
test: ./test.sh $PORT
<?php
/*
* Static Class to handle getting information from the request better
*
* @author D.Holborow
* @version 1.0 2006/04/03
*
*/
class Request {
//--------------------------------------------------------------------------
@tjdett
tjdett / attach_coretardis_to_mytardis.sh
Created January 6, 2012 05:13
Migrate CoreTardis into MyTardis branch
#!/bin/bash
# NOTE: You can specify alternate locations environment variables
CORETARDIS_REPO=${CORETARDIS_REPO:-'https://github.com/aaryani/CoreTardis.git'}
MYTARDIS_REPO=${MYTARDIS_REPO:-'git://github.com/mytardis/mytardis.git'}
# Fork commit
FORK_BASE='9445c33ab383940fb4da556ff69fc21e5983ebdf'
# commit 9445c33ab383940fb4da556ff69fc21e5983ebdf
# Author: Ryan Braganza <[email protected]>
@tjdett
tjdett / example_file_monitoring.sh
Created December 21, 2011 00:52
Util for testing - prints green for 0 exit status, otherwise red
#!/bin/sh
while (true)
do
inotifywait -r -e close_write tardis/apps
red_green.sh bin/django test --settings=tardis.test_settings --failfast --tests='tardis.apps.oaipmh.tests.test_oai'
done