Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ongaeshi
ongaeshi / gpt-prompt-ja.txt
Created January 28, 2024 03:07
ChatGPT からRuby を実行させるプロンプト
◯◯◯ Rubyスクリプトを作成してください。
このRubyスクリプトをrubyonbrowser上で実行させたいです。
URL は https://rubyonbrowser.ongaeshi.me/
後ろにクエリ文字列 ?q2=
コードテキストを URLエンコーディングした文字列を q2 のパラメータに設定
コードと生成したURLへのリンクの順に一回で出力してください。

Note

Highlights information that users should take into account, even when skimming.

Tip

Optional information to help a user be more successful.

def make_markdown_table(list)
lines = list.split("\n")
lines.map do |line|
path = line.gsub("./", "")
url = "https://github.com/DragonRuby/dragonruby-game-toolkit-contrib/blob/main/samples/#{path}/app/main.rb"
"| [#{path}](#{url}) | | | "
end.join("\n")
end#{path}
lists = <<EOS
def get_all_folders_recursive(directory)
# ディレクトリ内の全エントリを取得
entries = Dir.entries(directory)
# フォルダのみを抽出
folders = entries.select { |entry| File.directory?(File.join(directory, entry)) && entry != '.' && entry != '..' }
# 現在のディレクトリ内のフォルダをリストに追加
result = folders.map { |folder| File.join(directory, folder) }
@ongaeshi
ongaeshi / make_tweet.rb
Created October 4, 2023 17:52
イーロンマスクの新刊が読みたい
require "ruby_openai"
require "readline"
token = File.read(File.join(__FILE__, "../.token"))
$client = OpenAI::Client.new(access_token: token)
def gpt(message, title)
response = $client.chat(
parameters: {
model: "gpt-3.5-turbo",
@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",