Skip to content

Instantly share code, notes, and snippets.

View README.md

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

基本方針

  • Ruby2.7
    • Ruby3自体は安定しているがgem周りの挙動が若干安定していなかった
  • VSCodeから使える機能
    • Linter (standard)
    • Formatter (rufo, Shift+Alt+F9)
    • Debugger (debase, ruby-debug-ide)
  • コマンドラインから使える機能
    • standardrb --fixで自動修正
View script_with_scene.rb
# SceneClipの例
script do |root|
draw_background
# Scene1
root.scene_script do |scene|
# SceneClipが生成される(scene)
t = scene.text(10, 10)
View gist:62830ebd70f88a9d58ec6f8a7e200f26
PROJECT = "name";
title = "title"
url = "sbporter://scrapbox.io/"+PROJECT+"/"+encodeURIComponent(title)+"?body="+encodeURIComponent(T.lines());
T(url,{option:"cutWhole"});
View add_link_to_textwell.js
View textwell_make_sceapbox_link.js
View scrapbox_header_textwell.js
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});
@ongaeshi
ongaeshi / using_irb_as_a_programmable_calculator.md
Last active Jan 12, 2021
irbをプログラマブル電卓として使いこなす
View using_irb_as_a_programmable_calculator.md

irbをプログラマブル電卓として使いこなす

基本設定

  • .irbrcに設定する
  • ヒストリと補完は必ず動くようにする(複数行編集とかもできるようになるのでRuby 2.7以降がおすすめ)
require 'irb/ext/save-history'
require 'irb/completion'
require 'caseninja'
require 'open-uri'
View get_recent_tracks.rb
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'
View VideoPlayerOnSiv3D.cpp
# include <Siv3D.hpp>
// アニメーション描画用のクラス
struct AnimationTexture
{
Array<Texture> textures;
// フレームの時間
Array<int32> delays;
@ongaeshi
ongaeshi / gist:e1feb30f0a9701ab5183b2d4e55ddd1c
Last active Dec 14, 2020
bundle exec steep langserver がWindows上で失敗する
View gist:e1feb30f0a9701ab5183b2d4e55ddd1c
PS C:\Users\ongaeshi\Documents\ruby3-test> bundle exec steep langserver
#<ArgumentError: wrong exec option symbol: pgroup>
C:/Ruby30-x64/lib/ruby/3.0.0/open3.rb:221:in `spawn'
C:/Ruby30-x64/lib/ruby/3.0.0/open3.rb:221:in `popen_run'
C:/Ruby30-x64/lib/ruby/3.0.0/open3.rb:160:in `popen2'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/steep-0.38.0/lib/steep/server/worker_process.rb:32:in `spawn_worker'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/steep-0.38.0/lib/steep/drivers/langserver.rb:43:in `run'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/steep-0.38.0/lib/steep/cli.rb:153:in `process_langserver'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/steep-0.38.0/lib/steep/cli.rb:50:in `run'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/steep-0.38.0/exe/steep:11:in `<top (required)>'