Skip to content

Instantly share code, notes, and snippets.

@ongaeshi
ongaeshi / console.txt
Last active October 4, 2023 17:39
概要から色々なパターンのツイートを生成する
PS C:\Users\ongaeshi\Code\runa_app\ruby_openai> runa run .\make_tweet.rb "shi3z 氏が紹介していた Chat-GPT のやつを Ruby でもやってみた"
--- バズる優先 ---
「Ruby界の先駆者、shi3z氏が紹介する『Chat-GPT』をRubyでも試してみました!✨💎 プログラミングの魔術師たちよ、この新たな力を手に入れたのだ!🔮💬 #Ruby #ChatGPT #プログラミング魔術師」というツイート文がバズるかもしれません!
--- 落ち着き優先 ---
「Chat-GPTの素晴らしさに感動して、私もRubyで試してみました。とても面白くて使いやすいで す!shi3zさんの紹介に感謝です」という感謝と興奮が伝わる落ち着いたツイート文です。
--- 技術者優先 ---
「Chat-GPT is an amazing language model that shi3z san introduced! I couldn't resist trying it out in Ruby, and the results blew me away! The potential for natural language processing in Ruby just got a major boost. Can't wait to explore more applications with this powerful tool! #ChatGPT #Ruby #AI #NaturalLanguageProcessing」
--- テクニカルライター ---
「【テクニカルライター】Chat-GPTをRubyで試してみました!shi3z氏の紹介記事を参考にしながら、実装を進めました。Rubyならではの特徴を活かしたコーディング手法を取り入れた結果、シ ームレスなチャット体験が可能になりました。興味がある方はぜひご覧ください!#ChatGPT #Ruby #テクニカルライティング」
--- インフルエンサー ---
@ongaeshi
ongaeshi / console.txt
Last active October 4, 2023 17:39
「ruby について本を書こうと思う」という質問をGPTに投げた結果
PS C:\Users\ongaeshi\Code\runa_app\ruby_openai> runa run .\question.rb
---
Title: Mastering Ruby: Unlocking the Power of a Dynamic Programming Language
Table of Contents:
1. Introduction to Ruby
- Overview of Ruby's history and philosophy
- Setting up a Ruby development environment
- Basic syntax and data types in Ruby
scala> def largerThan(n: Int)(i: Int): Boolean = i > n
def largerThan(n: Int)(i: Int): Boolean
scala> largerThan(4)
val res1: Int => Boolean = Lambda$6155/0x000001919e039400@372eb77
scala> largerThan(4)(5)
val res2: Boolean = true
scala> List(5,1,2,4,0).filter(largerThan(4))
# 一度 uninstall してから install するとうまくいった。
C:/Ruby32-x64/lib/ruby/3.2.0/rubygems.rb:263:in `find_spec_for_exe': can't find gem runa (>= 0.a) with executable runa (Gem::GemNotFoundException)
from C:/Ruby32-x64/lib/ruby/3.2.0/rubygems.rb:282:in `activate_bin_path'
from C:/Ruby32-x64/bin/runa:32:in `<main>'
PS C:\Users\ongaeshi\Code\tmp\ruby2d_test> gem uninstall runa
Successfully uninstalled runa-0.1.0
PS C:\Users\ongaeshi\Code\tmp\ruby2d_test> gem install runa
Fetching runa-0.1.0.gem
Successfully installed runa-0.1.0
```
irb(main):002:0> $LOAD_PATH
=>
["C:/Users/ongaeshi/Code/rurema/vendor/bundle/ruby/3.2.0/gems/thor-1.2.2/lib",
"C:/Users/ongaeshi/Code/rurema/vendor/bundle/ruby/3.2.0/bundler/gems/ruremai-a7c249c92623/lib",
"C:/Users/ongaeshi/Code/rurema/vendor/bundle/ruby/3.2.0/gems/launchy-2.5.2/lib",
"C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/lib",
"C:/Users/ongaeshi/Code/rurema/vendor/bundle/ruby/3.2.0/gems/addressable-2.8.4/lib",
"C:/Users/ongaeshi/Code/rurema/vendor/bundle/ruby/3.2.0/gems/public_suffix-5.0.1/lib",
"C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0",
@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")