Skip to content

Instantly share code, notes, and snippets.

;;with adv. optimizations on my macbook air
(ns foo
(:require [datascript :as d]))
(d/q '[:find (sum ?x)
:with ?idx
:in [[?idx ?x]]]
(map-indexed vector (range 10000)))
module Saucelabs
SAUCE_USERNAME = ''
SAUCE_TOKEN = ''
def self.setup_saucelabs_connection!(driver=nil)
WebMock.allow_net_connect!
driver ||= {
capability: :chrome,
platform: 'Windows 8',
version: '',
@lynaghk
lynaghk / deploy.sh
Created May 23, 2015 06:56
Sketch of setting up a server for Clojure apps
#!/bin/bash
set -e
lein uberjar
rsync target/weathertron.jar weathertron@weathertron:.
ssh root@weathertron svc -t /etc/service/weathertron
@lynaghk
lynaghk / gist:0b401411dd55d7af20d2
Created June 3, 2015 03:58
copy and eval form in cider buffer.
(defun cider-send-dwim (arg)
"Send the appropriate forms to the REPL to be evaluated."
(interactive "P")
(let ((expr (cider-last-sexp)))
(set-buffer (cider-current-repl-buffer))
(unless (eq (current-buffer) (window-buffer))
(pop-to-buffer (current-buffer) t))
(goto-char (point-max))
(insert expr)
(cider-repl-return)
@lynaghk
lynaghk / gist:52ec255ea22ba9f1efef
Created June 16, 2015 19:15
datascript entity export
;;Export datoms, replacing eids w/ tempids so that the datoms can be imported into a second datascript/datomic db.
(let [db (d/db conn)
eids (->> (d/q '{:find [?eid]
:in [$ %]
:where [(exportable ?eid)]}
db export-rules)
(map first)
set)
@lynaghk
lynaghk / gist:790631
Created January 21, 2011 23:25
R k-nearest neighbors example
#I'm using two non-standard packages; one for nearest neighbors (FNN) and one for doing split-combine-apply (think map reduce) type operations.
#you'll have to run this: install.packages(c('FNN', 'plyr'))
#you can also checkout documentation in R using the question mark; run this: ?knn
library(FNN)
library(plyr)
#Here are some random points on the plane to show you the interface
neartop = ldply(1:50, function(i){
c( x = rnorm(1)
, y = 1 + rnorm(1, sd=0.5))
Things I don't particularly like about Devin Chalmers:
1. He doesn't write any tests before implementing John Conway's Game of Life.
2. He asks for whiskey with lots of different, non-whiskey things mixed in.
3. He put a second top tube on his bicycle and then stopped riding it.
4. Looks better in a pair of brass goggles than I do.
@lynaghk
lynaghk / gist:823847
Created February 12, 2011 16:07
compojure resources problem between 0.5.2 and 0.6.0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;/login.html (a static resource) does not work in [compojure "0.6.0-RC4"]
;;however, the simple GET works fine
;; 2011-02-12 08:03:25.840:WARN::/login.html
;; java.lang.NullPointerException
;; at ring.middleware.session$wrap_session$fn__3069.invoke(session.clj:47)
;; at ring.middleware.cookies$wrap_cookies$fn__3009.invoke(cookies.clj:132)
;; at clojure.lang.Var.invoke(Var.java:365)
;; at ring.adapter.jetty$proxy_handler$fn__2063.invoke(jetty.clj:16)
;;
\documentclass[a4paper,11pt,leqno,article,oneside]{memoir}
\usepackage[leqno]{amsmath}
\usepackage{amsfonts}
\begin{document}
\title{Test Document}
\chapter{Clustering}
@lynaghk
lynaghk / gist:878657
Created March 20, 2011 20:40
Pubtex JSONP
<!DOCTYPE html>
<head>
<meta charset='utf-8'>
</head>
<body>
<h1>Original Page content</h1>
<p>blah blah blah</p>
<div id='my_pubtex'></div>
</body>
<script src='//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js'></script>