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
| (defrecord Closure [form env]) | |
| (defn closure? | |
| [x] | |
| (instance? Closure x)) | |
| (defn close-over | |
| [form env] | |
| (println "(close-over " form (str env ")")) | |
| (Closure. form env)) |
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
| (defmulti -exec (comp peek :control)) | |
| (defmethod -exec 'NIL | |
| [{:keys [stack env control dump] :as registers}] | |
| (-> registers | |
| (update-in [:stack] conj nil) | |
| (update-in [:control] pop))) | |
| (defmethod -exec 'LDC | |
| [{:keys [stack env control dump] :as registers}] |
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
| (defun current-font-height () | |
| (cdr (assoc :height (face-all-attributes 'default)))) | |
| (defun set-font-height! (height) | |
| (set-face-attribute 'default nil :height height)) | |
| (defun increase-font-height () | |
| (interactive) | |
| (set-font-height! (+ (current-font-height) 5))) |
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
| (defprotocol PointerTo | |
| (pointer [val])) | |
| (extend-protocol PointerTo | |
| String | |
| (pointer [s] | |
| (Pointer/pointerToCString s)) | |
| clojure.lang.Seqable | |
| (pointer [seq] |
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 server-handler [] | |
| (proxy [ChannelHandlerAdapter] [] | |
| (channelRead [^ChannelHandlerContext ctx ^ByteBuf msg] | |
| (.write ctx msg) | |
| (.flush ctx)) | |
| (exceptionCaught [^ChannelHandlerContext ctx ^Throwable cause] | |
| (.printStackTrace cause) | |
| (.close ctx)))) | |
| (defn handlers |
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
| (set! *warn-on-reflection* true) | |
| (defn server-response | |
| [packet] | |
| (Unpooled/copiedBuffer "Hello, world!" CharsetUtil/UTF_8)) | |
| (defn packet-content | |
| [^DatagramPacket packet] | |
| (str (.content packet))) |
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 server-response | |
| [^DatagramPacket packet] | |
| (let [ret (packet-content packet)] | |
| (Unpooled/copiedBuffer ret CharsetUtil/UTF_8)) ) | |
| (defn server-handler [] | |
| (proxy [SimpleChannelInboundHandler] [] | |
| (messageReceived [^ChannelHandlerContext ctx ^DatagramPacket packet] | |
| (let [content (packet-content packet) | |
| res (DatagramPacket. (server-response packet) (.sender packet))] |
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 ^String packet-content | |
| [^DatagramPacket packet] | |
| (.toString ^DefaultAddressedEnvelope (.content packet) CharsetUtil/UTF_8)) | |
| (defn protocol-multiplexer-channel-initializer | |
| [] | |
| (proxy [ChannelInitializer] [] | |
| (initChannel [^SocketChannel ch] | |
| (-> (.pipeline ch) | |
| )))) |
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 parse-header | |
| [archive] | |
| (zipmap [:file-id | |
| :version | |
| :total-records | |
| :records-offset | |
| :records-compression-level | |
| :records-deflated-size | |
| :names-compression-level | |
| :names-deflated-size |
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
| (let [flt (with-precision 6 (/ (bigdec n) 1))] | |
| (if (> (.scale flt) 6) | |
| (str (.setScale flt 6 java.math.RoundingMode/UP)) | |
| (str flt))) |