This file contains hidden or 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 workspace global.atom.workspace) | |
(def commands global.atom.commands) | |
(def views global.atom.views) | |
(defn get-editor [] (.getActiveTextEditor workspace)) | |
(defn get-editor-view [] (.getView views (get-editor))) | |
(defn get-cursor [] (.getLastCursor (get-editor))) | |
(defn get-cursors [] (.getCursors (get-editor))) | |
(defn add-command [name & fs] |
This file contains hidden or 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
(.log js/console global.atom) | |
(.log js/console global.atom.commands) | |
(.. global.atom.commands | |
(add "atom-text-editor" "cljs:sample-linefirst" | |
#(.. global.atom.workspace | |
getActiveTextEditor | |
getLastCursor | |
moveToFirstCharacterOfLine))) | |
This file contains hidden or 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-frame :Ipv4Frame | |
:Ipv4Header :header | |
"IcmpFrame:(= Protocol 1)" :icmp | |
"TcpFrame:(= Protocol 6)" :tcp | |
"bytes:(if (not-any? #(= Protocol %) [1 6]) (- incl_len 14 (* 4 IHL)) false)" :unknown) | |
(def-frame :ArpFrame | |
:uint16 :HTYPE | |
:uint16 :PTYPE | |
:uint8 :HLEN |
This file contains hidden or 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
(defn delete-to-bracket [cm command] | |
(.setExtending cm true) | |
(cmd/exec! command) | |
(.replaceSelection cm "") | |
(.setExtending cm false)) | |
(cmd/command {:command :user.delete-to-bracket | |
:desc "User: Delete to bracket" | |
:exec #(delete-to-bracket (get-cm) :editor.sublime.goToBracket)}) |
This file contains hidden or 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 << bit-shift-left) | |
(def >> bit-shift-right) | |
(defn unsigned [^bytes bytea] | |
{:pre [(<= 1 (alength bytea) 7)]} | |
(areduce bytea i ret 0 | |
(bit-or (<< ret 8) (bit-and 0xff (aget bytea i))))) | |
(defn signed [^bytes bytea] | |
{:pre [(<= 1 (alength bytea) 8)]} |
This file contains hidden or 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 v (volatile! {:a 1})) | |
(vswap! v assoc :b 2) | |
(vreset! v {:c 3}) |
This file contains hidden or 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 robot.sample | |
(:import [java.awt Robot] | |
[java.awt.event KeyEvent] | |
[javax.swing KeyStroke])) | |
(defn static-fields [^Class class fields] | |
(map #(load-string (str (.getName class) "/" %)) fields)) | |
(defn modifiers->vks [modifiers] | |
(->> (map #(when (pos? (bit-and modifiers %1)) %2) |
This file contains hidden or 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 hotkey.sample | |
(:import [com.tulskiy.keymaster.common Provider HotKeyListener] | |
[javax.swing KeyStroke])) | |
(def provider (atom nil)) | |
(defn- get-arity [f] | |
(let [^java.lang.reflect.Method m (-> f class .getDeclaredMethods first)] | |
(count (.getParameterTypes m)))) |
This file contains hidden or 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
(defn third [coll] (second (next coll))) |
This file contains hidden or 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 use-clipboard.core | |
(:import [java.awt Toolkit] | |
[java.awt.datatransfer Clipboard DataFlavor StringSelection])) | |
(def ^Clipboard clip (.getSystemClipboard (Toolkit/getDefaultToolkit))) | |
(defn get-string [] | |
(when (.isDataFlavorAvailable clip DataFlavor/stringFlavor) | |
(.getData clip DataFlavor/stringFlavor))) |