This file contains hidden or 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
direc = File.dirname(__FILE__) | |
require "#{direc}/local_eval/version" | |
require 'remix' | |
require 'object2module' | |
module LocalEval | |
module ObjectExtensions | |
@@m = Mutex.new | |
def local_eval(*objs, &block) |
This file contains hidden or 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
#include <stddef.h> | |
#include <stdio.h> | |
typedef struct mystruct { | |
int x, y; | |
double f; | |
char * hello; | |
} mystruct; | |
void |
This file contains hidden or 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 'yard' | |
class Method | |
def docstring | |
@yard_cache ||= {} | |
file = source_location[0] | |
unless @yard_cache[file] | |
YARD.parse(file) | |
@yard_cache[file] = true | |
end |
This file contains hidden or 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
class Hello; end | |
Hello.singleton_class.class #=> Class | |
# So methods on Hello.singleton_class should be first looked up as instance methods on Class right? | |
class Class | |
def hello | |
puts "from Class" | |
end |
This file contains hidden or 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
# I want this method in ruby-core | |
def let | |
yield | |
end | |
def fib(i) | |
let do |n = 1, result = 0| | |
if i == -1 | |
result | |
else |
This file contains hidden or 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
# Ruby edge cases | |
# lambdas can no longer be used with instance_eval in Ruby 1.9.2 | |
l = lambda { puts "hello world"! } | |
Object.instance_eval(&l) #=> invalid argument. This is due to the fact instance_eval now yields a value (the receiver) in 1.9 | |
# module double inclusion | |
# module appear multiple times in inheritance chain | |
# behaviour of constants in class_eval | |
# Proc.new can create a proc from an implicit block |
This file contains hidden or 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)> class SupBurg | |
pry(main)* def yo | |
pry(main)* puts 'swede' | |
pry(main)* end | |
pry(main)* end | |
=> nil | |
pry(main)> hist | |
0: class SupBurg | |
1: def yo | |
2: puts 'swede' |
This file contains hidden or 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
# Add this to the end of your development.rb and add | |
# | |
# gem 'pry' | |
# | |
# to your Gemfile and run bundle to install. | |
silence_warnings do | |
begin | |
require 'pry' | |
IRB = Pry |
This file contains hidden or 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
module Helpers | |
def use_a_helper | |
puts "test" | |
end | |
end | |
class Pry::CommandContext | |
include Helpers | |
end |
This file contains hidden or 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::Helpers::Color: | |
** bold | |
** colorize | |
** blue | |
** bright_black | |
** brigt_cyan | |
** bright_green | |
** brigt_magenta | |
** bright_purple | |
** bright_red |