This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns gems) | |
(def unique-by | |
"inverts the range of f" | |
[f s] | |
(vals (zipmap (map f s) s))) | |
(defn decompose-map | |
"nested map structure -> list of 'address vectors'" | |
([m] (decompose-map [] m)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(import java.awt.datatransfer.StringSelection) | |
(import java.awt.Toolkit) | |
(import java.awt.datatransfer.DataFlavor) | |
(defn to-clipboard [s] | |
(let [ | |
selection (StringSelection. s) | |
clipboard (.getSystemClipboard (Toolkit/getDefaultToolkit))] | |
(.setContents clipboard selection selection))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(import System.Windows.Forms.Clipboard) | |
(Clipboard/SetText "hi") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[excel-repl.interop :as interop]) | |
(require '[clojure.string :as str]) | |
(defn parse [s] | |
(if (string? s) (-> s (str/replace " " "") Double/Parse))) | |
(def our-data (map first (interop/get-values "Sheet2" "S1:S1000"))) | |
(def our-members (filter number? our-data)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defonce persisted-frames (atom {})) | |
(defn persist [k v] | |
(swap! persisted-frames assoc k v) | |
v) | |
(defn split-until [f s] | |
(let [[a b] (split-with #(not (f %)) s)] | |
[(concat a (take 1 b)) (rest b)])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import clojure.lang.IFn | |
import org.apache.spark.sql.Row | |
import clojure.java.api.Clojure | |
import org.apache.spark.sql.types.StructType | |
def map_clojure(df: DataFrame, source: String, schema: StructType) = { | |
var clojure_compiled: IFn = null | |
val rdd = df.map({row => | |
if (clojure_compiled == null) { | |
clojure_compiled = Clojure.`var`("clojure.core", "load-string").invoke(source).asInstanceOf[IFn] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.spark.sql.{SQLContext, DataFrame} | |
import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan | |
import org.apache.spark.sql.execution.{ExplainCommand, QueryExecution} | |
import org.apache.spark.sql.catalyst.InternalRow | |
//Sorry about the clojure, we need it to sidestep the Scala typesystem | |
import clojure.java.api.Clojure | |
import clojure.lang.IFn | |
class BetterDataFrame(override val sqlContext: SQLContext, override val logicalPlan: LogicalPlan) extends DataFrame(sqlContext, logicalPlan) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def assembly-path "C:\\Users\\cplmam\\Downloads\\microsoft.office.interop.outlook.15.0.4797.1003\\lib\\net20\\Microsoft.Office.Interop.Outlook.dll") | |
(assembly-load-from assembly-path) | |
(import Microsoft.CSharp.CSharpCodeProvider) | |
(import System.CodeDom.Compiler.CompilerParameters) | |
(def provider (CSharpCodeProvider.)) | |
(def assemblies (into-array [assembly-path])) | |
(def compilerparams (CompilerParameters. assemblies)) | |
(.set_GenerateExecutable compilerparams false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static load_string = clojure.java.api.Clojure.var('clojure.core', 'load-string') | |
private static localization = load_string.invoke(''' | |
(require '[clojure.java.io :as io]) | |
(defn cljs-resource [path] ;does this work in production? | |
(io/resource (str "META-INF/assets/taipan_reagent/src/" path))) | |
(defn needed-messages [path] | |
(distinct (map second (re-seq #"\\(messages \\"(\\w+?)\\"\\)" (slurp (cljs-resource path)))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns render.format) | |
(defn standardize [form] | |
(cond | |
(vector? form) | |
(let [[k m & rest] form] | |
(if (map? m) | |
(vec (list* k m (map standardize rest))) | |
(vec (list* k {} (standardize m) (map standardize rest))))) | |
(seq? form) |
OlderNewer