<commit_before>(ns mediakeys.core
    (:use [mediakeys.hotkeys :only [keypress-events!]]
          mediakeys.rx)
    (:require
        [clojure.data.json :as json] 
        [rx.lang.clojure.interop :as rx])
    (:import 
           [rx Observable]
           [org.webbitserver WebServer WebServers WebSocketHandler]
           [org.webbitserver.handler StaticFileHandler]))

(import [com.tulskiy.keymaster.common Provider HotKeyListener])
(import [javax.swing KeyStroke])

(def dose-keys [{:play "control 1" :forward "control 2"}
                {:back "control 4" :play "control 3"}])

(def incoming-sub (atom nil))
(def incoming-observable
    (Observable/create
        (rx/action [^rx.Subscriber s]
            (reset! incoming-sub s))))
(def incoming-json 
    (map incoming-observable 
        json/read-json))
;THIS SHOULD ACTUALLY get transformed a bunch
;before getting fed into keypress-events

(defn sub-to-keypresses [] 
    (let [changes (from-seq dose-keys)
          presses (keypress-events! changes)]
        (.subscribe presses 
            (rx/action [x]
                (println x)))))

(def keypresses (-> incoming-json  keypress-events! (.map (rx/fn* name))))

(defn -main []
  (doto (WebServers/createWebServer 8080)
    (.add "/websocket"
          (proxy [WebSocketHandler] []
            (onOpen [c]
                (println "yo opened") 
                (.subscribe keypresses
                    (rx/action [action]
                        (.send c action))))
            (onClose [c] (println "closed" c))
            (onMessage [c j] 
                (.onNext @incoming-sub j))))
    (.add (StaticFileHandler. "."))
    (.start))
  (.subscribe keypresses
      (rx/action* println)) 
  (println @incoming-sub)
  (.onNext @incoming-sub "{}"))<commit_msg>replacing other things with hotter seq functions<commit_after>(ns mediakeys.core
    (:use [mediakeys.hotkeys :only [keypress-events!]]
          mediakeys.rx)
    (:require
        [clojure.data.json :as json] 
        [rx.lang.clojure.interop :as rx])
    (:import 
           [rx Observable]
           [org.webbitserver WebServer WebServers WebSocketHandler]
           [org.webbitserver.handler StaticFileHandler]))

(import [com.tulskiy.keymaster.common Provider HotKeyListener])
(import [javax.swing KeyStroke])

(def dose-keys [{:play "control 1" :forward "control 2"}
                {:back "control 4" :play "control 3"}])

(def incoming-sub (atom nil))
(def incoming-observable
    (Observable/create
        (rx/action [^rx.Subscriber s]
            (reset! incoming-sub s))))
(def incoming-json 
    (map incoming-observable 
        json/read-json))
;THIS SHOULD ACTUALLY get transformed a bunch
;before getting fed into keypress-events

(defn sub-to-keypresses [] 
    (let [changes (from-seq dose-keys)
          presses (keypress-events! changes)]
        (sub presses println)))

(def keypresses (-> incoming-json  keypress-events! (map name)))

(defn -main []
  (doto (WebServers/createWebServer 8080)
    (.add "/websocket"
          (proxy [WebSocketHandler] []
            (onOpen [c]
                (println "yo opened") 
                (sub keypresses
                    (fn [action]
                        (.send c action))))
            (onClose [c] (println "closed" c))
            (onMessage [c j] 
                (.onNext @incoming-sub j))))
    (.add (StaticFileHandler. "."))
    (.start))
  (sub keypresses println) 
  (println @incoming-sub)
  (.onNext @incoming-sub "{}"))
{'fraction_non_alphanumeric': 0.13390557939914163, 'fraction_numerical': 0.004577968526466381, 'mean_word_length': 2.270346117867166, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '80109', 'n_tokens_mistral': 1145, 'n_tokens_neox': 1059, 'n_words': 279}