Skip to content

Instantly share code, notes, and snippets.

I know the value and cost of nothing

Ohta Shogo athos

I know the value and cost of nothing
Block or report user

Report or block athos

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
athos / deps.edn
Last active Oct 17, 2019
Try `clojure -Sdeps '{:deps {hello-clojure {:git/url "" :sha "1c9a05106171f97f9b8e8ac8f58c7bd8dbe021f9"}}}' -m hello-clojure` on your terminal
View deps.edn
{:paths ["."]
:deps {clansi {:mvn/version "1.0.0"}}}
View tagbody.clj
(ns jise.extension.tagbody
(:require [jise.emit :as emit]
[jise.parse :as parse])
(:import [clojure.asm Label MethodVisitor Opcodes]))
(defn parse-tagbody-body [body]
(loop [body body
tag nil
block []
blocks []]
athos / defexception.clj
Created Aug 24, 2019
Another implementation of defexception using JiSE
View defexception.clj
(require '[jise.core :refer [defclass]])
(defmacro defexception [ex-name]
(defclass ~ex-name [clojure.lang.ExceptionInfo]
(defm ~ex-name [^String msg# ^clojure.lang.IPersistentMap map#]
(super msg# map#))
athos /
Last active May 30, 2019
Shibuya.lisp Lisp meetup #76 LT発表資料

Shibuya.lisp Lisp meetup #76 LT発表資料

  • LT発表資料です
  • Clojure CLIがインストールされていれば、以下で実行できます:
$ clj -Sdeps '{:deps {athos/form-and-env {:git/url "" :sha "343f21f5dc5999d9eeef3d993a31755ebd9b84a4"}}}'
athos / method_callsites.txt
Last active Dec 21, 2018
for classfile in target/classes/cljam/**/*.class; do line=$(javap -v $classfile | grep -E 'Method java/nio/(Char|Byte)Buffer.(clear|flip|limit|mark|position|reset|rewind):'); if (( ! $? )); then echo $classfile; echo $line; fi; done
View method_callsites.txt
69: invokevirtual #57 // Method java/nio/CharBuffer.flip:()Ljava/nio/CharBuffer;
220: invokevirtual #94 // Method java/nio/ByteBuffer.position:(I)Ljava/nio/ByteBuffer;
31: invokevirtual #35 // Method java/nio/ByteBuffer.clear:()Ljava/nio/ByteBuffer;
53: invokevirtual #35 // Method java/nio/ByteBuffer.clear:()Ljava/nio/ByteBuffer;
583: invokevirtual #212 // Method java/nio/CharBuffer.flip:()Ljava/nio/CharBuffer;
View pi.clj
(defn a&b [n]
(loop [n n, a (/ 1.0 (* 2 (Math/pow 3 0.5))), b (/ 1.0 3)]
(if (= n 0)
[a b]
(let [a' (/ (+ a b) 2)]
(recur (dec n) a' (Math/pow (* a' b) 0.5))))))
;; => (time (/ 1 (first (a&b 100))))
;; "Elapsed time: 0.04547 msecs"
;; 3.141592653589795
View debounce.cljs
(require '[clojure.core.async :as a]
'[kitchen-async.promise :as p]
;; cf.
(defn debounce
([c ms] (debounce (a/chan) c ms))
View repeating-decimal.clj
(ns repeating-decimal)
(defn repeating-decimal [n]
(loop [rem 1 rems #{} divs [] i 0]
(let [div (int (/ (* rem 10) n))
rem (mod (* rem 10) n)]
(if (and (not= rem 0) (contains? rems rem))
[n divs]
(when (not= rem 0)
(recur rem (conj rems rem) (conj divs div) (inc i)))))))
athos / gist:1033052
Created Jun 18, 2011
An example code to generate a class with ASM in Clojure.
View gist:1033052
(import '[clojure.asm Opcodes Type ClassWriter]
'[clojure.asm.commons Method GeneratorAdapter])
(defn make-class [name]
(let [cw (ClassWriter. ClassWriter/COMPUTE_FRAMES)
init (Method/getMethod "void <init>()")
meth (Method/getMethod "int fact(int)")]
(.visit cw Opcodes/V1_6 Opcodes/ACC_PUBLIC (.replace name \. \/) nil "java/lang/Object" nil)
(doto (GeneratorAdapter. Opcodes/ACC_PUBLIC init nil nil cw)
athos / core.clj
Last active Jan 26, 2017
「数字6桁パスワードのハッシュ値の総当たり、PHPなら約0.25秒で終わるよ( )」で、PHPに比べてClojureがやたら遅いという話だったので、Clojureのコードをいろいろいじってみた。
View core.clj
(ns six-length.core
(:require [clojure.core.reducers :as r]
[clojure.string :as s])
(:import [ MessageDigest]
[javax.xml.bind DatatypeConverter]))
(set! *warn-on-reflection* true)
(def hexdigest
(let [digester (MessageDigest/getInstance "MD5")]
You can’t perform that action at this time.