Skip to content

Instantly share code, notes, and snippets.

View jwhitlark's full-sized avatar

Jason Whitlark jwhitlark

View GitHub Profile
(ns org.whitlark.fc
(:import [org.apache.camel.impl DefaultCamelContext])
(:import [org.apache.camel.builder RouteBuilder])
(:gen-class))
(defn -main [& args]
(let [context (DefaultCamelContext.)]
(.addRoutes context (proxy [RouteBuilder] []
(configure []
(.. this (from "file:/home/jw/scratch/inbox?noop=true")
@jwhitlark
jwhitlark / gist:1228206
Created September 20, 2011 02:58
Rake as a library, from anywhere in the filesystem
#! /usr/bin/env ruby
require 'rubygems'
gem 'rake', '>= 0.7.3'
require 'rake'
Dir.chdir('where/I/want/to/be')
Rake.application.init('my-script-name')
@jwhitlark
jwhitlark / gist:5831b282ecce8e15d1e6
Last active August 29, 2015 14:02
Simple clock in Om
(defn clock-view [app owner]
(reify
om/IWillMount
(will-mount [_]
(js/setInterval
(fn [] (om/transact! app :time (fn [_] (js/Date.))))
100))
om/IRender
(render [_]
(dom/div nil (. (:time app) toUTCString)))))
(defn listen [el & types]
(let [out (chan)]
(doall (map (fn [type] (events/listen el type #(put! out %))) types))
out))
(defn set-states! [owner desired]
(doall (map #(om/set-state! owner (key %) (val %)) desired)))
@jwhitlark
jwhitlark / gist:0081c0b479591ce1b3c7
Created June 20, 2014 20:30
Scrubbing ints: first attempt
(defn scrubbing-int-state-view [app owner]
(let [start-capturing #(do (om/set-state! owner :capturing true)
(om/set-state! owner :start-x (.-clientX %)))
stop-capturing #(do (om/set-state! owner :capturing false)
(om/set-state! owner :start-x nil))]
(reify
om/IInitState
(init-state [_]
{:my-val 0
:capturing false
@jwhitlark
jwhitlark / gist:df071d0f065d9692031e
Created June 20, 2014 20:35
Lowering the sensitivity
(if (zero? (mod difference 5))
(do (om/update-state! owner :my-val (partial + (/ difference 5)))
(om/set-state! owner :start-x x)))
@jwhitlark
jwhitlark / gist:707f9fb5b379b39c51a5
Created June 20, 2014 20:45
Scrubbing Ints: Second attempt
(defn scrubbing-int-app-event-view-2 [app owner]
(reify
om/IInitState
(init-state [_]
{:capturing false
:start-x nil})
om/IWillMount
(will-mount [_]
(let [mouse-chan (async/map (fn [e] {:x (.-clientX e)
:type (.-type e)})
@jwhitlark
jwhitlark / google.clj
Created March 25, 2015 20:16
Combine friend, oauth2, and JWT token processing.
(ns foo.auth.google
(:require [clojure.string :as str]
[clojure.java.io :as io]
[clojure.data.json :as json]
[clojure.logging :refer :all]
[friend-oauth2.util :refer [format-config-uri]]
[friend-oauth2.workflow :as oauth2])
(:import [java.security.cert CertificateFactory]
[org.apache.commons.codec.binary Base64]))
@jwhitlark
jwhitlark / reagent_datascript.cljs
Created March 14, 2016 22:56 — forked from allgress/reagent_datascript.cljs
Test use of DataScript for state management of Reagent views.
(ns reagent-test.core
(:require [reagent.core :as reagent :refer [atom]]
[datascript :as d]
[cljs-uuid-utils :as uuid]))
(enable-console-print!)
(defn bind
([conn q]
(bind conn q (atom nil)))
@jwhitlark
jwhitlark / google-api.clj
Created January 31, 2019 19:45 — forked from arohner/google-api.clj
Clojure example of accessing google APIs directly
(ns example.api.google
(:require [cemerick.url :as url]
[cheshire.core :as json]
[clj-jwt.core :as jwt]
[clj-jwt.key :as key]
[clj-time.core :as time]
[clj-http.client :as http]
[clojure.string :as str])
(:import java.io.StringReader))