Skip to content

Instantly share code, notes, and snippets.

View mephistobooks's full-sized avatar
🤔
uhm...

YAMAMOTO, Masayuki mephistobooks

🤔
uhm...
View GitHub Profile
@mephistobooks
mephistobooks / test-with_async_loop_tasks.rb
Created November 25, 2022 05:09
Async::Container::Threaded test.
#
#
# * Async::Container [Getting Started](https://socketry.github.io/async-container/guides/getting-started/index.html)
# https://github.com/socketry/async-container/tree/main/examples
require 'async/container'
Console.logger.debug!
# container = Async::Container.new #ok.

bitFlyer API Error responses.

.

{"status"=>-204, "error_message"=>"Market state is closed.", "data"=>nil}

place orders.

#
#
# ==== Reference
# * Console [Getting Started](https://socketry.github.io/console/guides/getting-started/index.html)
#
require 'async'
ENV['CONSOLE_LEVEL'] ||= 'debug'
# ENV['CONSOLE_LEVEL'] ||= 'info'
@mephistobooks
mephistobooks / zsh_one_liner.md
Last active May 6, 2022 18:04
zsh one liner

zsh one liner

SLEEP=5; while [ "true" ]; do; grep -i error $(ls -tr YOUR_ROTATED_LOG_FILE_TO_OBSERVE.log*); echo "next $SLEEP sec later..."; sleep $SLEEP; done

@mephistobooks
mephistobooks / async-clock.rb
Created April 20, 2022 03:59
処理にかかったmonotonic時間を測る(async)
require 'async'
#
clk = Async::Clock.new.tap{|c| c.start! }
sleep 1.14514 # pseudo processing.
p clk.total
@mephistobooks
mephistobooks / test-async-error.rb
Created April 19, 2022 08:26
Async example, with Exception, restart reactor.
#
#
#
#
# * [async-websocket](https://github.com/socketry/async-websocket/blob/master/examples/binance/client.rb)
#
#
require 'async'
@mephistobooks
mephistobooks / async-error-202203.md
Last active April 21, 2022 06:22
Ruby async-websocket error.

Ruby async-websocketが落ちる

  • async-websocketを使ったWebSocketクライアント・プログラム
  • 2日程度稼働していると, WebSocketサーバからの切断が頻発し始める
  • 最終的には下記のようなエラーでasync自体が落ちる
  • サーバからの切断はfaye-websocketを使っても, 同様な症状がある
  • Pythonではこのような症状は起きないらしい
  • 誰か原因わかりませんか?
    • →エラーからの復帰の書き方がまずかったっぽい
  • まず, 個々のタスクで rescue する必要がある. rescue しないと, そのタスクだけ死んでその他のタスクが生きている限り・リアクターが動き続けるか, プログラム全体が落ちる.
@mephistobooks
mephistobooks / async-binance_websocket.rb
Last active April 20, 2022 04:02
Async/WebSocketの挙動を見るためにロガー機能を追加する/BinanceでbtcusdtのWebSocket受信
#! /usr/bin/env ruby
#
#
# ==== See Also
# * `../faye/faye-ohlc-plain.rb`
#
# ==== References
# * [Async](https://socketry.github.io/async/)
# * [Async Overview](https://socketry.github.io/async/source/index.html)
@mephistobooks
mephistobooks / statistics_plus.rb
Created July 13, 2021 11:52
Numo::NArray (SFloat, DFloatのために) にmoment, skew, kurtosisメソッドを追加する
#
#
#
require 'numo/narray'
module Numo
module StatisticsPlus
def sigma
@mephistobooks
mephistobooks / hanzen_kanji.json
Last active December 25, 2019 06:35
Karabiner-Elements 半角/全角・漢字キーでトグルする設定
{
"title": "半角/全角キーでIMEトグル2019",
"rules": [
{
"description": "JISキーボードの半角/全角キーをIMEのON/OFF切り替えキーに変換する2019",
"manipulators": [
{
"type": "basic",
"from": { "key_code": "grave_accent_and_tilde" },
"to": [