pry

【在 Nervos CKB 上做开发】Nervos CKB 脚本编程简介[5]:调试 debug

孤街醉人 提交于 2019-12-08 17:12:38
作者:Xuejie 原文链接: https://xuejie.space/2019_10_18_introduction_to_ckb_script_programming_debugging/ Nervos CKB 脚本编程简介[5]:调试 debug 事实上,CKB 脚本工作的层级要比其他智能合约低很多,因此 CKB 的调试过程就显得相当神秘。在本文中,我们将展示如何调试 CKB 脚本。你会发现,其实调试 CKB 脚本和你日常调试程序并没有太大区别。 本文建立在 ckb v0.23.0 之上。具体的,我在每个项目中使用的是如下版本的 commit: ckb: 7e2ad2d9ed6718360587f3762163229eccd2cf10 ckb-sdk-ruby: 18a89d8c69e173ad59ce3e3b3bf79b5d11c5f8f8 ckb-duktape:347bf730c08eb0aab7e56e0357945a4d6cee109a ckb-standalone-debugger: 2379e89ae285e4e639b961756c22d8e4fde4d6ab 使用 GDB 调试 C 程序 CKB 脚本调试的第一种方案,通常适用于 C、Rust 等编程语言。也许你已经习惯了写 C 的程序,而 GDB 也是你的好搭档。你想知道是不是可以用 GDB 来调试 C

GC.start has no effect in Pry, but does in IRB

拟墨画扇 提交于 2019-12-08 09:37:09
问题 I was playing with garbage collection in Pry, and noticed that for some reason it doesn't seem to work. I was trying different ways to set my big array as nil , etc, while breaking my head on the question "why in the world I simply cannot deallocate the freaking memory with GC.start ?" Then I went to IRB and suddenly it worked! I'm wondering what could cause this, and if you didn't know the answer but found it, I'd also like to know how. My simple code (I'm on 1.9.3-p327, and beware, this

How to step through a loop with pry and view the value of an iterator?

自古美人都是妖i 提交于 2019-12-08 05:43:37
问题 I inserted binding.pry into my Ruby program and am trying to view the value of an iterator at each iteration of my loop: require 'pry' def longest_palindrome s max_palindrome_len = 0 for i in (0..s.length) binding.pry for j in (i..s.length) binding.pry substr = s[i..j] if substr == substr.reverse && substr.length > max_palindrome_len max_palindrome_len = substr.length end end end return max_palindrome_len end longest_palindrome "racer" I want to view the values for i and j at each iteration

【在 Nervos CKB 上做开发】Nervos CKB 脚本编程简介[3]:自定义代币

眉间皱痕 提交于 2019-12-07 22:41:22
原文作者:Xuejie 原文链接: https://xuejie.space/2019_09_06_introduction_to_ckb_script_programming_udt/ Nervos CKB 脚本编程简介[3]:自定义代币 CKB 的 Cell 模型和 VM 支持许多新的用例。然而,这并不意味着我们需要抛弃现有的一切。如今区块链中的一个常见用途是 Token 发行者发布具有特殊目的/意义的新 Token。在以太坊中,我们称之为 ERC20 Token,下面让我们看看我们如何在 CKB 中构建类似的概念。为了与 ERC20 区分,在 CKB中的 Token 我们称之为 user defined token,简称 UDT。 本文使用 CKB v0.20.0 版本来演示。具体来说,我会在每个项目中使用以下提交的版本: ckb: 472252ac5333b2b19ea3ec50d54e68b627bf6ac5 ckb-duktape: 55849c20b43a212120e0df7ad5d64b2c70ea51ac ckb-sdk-ruby: 1c2a3c3f925e47e421f9e3c07164ececf3b6b9f6 数据模型 以太坊会为每个合约账户提供单独的存储空间,CKB 与之不同,CKB 是在多个 Cell 之间传递数据。Cell 的 Lock Sript 和

Why won't Pry run in Heroku's console?

大憨熊 提交于 2019-12-07 02:48:18
问题 My goal is to use Pry as the console for my Rails app, both locally and on my staging server. But I can't get it to work on Heroku. I'm following these instructions to get Heroku to use Pry as the console for my Rails app. When I run heroku run console pry , my console prints Running console pry attached to terminal... up, run.1 and then exits. When I run heroku console pry it just says main and then exits. Any ideas on what I'm doing wrong? Here's what I've done so far: In my Gemfile I've

Make Byebug finish executing without exiting Pry

佐手、 提交于 2019-12-06 18:15:21
问题 When I set a breakpoint with Byebug in Rails, I sometimes want it to finish executing, but the guide on github says to use exit which also exits Pry. Typing continue repeatedly can be annoying if the breakpoint is in a loop. Is there anyway to stop byebug without exiting the Rails console? 回答1: When running byebug under the Rails console or in Rails' server I usually quit only byebug by hitting Ctrl + D . The catch with this approach is, if you do this in Rails' server then Byebug will not

Puma Rails 5 binding.pry only available for 60 seconds before timeout

。_饼干妹妹 提交于 2019-12-06 18:09:39
问题 Puma times out my request when I'm using binding.pry . In my controller def new require 'pry' binding.pry end I then make a request that hits the controller and enter the pry session. After 60 seconds Puma? times out my request, restarts a worker and subsequently blows up by debugging session. [1] pry(#<Agent::ClientsController>)> [3522] ! Terminating timed out worker: 3566 [3522] - Worker 0 (pid: 4171) booted, phase: 0 I generated this app with suspenders if that matters. How do I extend my

Does Ruby use $stdout for writing the output of puts and return?

别来无恙 提交于 2019-12-06 03:08:33
问题 I want to know the output stream being used by Ruby to print these things at the command-line: irb(main):001:0> a="test" => "test" irb(main):002:0> puts a test => nil irb(main):003:0> a => "test" Is $stdout used for irb(main):002:0> and irb(main):003:0> ? And, is there any change in the value of $stdout between those two invocations? Also, can some one point me to the Ruby source from where these things get printed/written? 回答1: Yes. And it's easy to test/prove to yourself. Try this at the

How to add “pry” when developing a Ruby gem

不羁的心 提交于 2019-12-05 06:10:38
I have a gem called "something". I would like to add pry as a development dependency when developing the gem. However I don't know how to load it. If I have "require something" inside lib/something.rb , when I release the gem, it throws a LoadError, because pry is only a development dependency. At the same time I don't want to keep adding and removing pry when I am committing code. What is the best way to require pry only when developing the application, but not require it as a dependency for the gem? You can use the add_development_dependency in the gemspec file. You'll still have to require

Why won't Pry run in Heroku's console?

蓝咒 提交于 2019-12-05 05:10:00
My goal is to use Pry as the console for my Rails app, both locally and on my staging server. But I can't get it to work on Heroku. I'm following these instructions to get Heroku to use Pry as the console for my Rails app. When I run heroku run console pry , my console prints Running console pry attached to terminal... up, run.1 and then exits. When I run heroku console pry it just says main and then exits. Any ideas on what I'm doing wrong? Here's what I've done so far: In my Gemfile I've added the lines: gem 'pry' gem 'pry-rails' I've created a file called pry which contains: #!/usr/bin/env