Skip to content

Instantly share code, notes, and snippets.

@taylorSando
taylorSando / project.clj
Created September 17, 2012 00:13
The intended settings for a lein 2 compatible clojurescript one project
(defproject one "1.0.0-SNAPSHOT"
:description "Getting Started with ClojureScript."
:dependencies [[org.clojure/clojure "1.4.0"]
[ring "1.1.5"]
[compojure "1.1.3"]
[org.clojure/clojurescript "0.0-1450"]
[enlive "1.0.1"]
[domina "1.0.1-SNAPSHOT"]
[org.mozilla/rhino "1.7R3"]
[com.google.javascript/closure-compiler "r2079"]
@taylorSando
taylorSando / project.clj
Created September 17, 2012 18:54
project.clj settings for updated clojurescript one project
(defproject one "1.0.0-SNAPSHOT"
:description "Getting Started with ClojureScript."
:dependencies [[org.clojure/clojure "1.4.0"]
[ring "1.1.5"]
[compojure "1.1.3"]
[enlive "1.0.0"]
[domina "1.0.0"]
[org.mozilla/rhino "1.7R3"]
[com.google.javascript/closure-compiler "r1918"]
[org.clojure/google-closure-library "0.0-1376-2"]]
@taylorSando
taylorSando / session Override
Created October 23, 2012 13:07
Altering backbone to go to /login and /logout
sync: function(method, model, options) {
if (method == "update" || method == "create") {
var params = {type: "POST", dataType: "json", "url": ___ROOT_URL___ + "/login",
contentType: 'application/json', data: JSON.stringify(model.toJSON()),
processData: false
};
return $.ajax(_.extend(params, options));
} else {
@taylorSando
taylorSando / shoppers-locs
Created December 2, 2012 21:33
Shoppers Stores
http://www1.shoppersdrugmart.ca/en/store-locator/store-58.aspx
http://www1.shoppersdrugmart.ca/en/store-locator/store-6.aspx
http://www1.shoppersdrugmart.ca/en/store-locator/store-18.aspx
http://www1.shoppersdrugmart.ca/en/store-locator/store-50.aspx
http://www1.shoppersdrugmart.ca/en/store-locator/store-54.aspx
http://www1.shoppersdrugmart.ca/en/store-locator/store-105.aspx
http://www1.shoppersdrugmart.ca/en/store-locator/store-27.aspx
http://www1.shoppersdrugmart.ca/en/store-locator/store-7.aspx
http://www1.shoppersdrugmart.ca/en/store-locator/store-156.aspx
http://www1.shoppersdrugmart.ca/en/store-locator/store-2.aspx
;; The ->> threading macro will normally place the previous form into the last argument position of the next form
;; However, there are times when you are working with functions that don't take the required parameter in the last spot
;; In this example, I'm extracting all path locations before /v
;; re-seq first and second all work with the threading macro
;; However, when it comes time to split the string result, clojure.string/split takes two arguments
;; The first is the string, and the second is the regular expression to split on.
;; For the threading macro to work as is, these arguments need to be reversed
;; One way of doing this is creating an anonymous function that does this
;; #(clojure.string/split % #"/") This is the function
;; Then you actually evaluate by wrapping it in paranthesis
@taylorSando
taylorSando / datomic-function-binding.clj
Created December 25, 2012 07:38
You can't use map or vector binding in the params of a datomic function map. It will cause a 'clojure.lang.PersistentVector cannot be cast to java.lang.Stringclojure.lang.PersistentVector cannot be cast to java.lang.String
;; You can't use map or vector binding in the params of a datomic function map. It will cause a
;; 'clojure.lang.PersistentVector cannot be cast to java.lang.Stringclojure.lang.PersistentVector cannot be cast to java.lang.String
;; For example, I was attempting ot create a function so that I could pass the following to the transactor function:
;; (d/transact *conn* [ [:node/add {:node/description "Hello" :node/uri "http://www.example.com" :node/tags ["tag1", "tag2"]]])
;; This causes an error, because params isn't being treated like it can be bound to. You can only specify symbols to bind to
(def add-node {:db/doc "A function for adding a node to the database"
:db/ident :node/add
:db/fn (d/function '{:lang :clojure
:params [db [{:keys [uri description tags prerequisites]}]]
@taylorSando
taylorSando / datomic-rules.clj
Created June 5, 2014 01:15
Datomic recursion using rules
(defn recursive-rule
"A recursive rule for establishing prototype inheritance/isa relationship.
Can specify a maximum depth to travel, or none if there are no restrictinos.
rule The name of the rule
e The entity
a The attribute
v The value
Should be creating the rule like: (recursive-rule 'isa '?e '?a '?v)
Then within a query, can refer to it like this:
(isa ?e :thing/isa ?v) "
@taylorSando
taylorSando / clj-material-ui
Last active November 18, 2016 11:06
How to use material ui with om
(ns om-material-ui.core
(:require [clojure.string :as str]
[om-tools.dom :as omt]))
(defn kebab-case
"Converts CamelCase / camelCase to kebab-case"
[s]
(str/join "-" (map str/lower-case (re-seq #"\w[a-z]+" s))))
(def material-tags
@taylorSando
taylorSando / ui-material-build
Last active August 29, 2015 14:13
Altering javascript
(function () {
var React = require('react'),
injectTapEventPlugin = require("react-tap-event-plugin"),
materialUI = require('material-ui');
//Needed for React Developer Tools
window.React = React;
window.MaterialUI = materialUI;
(ns path.to.services.env
(:require
[clojure.tools.logging :as log]
[puppetlabs.trapperkeeper.core :as tk]
[puppetlabs.trapperkeeper.services :as s]))
(defprotocol EnvironmentConfigService
(get-config [this]
"Returns a map containing all of the configuration values (enviornmentally aware). Any string value that is
prefixed by ENV_, will be considered an environmental variable.")