- Ruby2.7
- Ruby3自体は安定しているがgem周りの挙動が若干安定していなかった
- VSCodeから使える機能
- Linter (standard)
- Formatter (rufo, Shift+Alt+F9)
- Debugger (debase, ruby-debug-ide)
- コマンドラインから使える機能
standardrb --fixで自動修正
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
| $ 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 |
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
| # SceneClipの例 | |
| script do |root| | |
| draw_background | |
| # Scene1 | |
| root.scene_script do |scene| | |
| # SceneClipが生成される(scene) | |
| t = scene.text(10, 10) |
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
| PROJECT = "name"; | |
| title = "title" | |
| url = "sbporter://scrapbox.io/"+PROJECT+"/"+encodeURIComponent(title)+"?body="+encodeURIComponent(T.lines()); | |
| T(url,{option:"cutWhole"}); |
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
| // add | |
| location.href="textwell:///add?text="+encodeURIComponent("["+document.title+" "+location.href+"]") | |
| // insert | |
| location.href="textwell:///insert?text="+encodeURIComponent("["+document.title+" "+location.href+"]") |
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
| c = T.current; | |
| if(c){ | |
| s = "[" + c + "]" | |
| if(T.range.len){ | |
| T("replaceRange", {text:s, | |
| replacingRange:{ loc:T.range.loc, len:c.length }, | |
| selectingRange:{ loc:T.range.loc, len:s.length } | |
| } ); | |
| }else{ | |
| T("replaceCurrent",{text:s}); |
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
| c = T.current; | |
| if(c){ | |
| s = "[*** " + c + "]" | |
| if(T.range.len){ | |
| T("replaceRange", {text:s, | |
| replacingRange:{ loc:T.range.loc, len:c.length }, | |
| selectingRange:{ loc:T.range.loc, len:s.length } | |
| } ); | |
| }else{ | |
| T("replaceCurrent",{text:s}); |
- .irbrcに設定する
- ヒストリと補完は必ず動くようにする(複数行編集とかもできるようになるのでRuby 2.7以降がおすすめ)
require 'irb/ext/save-history'
require 'irb/completion'
require 'caseninja'
require 'open-uri'
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
| def get_recent_tracks(token) | |
| URI.open("https://api.spotify.com/v1/me/player/recently-played", "Authorization" => "Bearer #{token}") do |f| | |
| JSON.load(f.read)["items"].map do |e| | |
| e = e["track"] | |
| "#{e["name"]} - #{e["artists"][0]["name"]}" | |
| end | |
| end | |
| end | |
| TOKEN = 'XXXXXXXXXX' |
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
| # include <Siv3D.hpp> | |
| // アニメーション描画用のクラス | |
| struct AnimationTexture | |
| { | |
| Array<Texture> textures; | |
| // フレームの時間 | |
| Array<int32> delays; | |