Skip to content

Instantly share code, notes, and snippets.

Matthew Molloy whamtet

Block or report user

Report or block whamtet

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View clojure-gems.clj
(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))
View clipboard.clj
(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)))
View clipboard-clr.clj
(import System.Windows.Forms.Clipboard)
(Clipboard/SetText "hi")
View check-spreadsheet.clj
(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))
View persistent.clj
(defonce persisted-frames (atom {}))
(defn persist [k v]
(swap! persisted-frames assoc k v)
(defn split-until [f s]
(let [[a b] (split-with #(not (f %)) s)]
[(concat a (take 1 b)) (rest b)]))
View MapDF.scala
import clojure.lang.IFn
import org.apache.spark.sql.Row
import org.apache.spark.sql.types.StructType
def map_clojure(df: DataFrame, source: String, schema: StructType) = {
var clojure_compiled: IFn = null
val rdd ={row =>
if (clojure_compiled == null) {
clojure_compiled = Clojure.`var`("clojure.core", "load-string").invoke(source).asInstanceOf[IFn]
View Docker GUI on
socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"
#start XQuartz with appropriate config, then
#launch docker with -e DISPLAY=IP_ADDRESS:0
View BetterDataFrame.scala
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.lang.IFn
class BetterDataFrame(override val sqlContext: SQLContext, override val logicalPlan: LogicalPlan) extends DataFrame(sqlContext, logicalPlan) {
View compile-outlook-cs.clj
(def assembly-path "C:\\Users\\cplmam\\Downloads\\\\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)
View defm.clj
(defmacro defm [symbol arglist m & rest]
`(def ~symbol (with-meta (fn ~arglist ~@rest) ~m)))
You can’t perform that action at this time.