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 analyze.spit-sheets) | |
(import com.google.api.services.sheets.v4.SheetsScopes) | |
(require 'google-apps-clj.credentials) | |
(require '[google-apps-clj.google-sheets-v4 :as gs4]) | |
(def scopes [SheetsScopes/DRIVE SheetsScopes/SPREADSHEETS]) | |
(def creds (google-apps-clj.credentials/default-credential scopes)) | |
;(println (gd/list-files! creds "0BxDSmBQ-JH6xLTZ5R3psbkUzNEE")) | |
(def service (gs4/build-service creds)) |
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
;compile "ring:ring-core:1.5.0" | |
;compile "ring:ring-servlet:1.5.0" | |
;compile "ring:ring-defaults:0.2.1" | |
;compile "org.clojure:tools.nrepl:0.2.12" | |
;compile "org.clojure:clojure:1.8.0" | |
(require '[ring.util.servlet :as servlet]) | |
(defn merge-servlet-keys [request-map servlet-context request response] | |
(merge request-map |
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) |
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
(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
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
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
(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
(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
(import System.Windows.Forms.Clipboard) | |
(Clipboard/SetText "hi") |