Skip to content

Instantly share code, notes, and snippets.

View ryoakg's full-sized avatar

℟γồ ᾅḳᐃϼ╿ ryoakg

View GitHub Profile
;; https://k11i.biz/blog/2016/12/05/fastest-gaussian-rng-in-java/
(boot.core/merge-env! :repositories
[["bintray-komiya-atsushi-maven" {:url "https://dl.bintray.com/komiya-atsushi/maven"}]]
:dependencies
'[[biz.k11i/fast-rng "0.2.0"]])
(import java.util.Random)
;; https://en.wikipedia.org/wiki/Normal_distribution
(let [r (Random.)]
@ryoakg
ryoakg / script-async-defer.php
Created January 7, 2020 09:51
結論 PHP の built in web server は シングルスレッドなので上手く評価できない
<?php
// 結論 PHP の built in web server は シングルスレッドなので上手く評価できない
if (PHP_SAPI === 'cli') {
echo <<<EOU
Usage:
run: php -S localhost:8080 {$argv[0]}
browse http://localhost:8080/
EOU;
exit;
<?php
if (PHP_SAPI === 'cli') {
echo <<<EOU
This is something like a http://stevesouders.com/hpws/sleep.txt
Usage:
run: php -S localhost:8080 {$argv[0]}
browse http://localhost:8080/
NOTICE:
<?php
if (PHP_SAPI === 'cli') {
echo <<<EOS
Usage:
run: php -S localhost:8080 {$argv[0]}
browse http://localhost:8080/
EOS;
exit;
}
(import (java.util.logging LogRecord Logger Formatter SimpleFormatter StreamHandler)
(java.awt Image Color Dimension Insets Graphics)
(java.awt.image ImageObserver)
(javax.swing UIManager UnsupportedLookAndFeelException
BorderFactory
JComponent
JFrame JPanel Box JDialog
JScrollPane JScrollBar
JFileChooser
JLabel JTextField JPasswordField JTextArea
(boot.core/set-env! :dependencies '[[io.github.bonigarcia/webdrivermanager "3.7.1"]
;; https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager
])
(System/getProperty "webdriver.chrome.driver")
;; => "/bin/chromedriver"
(.setup (io.github.bonigarcia.wdm.WebDriverManager/chromedriver))
(System/getProperty "webdriver.chrome.driver")
@ryoakg
ryoakg / swing-grid-layout.clj
Created December 24, 2019 06:15
GRIDの大きさは全部同じみたい
(import (javax.swing JFrame JLabel)
(java.awt GridLayout))
(defn- rand-str [len]
(apply str (take len (repeatedly #(char (+ (rand 26) 65))))))
(let [n-rows 10
n-cols 3
frame (doto (JFrame. "GRIDの大きさは全部同じみたい")
(.setDefaultCloseOperation JFrame/DISPOSE_ON_CLOSE))]
(->> (java.lang.management.ManagementFactory/getRuntimeMXBean)
.getSystemProperties
(into {}))
(= (->> (java.lang.management.ManagementFactory/getRuntimeMXBean)
.getSystemProperties
(into {})
keys sort)
(->> (System/getProperties)
(into {})
(let [f #(-> (System/getProperty "os.name")
.toLowerCase
(.startsWith %))]
(def linux? #(f "linux"))
(def windows? #(f "windows"))
(def mac? #(f "mac")))
(boot.core/set-env! :dependencies '[[org.jasypt/jasypt "1.9.3"]])
;;; https://www.codeflow.site/ja/article/jasypt
(import (org.jasypt.util.text BasicTextEncryptor))
(let [pass "foo"
msg "今日は晴れです。"
encryptor (doto (BasicTextEncryptor.)
(.setPassword pass))