Skip to content

Instantly share code, notes, and snippets.

Avatar

Hugo Duncan hugoduncan

View GitHub Profile
@hugoduncan
hugoduncan / gist:1001548
Created Jun 1, 2011
debian squeeze preseed late_command for automated install of virtualbox guest additions
View gist:1001548
# Install virtualbox additions.
# Requires the guest additions iso connected to the secondary slave.
# This seems overly complicated, but is a combination
# that seems to work:
# the vbox ose packages were somehow being installed by the standard task,
# the LSB header is required for update-rc.d, which in turn is needed,
# due to straight linking to rc2.d not working (automatic boot sequence,
# and dependency management),
# cdrom source not being removed at the point when this script runs.
# Deletes /etc/udev/rules.d/70-persistent-net.rules to allow cloning.
View Keybase.md

Keybase proof

I hereby claim:

  • I am hugoduncan on github.
  • I am hugoduncan (https://keybase.io/hugoduncan) on keybase.
  • I have a public key ASDseSq5a9GjSqrnIsEMf3Ga_qvOzbvm9uamhZD2yQ3nCgo

To claim this, I am signing this object:

View gist:d3e942ce792588f25f5fc31828c9f9a4
Verifying my Blockstack ID is secured with the address 1MRCNmVgM2t3mryyaknMZagM9Rxdvs1v6K https://explorer.blockstack.org/address/1MRCNmVgM2t3mryyaknMZagM9Rxdvs1v6K
@hugoduncan
hugoduncan / list_view.clj
Last active Feb 7, 2016
Using a React Native ListView with om.next
View list_view.clj
(list-view
{:dataSource (clone-with-rows
data-source
(clj->js
(mapv #(assoc % :omcljs$meta (pr-str (meta %)))
objects)))
:renderRow (fn objects-render-r-row [row section-id row-id]
(let [row (j->c row)
m (:omcljs$meta row)
m (if m (reader/read-string m))
@hugoduncan
hugoduncan / gist:8611473
Created Jan 25, 2014
Scaling the Infrastructure Continuum
View gist:8611473

Scaling the Infrastructure Continuum

The choices of infrastructure is ever increasing - dedicated servers, VPS, cloud images, virtualisation and containers.

Each of these choices has advantages that suit a particular use case. A single application, when viewed from the development and operation perspective has many use cases however. Local virtualisation makes good sense for development. Ephemeral cloud nodes fit well for testing. Dedicated hardware is good choice for production in constant load environments. An image based solution is great

@hugoduncan
hugoduncan / gist:8611549
Created Jan 25, 2014
Criterium - reliable micro-benchmarks
View gist:8611549

Criterium - reliable micro-benchmarks

abstract

We’ve all timed a clojure function using clojure’s `time` macro, and then wondered why we don’t get stable results. We’ve seen Rich show off order of magnitude speed differences in new versions of clojure using the time macro. But what happens when you want reliable benchmarks, that can track small changes in timings? `time` falls short.

@hugoduncan
hugoduncan / Test.hs
Created Jan 12, 2014
An attempt to create a function that process an external representation of different data types
View Test.hs
{-# LANGUAGE ScopedTypeVariables #-}
module Test () where
-- a type class to specify parsing and encoding of a type
-- (in reality I'm using hedn, which is similar to aeson)
class T a where
f :: String -> a
g :: a -> String
@hugoduncan
hugoduncan / gist:1377108
Created Nov 18, 2011
Alternate cache protocol
View gist:1377108
(ns pallet.cache.impl
"An implementation namespace for pallet.cache")
(defprotocol CacheProtocolImpl
"Cache implementation interface."
(lookup [cache e] [cache e default]
"Retrieve the value associated with `e` if it exists")
(has? [cache e]
"Checks if the cache contains a value associtaed with `e`"))
@hugoduncan
hugoduncan / gist:6393438
Created Aug 30, 2013
Using JDK Watch Service
View gist:6393438
(ns com.palletops.brick-server.fs-watch
"Watch a filesystem path"
(:require
[clojure.java.io :refer [file]]
[clojure.set :refer [map-invert]]
[clojure.tools.logging :refer [debugf]]
[clojure.string :refer [join]])
(:import
[java.nio.file
ClosedWatchServiceException FileSystems Path StandardWatchEventKinds
@hugoduncan
hugoduncan / gist:4662037
Last active Dec 11, 2015
Examine failed test using ediff to compare actual and expected results
View gist:4662037
(defvar clojure-test-ediff-buffers nil)
(defun clojure-test-ediff-cleanup ()
"A function for ediff-cleanup-hook, to cleanup the temporary ediff buffers"
(mapc #'kill-buffer clojure-test-ediff-buffers))
(defconst re1
"Expected \\(?:.\\|\n\\)*, got (not ([^ ]+ \\(\"\\(?:.\\|\n\\)+\"\\) \\(\"\\(?:.\\|\n\\)+\"\\)))"
"Match predicate on strings test")
(defconst re2
"Expected \\(?:.\\|\n\\)*, got (not ([^ ]+ \\(\\(?:.\\|\n\\)+\\) \\(\\(?:.\\|\n\\)+\\)))"
You can’t perform that action at this time.