This file contains 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
[1] (pry) main: 0> require './prytime' | |
=> true | |
[2] (pry) main: 0> def a | |
[2] (pry) main: 0* x = :circky | |
[2] (pry) main: 0* y = :ryanie | |
[2] (pry) main: 0* b() | |
[2] (pry) main: 0* end; | |
[3] (pry) main: 0> def b | |
[3] (pry) main: 0* z = :fowlie | |
[3] (pry) main: 0* y = :mon_french_guy |
This file contains 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
If you set LD_PRELOAD to the path of a shared object, that file will be loaded before any other library (including the C runtime, libc.so). So to run ls with a your special malloc() implementation, do this: | |
$ LD_PRELOAD=/path/to/my/malloc.so /bin/ls |
This file contains 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
require 'io/console' | |
class Coolline | |
# Creates a new cool line | |
# @param [IO] input Input to read from. This has to be an actual IO object. | |
# @param [IO] output Output. This can be an object of any kind. | |
# | |
# @yield after each character entered | |
# @yieldparam [String] line | |
# @yieldreturn [String] string to print for this input |
This file contains 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
ls | |
Tweak display of methods with: | |
-m show only public methods | |
-p show public/protected/private methods (i.e. -p implies -m) | |
-M show only public instance methods |
This file contains 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
Changing current directory with `posix_spawnp` | |
```ruby | |
posix_spawn('sh -c "cd blah ; ls') | |
``` |
This file contains 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
method(:foo).to_java.source_location(Thread.current.to_java.getContext()) |
This file contains 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
pry(main)> def hello(friends) | |
pry(main)* puts "my friends i have come here to say hello" | |
pry(main)* puts "hello is an unusual word, but is appropriate at a time like this" | |
pry(main)* puts "when it has been so long since we last met" | |
pry(main)* puts "before the dogs were put to sleep" | |
pry(main)* s/hello/goodbye | |
1: def goodbye(friends) | |
2: puts "my friends i have come here to say goodbye" | |
3: puts "goodbye is an unusual word, but is appropriate at a time like this" | |
4: puts "when it has been so long since we last met" |
This file contains 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
require 'pry' | |
require 'drb' | |
DRb.start_service | |
client = DRbObject.new nil, ARGV[0] | |
# Dummy proxy, DRb won't allow us to pass Readline directly. | |
Proxy = Object.new |
This file contains 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
pry(main)> blame Pry#repl | |
John Mair def repl(target=TOPLEVEL_BINDING) | |
John Mair target = Pry.binding_for(target) | |
John Mair target_self = target.eval('self') | |
John Mair | |
John Mair repl_prologue(target) | |
Mon ouïe | |
John Mair # cannot rely on nesting.level as | |
John Mair # nesting.level changes with new sessions | |
John Mair nesting_level = nesting.size |
This file contains 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
int main(int argc, char *argv[]) { | |
TestDefaultFormatter formatter; | |
use_formatter(formatter); | |
describe("Test", []{ | |
it("1 == 1", []{ assert(1).equals(1); }); | |
it("2 == 1", []{ assert(2).equals(1); }); | |
describe("with strings", []{ | |
it("std::string == char*", []{ assert_equals(std::string("a"), "a"); }); |