Skip to content

Instantly share code, notes, and snippets.

(def ^:dynamic *default-fetch-size* 50)
(defn with-query-results-cursor [[sql & params :as sql-params] func]
(sql/transaction
(with-open [stmt (.prepareStatement (sql/connection) sql)]
(doseq [[index value] (map vector (iterate inc 1) params)]
(.setObject stmt index value))
(.setFetchSize stmt *default-fetch-size*)
(with-open [rset (.executeQuery stmt)]
(func (resultset-seq rset))))))
@ragnard
ragnard / fligh-recorder.sh
Last active December 30, 2015 18:59
Starting a JVM ready for remote profiling using flight recorder.
java -XX:+UnlockCommercialFeatures -XX:+FlightRecorder \
-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.port=1098 \
-Dcom.sun.management.jmxremote.authenticate=false \
-Djava.rmi.server.hostname=A.B.C.D \
-jar blahonga.jar
@ragnard
ragnard / 1
Last active January 2, 2016 18:09
rethink
Please accept my apologies for the direct contact. I am a specialist
technology headhunter that specialises in headhunting talented IT
professionals within the Cambridge area.
I’m not too sure if you can help me; I am looking for a talented
Software Developer (C#) professional with your technical expertise to
join my partner company’s award winning team with a view to advance on
their career and existing skills within a relatively short period of
time. My partner company is a well known global leading company within
the software field with main offices based in Cambridge. They have a
#s(hash-table size 18699 test equal rehash-size 1.5 rehash-threshold 0.8 data (:state-size 2 ("Here" "are") ("the" "the" "the" "the") ("are" "the") ("wrong" "trends" "trends" "trends" "trends") ("the" "trends") ("highlighted" "highlighted" "highlighted" "highlighted") ("trends" "highlighted") ("in" "in" "in" "in") ("highlighted" "in") ("this" "this" "this" "this") ("in" "this") ("document" "field." "space" "space." "edition:" "vibrant" "edition:" "edition" "edition:" "edition:") ("this" "edition:") ("Mobile—As" "•" "•" "Early") ("edition:" "Early") ("warning") ("Early" "warning") ("and" "and") ("warning" "and") ("recovery" "recovery") ("and" "recovery") ("in" "in") ("recovery" "in") ("production" "production") ("in" "production") ("using" "code." "-" "-") ("production" "-") ("We" "We") ("-" "We") ("are" "are") ("We" "are") ("reiterating" "always" "seeing" "strong" "pleased" "especially" "rapidly" "seeing" "interested" "excited" "not" "aware" "a" "also" "interested" "interested" "aware" "placing" "already" "in
(ns russel-quiz
(:require [clojure.math.numeric-tower :as math]
[loom.graph :as graph :refer [digraph]]
[loom.alg :as alg]))
(defn lcm
"Calculate least common multiple of some numbers."
([a b] (math/lcm a b))
([a b & more] (reduce lcm (lcm a b) more)))
@ragnard
ragnard / project.clj
Last active August 29, 2015 14:05
lein-docker
(defproject my-project
...
:plugins [[lein-docker "0.1.0-SNAPSHOT"]]
:docker {:image "ragge/clojure"
:ports {3000 8080}
:env {"SECRET_KEY" "lolcat"}}
...)
(require '[clojure.java.io :as io]
'[clojure.core.protocols :as protocols])
(defn line-reducible
"Given a source as accepted by clojure.java.io/reader, return a
reducible of the lines (as interpreted by clojure.core/line-seq) in
that source."
[source]
(reify
protocols/CollReduce
@ragnard
ragnard / nixos.sh
Last active August 29, 2015 14:13
nixos.sh
# sda1 = 512M EFI VFAT
# sda2 = swap
# sda3 = zfs
mkfs.vfat /dev/sda1
mkswap /dev/sda2
cryptsetup -y -v luksFormat /dev/sda3
cryptsetup open /dev/sda3 cryptroot
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
@ragnard
ragnard / gist:a48f337a581a736e01b5
Last active August 29, 2015 14:16
Configuring a component system?
(require
'[schema.core :as s]
'[com.stuartsierra.component :as component])
;;--------------------------------------------------------------------
;; A protocol for components that want configuration. To satisfy
;; protocol, they must provide a schema for their config.
(defprotocol IRequireConfig
(config-schema [this] "return schema of config for this component"))