Skip to content

Instantly share code, notes, and snippets.

@davidkrisch
davidkrisch / howto-clj-hsqldb.clj
Created November 9, 2011 20:10
Connect to hsqldb with Clojure and korma
(comment Snippet of clojure to show how to connect to, insert, and query hsqldb)
(use 'korma.db)
(use 'korma.core)
(comment
The defdb call below assumes the following:
1. hsqldb has been started:
java -cp ../hsqldb/lib/hsqldb.jar org.hsqldb.server.Server --database.0 file:mydb --dbname.0 xdb
@davidkrisch
davidkrisch / watchr-recompile-less
Created December 7, 2011 22:41
HOWTO: Watchr recompiling Less on Save
# Install the necessary packages
# Assumes node.js/npm and ruby/gem are already installed
npm install less
gem install watchr
Create a .less file.
Run this (replace <filename> with the actual filename)
watchr -e 'watch("<filename>") { |f| system("lessc #{f[0]}") }' &
@davidkrisch
davidkrisch / gist:1818829
Created February 13, 2012 18:24
Express Cookie Handling - why does Connect call toLowerCase on all cookie names?
var express = require('express');
var app = express.createServer();
app.use(express.cookieParser());
app.get('/', function(req, res) {
// Prints undefined
process.stdout.write('req.cookies.RelayState = '
+ JSON.stringify(req.cookies.RelayState) + '\n');
// Prints undefined
@davidkrisch
davidkrisch / param.js
Created February 23, 2012 01:59
Express Route Param Pre-conditions combined with express-namespace
// This is an example of the Route Param Pre-condition
// feature of Express. It also uses express-namespace
// Documentation for the Route Param Pre-condition can
// be found here:
// http://expressjs.com/guide.html#route-param pre-conditions
var express = require('express'),
ns = require('express-namespace'),
app = express.createServer();
app.param('id', function(req, res, next, id) {
@davidkrisch
davidkrisch / accept-xml.js
Created March 26, 2012 23:13
Express-Node: Accepting POST with Content-Type: application/xml
// This script requires Express 2.4.2
// It echoes the xml body in the request to the response
//
// Run this script like so:
// curl -v -X POST -H 'Content-Type: application/xml' -d '<hello>world</hello>' http://localhost:3000
var express = require('express'),
app = express.createServer();
express.bodyParser.parse['application/xml'] = function(data) {
return data;
@davidkrisch
davidkrisch / printrequest.py
Last active September 20, 2017 20:38
A web server that prints POST requests to stdout
#!/usr/bin/env python
# Print POST request body to console
#
# To run it..
# virtualenv env
# source ./env/bin/activate
# pip install cherrypy
# python main.py
#
@davidkrisch
davidkrisch / postgres_wsl.md
Last active February 3, 2024 20:05
PostgreSQL on Debian in WSL