Skip to content

Instantly share code, notes, and snippets.

<link rel="import" href="../code-mirror/code-mirror.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
I1212 22:03:27.103919 4515 fetcher.cpp:76] Fetching URI 'http://10.88.236.8:9000/proxy'
I1212 22:03:27.104070 4515 fetcher.cpp:126] Downloading 'http://10.88.236.8:9000/proxy' to '/tmp/mesos/slaves/20141212-210553-149706762-5050-2275-S5/frameworks/20141212-210553-149706762-5050-2275-0002/executors/KubeleteExecutorID/runs/f300609d-cb59-4851-a22f-7e57c183590f/proxy'
I1212 22:03:27.389055 4515 fetcher.cpp:76] Fetching URI 'http://10.88.236.8:9000/kubernetes-executor'
I1212 22:03:27.389119 4515 fetcher.cpp:126] Downloading 'http://10.88.236.8:9000/kubernetes-executor' to '/tmp/mesos/slaves/20141212-210553-149706762-5050-2275-S5/frameworks/20141212-210553-149706762-5050-2275-0002/executors/KubeleteExecutorID/runs/f300609d-cb59-4851-a22f-7e57c183590f/kubernetes-executor'
sh: 1: ./kubernetes-executor: Permission denied
@pmbauer
pmbauer / build.boot
Created December 17, 2014 19:44
there's a snake in my boot
(deftask snake []
(letfn [(copy-uri-to-file [uri file]
(with-open [in (clojure.java.io/input-stream uri)
out (clojure.java.io/output-stream file)]
(clojure.java.io/copy in out)))]
(let [snake-mp3 (java.io.File/createTempFile "snake" ".mp3")]
(copy-uri-to-file "http://movie-sounds.org/quotes/toys2/VOlCE-BOX-Theres-a-snake-in-my-boot.mp3" snake-mp3)
(speak :success (.getPath snake-mp3)))))
;; One example of why one might want to generate platform specific feature macros
;; I'm not saying this is a good DSL, just possible with https://github.com/feature-macros/clojurescript/tree/feature-macros/feature-macros-demo
(deftype-unified Foo [bar]
unified/Counted [(count [_] {:cljs (-count bar)
:clj (.count bar)})]
BazProtocol
(fizz [_] :buzz))
;; where unified/Counted [...] expands to clojure.lang.Counted/count on :clj and ICounted/-count on :cljs
(defn define-node-repl-launcher []
(fn [handler]
(fn [fileset]
(defn node-repl []
(require 'cemerick.piggieback 'cljs.repl.node)
((resolve 'cemerick.piggieback/cljs-repl)
:repl-env ((resolve 'cljs.repl.node/repl-env))
:output-dir ".noderepl"
:optimizations :none
:cache-analysis true
@pmbauer
pmbauer / euler14.clj
Created August 22, 2011 03:14
Three Clojure solutions to Euler 14
(ns euler14
(:use [clojure.repl]))
(defn max-euler14 [count-fn upper-bound]
(->> (range 1 (inc upper-bound))
(map (juxt identity count-fn))
(reduce (partial max-key second))))
; idiomatic
(defn euler14-terms [n]
@pmbauer
pmbauer / euler14.clj
Created August 22, 2011 16:52
Three Clojure solutions to Euler 14
(ns euler14
(:use [clojure.repl]))
(defn max-euler14 [count-fn upper-bound]
(->> (range 1 (inc upper-bound))
(map (juxt identity count-fn))
(reduce (partial max-key second))))
; idiomatic
(defn euler14-terms [n]
@pmbauer
pmbauer / quine_gawk.awk
Created September 10, 2011 05:23
Quine, a self-printing program
BEGIN{S="BEGIN{S=\"%s\";s=S;gsub(/\\\\/,\"\\\\\\\\\",s);gsub(/\\\"/,\"\\\\\\\"\",s);printf(S,s)}";s=S;gsub(/\\/,"\\\\",s);gsub(/\"/,"\\\"",s);printf(S,s)}
@pmbauer
pmbauer / mahout.clj
Created December 22, 2011 06:42
Mahout playground buffer
;; :dependencies [[org.apache.mahout/mahout-core "0.5"]]
;; :dev-dependencies [[slamhound "1.2.0"]]
(ns mia.mahout
(:import
(java.io File)
(org.apache.mahout.cf.taste.eval RecommenderBuilder)
(org.apache.mahout.cf.taste.impl.eval
AverageAbsoluteDifferenceRecommenderEvaluator
GenericRecommenderIRStatsEvaluator)
(org.apache.mahout.cf.taste.impl.model.file FileDataModel)
@pmbauer
pmbauer / y.clj
Created March 5, 2012 22:09
Memoized Y-Combinator
;; Y-combinator
(defn Y [f] ((fn [x] (f (fn [y] ((x x) y))))
(fn [x] (f (fn [y] ((x x) y))))))
;; Y-combinator memoized
(defn Y [f]
(let [c (atom {})
fp-gen (fn [x] (f (fn [y]
(or (@c y)