Skip to content

Instantly share code, notes, and snippets.

@thickey
thickey / deps+nrepl.md
Last active October 26, 2018 19:57 — forked from solussd/deps+nrepl.md
nrepl + deps.edn quickstart

Instructions

  1. Add nrepl server dep to deps.edn :dev alias extra deps
org.clojure/tools.nrepl {:mvn/version "0.2.12"}
  1. create dev/user.clj containing the following:
(ns user
 (:require [clojure.tools.nrepl.server :as nrepl]))
@thickey
thickey / core.cljs
Last active August 29, 2015 14:17 — forked from scttnlsn/core.cljs
(ns nested-routing.core
(:require-macros [om.core :as om]
[secretary.core :refer [defroute]])
(:require [om.dom :as dom]
[om.core :as om]
[secretary.core :as secretary]
[goog.events :as events]
[goog.history.EventType :as EventType])
(:import goog.History))
@thickey
thickey / init.el
Last active August 29, 2015 14:07 — forked from martintrojer/init.el
;; Clojure
(require 'clojure-mode)
(setq auto-mode-alist (cons '("\\.cljs$" . clojure-mode) auto-mode-alist))
(setq inferior-lisp-program "lein repl")
;; clj-refactor
(require 'clj-refactor)
(add-hook 'clojure-mode-hook (lambda ()
(clj-refactor-mode 1)
(cljr-add-keybindings-with-prefix "C-c C-o")))
function Retry-Command
{
param (
[Parameter(Mandatory=$true)][string]$command,
[Parameter(Mandatory=$true)][hashtable]$args,
[Parameter(Mandatory=$false)][int]$retries = 5,
[Parameter(Mandatory=$false)][int]$secondsDelay = 2
)
# Setting ErrorAction to Stop is important. This ensures any errors that occur in the command are
@thickey
thickey / human_log.py
Last active August 29, 2015 14:06 — forked from steinim/human_log.py
FIELDS = ['cmd', 'command', 'start', 'end', 'delta', 'msg', 'stdout', 'stderr']
def human_log(res):
if type(res) == type(dict()):
for field in FIELDS:
if field in res.keys():
encoded_field = res[field].encode('utf-8')
print '\n{0}:\n{1}'.format(field, encoded_field)
@thickey
thickey / rps.clj
Last active December 19, 2015 14:29 — forked from puredanger/rps.clj
;; An implementation of the rock-paper-scissors variant -
;; rock-paper-scissors-lizard-spock - based on Alex Miller's core.async
;; implementation.
;; - http://tech.puredanger.com/2013/07/10/rps-core-async/
;; - https://gist.github.com/puredanger/5965883
;; - https://github.com/relevance/labrepl/blob/master/src/solutions/rock_paper_scissors.clj
;; - http://www.imdb.com/title/tt1256039/quotes?item=qt0493730
(require 'clojure.core.async :refer :all)
(ns dinesman
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
(defne aboveo [x y l]
([_ _ [y . r]]
(membero x l))
([_ _ [z . r]]
(!= z y)
(aboveo x y r)))
@thickey
thickey / gist:3896845
Created October 16, 2012 01:53 — forked from stuarthalloway/gist:3068749
datomic-clojure-relational-algebra-2012-07-07
;; Datomic example code
;; Demonstrates using datalog with Clojure defrecords
(use '[datomic.api :only [q db] :as d])
;;; http://www.lshift.net/blog/2010/08/21/some-relational-algebra-with-datatypes-in-clojure-12
(defrecord Supplier [number name status city])
(defrecord Part [number name colour weight city])
(defrecord Shipment [supplier part quantity])
;; sample data
@thickey
thickey / gist:3827215
Created October 3, 2012 14:29 — forked from stuarthalloway/gist:2645453
Datomic queries against Clojure collections
;; Datomic example code
(use '[datomic.api :only (db q) :as d])
;; ?answer binds a scalar
(q '[:find ?answer :in ?answer]
42)
;; of course you can bind more than one of anything
(q '[:find ?last ?first :in ?last ?first]
"Doe" "John")
@thickey
thickey / ember-precompile.js
Created June 25, 2012 19:55 — forked from zilkey/ember-precompile.js
Precompile .handlebars templates with node js
var fs = require('fs');
var vm = require('vm');
var emberjs = fs.readFileSync('public/javascripts/vendor/ember-0.9.5.min.js', 'utf8');
var templatesDir = 'templates';
var destinationDir = 'public/javascripts/templates';
function compileHandlebarsTemplate(templatesDir, fileName) {
var file = templatesDir + '/' + fileName;