Skip to content

Instantly share code, notes, and snippets.

@ongaeshi
ongaeshi / errorlog.txt
Last active March 21, 2023 15:39
ruby.wasm build Error log: rake build:head-wasm32-unknown-wasi-full-js
tool/config.guess already exists
tool/config.sub already exists
checking build system type... x86_64-pc-linux-gnu
checking host system type... wasm32-unknown-wasi
checking target system type... wasm32-unknown-wasi
checking for wasm32-wasi-wasm-opt... /home/ongaeshi/WslCode/ruby.wasm/build/toolchain/binaryen/bin/wasm-opt
checking wheather $WASI_SDK_PATH is set... no
configure: error: WASI_SDK_PATH environment variable is required
make: *** No rule to make target 'rbconfig.rb'. Stop.
creating Makefile
@ongaeshi
ongaeshi / errorlog.txt
Created March 1, 2023 17:45
ruby.wasm error "Uncaught RuntimeError: unreachable executed"
Uncaught RuntimeError: unreachable executed
rbFuncallvProtect https://cdn.jsdelivr.net/npm/ruby-3_2-wasm-wasi@next/dist/browser.script.iife.js:3540
callRbMethod https://cdn.jsdelivr.net/npm/ruby-3_2-wasm-wasi@next/dist/browser.script.iife.js:4378
wrapRbOperation https://cdn.jsdelivr.net/npm/ruby-3_2-wasm-wasi@next/dist/browser.script.iife.js:4356
callRbMethod https://cdn.jsdelivr.net/npm/ruby-3_2-wasm-wasi@next/dist/browser.script.iife.js:4377
call https://cdn.jsdelivr.net/npm/ruby-3_2-wasm-wasi@next/dist/browser.script.iife.js:4234
procToJsFunction https://cdn.jsdelivr.net/npm/ruby-3_2-wasm-wasi@next/dist/browser.script.iife.js:4008
redraw https://cdn.jsdelivr.net/npm/p5@1.5.0/lib/p5.js:68314
_draw https://cdn.jsdelivr.net/npm/p5@1.5.0/lib/p5.js:60836
_draw https://cdn.jsdelivr.net/npm/p5@1.5.0/lib/p5.js:60854
# https://twitter.com/lisasekaida/status/1629291753261117441
$s=600
def setup
createCanvas($s,$s,WEBGL)
noStroke
end
$a=0
graph

1 --> 2 --> 3 --> 4

1(1. u32のソート)
2(2. ジェネリクス対応)
3(3. クロージャによるソート順のカスタマイズ)
4(4. 並列ソートの実現)
# https://ongaeshi.github.io/rubyonbrowser/ でPC実行すると1ループ約1秒位だった
(1..10).map do
(1..10000000).each {}
Time.now
end.join("\n")
DATA = <<EOS
<html>
<head>
<meta charset="utf-8"/>
</head>
<script src="https://cdn.jsdelivr.net/npm/ruby-head-wasm-wasi@0.2.0/dist/browser.umd.js"></script>
<script>
const { DefaultRubyVM } = window["ruby-wasm-wasi"];
const main = async () => {
// Fetch and instntiate WebAssembly binary
$ git clone https://github.com/kateinoigakukun/ruby.wasm.git
$ cd ruby.wasm/packages/npm-packages/ruby-wasm-wasi/
$ npm install
$ npm install --save ruby-head-wasm-wasi
# Need this?
$ cp -r node_modules/ruby-head-wasm-wasi/dist/ .
$ cd example

Ruby+VSCode+Windowsで必要最低限の開発環境を整える

基本方針

  • Ruby2.7
    • Ruby3自体は安定しているがgem周りの挙動が若干安定していなかった
  • VSCodeから使える機能
    • Linter (standard)
    • Formatter (rufo, Shift+Alt+F9)
    • Debugger (debase, ruby-debug-ide)
  • コマンドラインから使える機能
  • standardrb --fixで自動修正
# SceneClipの例
script do |root|
draw_background
# Scene1
root.scene_script do |scene|
# SceneClipが生成される(scene)
t = scene.text(10, 10)
@ongaeshi
ongaeshi / gist:62830ebd70f88a9d58ec6f8a7e200f26
Created January 25, 2021 08:13
add_to_scrapbox_page.js
PROJECT = "name";
title = "title"
url = "sbporter://scrapbox.io/"+PROJECT+"/"+encodeURIComponent(title)+"?body="+encodeURIComponent(T.lines());
T(url,{option:"cutWhole"});