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
modules = ObjectSpace.each_object(Module).reject { |m| m.is_a? Class } | |
p modules.map { |m| m.to_s } | |
p modules.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
module Hobby | |
class Test | |
class Report | |
def initialize exchanges | |
@exchanges = exchanges | |
end | |
def ok? | |
@exchanges.all? &:passed? | |
end |
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
module Hobby | |
class Test | |
class Report | |
def initialize(exchanges) | |
@exchanges = self | |
end | |
end | |
end | |
end |
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
- rspec:0:./spec/http_spec.rb:8/Hobby::JSON #<Hobby::Test:0x00000002f60818> works | |
[0/1897] | |
evil:Hobby::JSON.included:/home/ch1c0t/sources/ruby/hobby-json/lib/hobby/json.rb:6:581f7 | |
@@ -1,5 +1,5 @@ | |
-def self.included(app) | |
+def self.included | |
app.use(Rack::ContentType, "application/json") | |
app.response = Response | |
end | |
----------------------- |
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
- rspec:0:./spec/http_spec.rb:8/Hobby::JSON #<Hobby::Test:0x00000003018e40> works | |
evil:Hobby::JSON.included:/home/ch1c0t/sources/ruby/hobby-json/lib/hobby/json.rb:6:581f7 | |
@@ -1,5 +1,5 @@ | |
-def self.included(app) | |
+def self.included | |
app.use(Rack::ContentType, "application/json") | |
app.response = Response | |
end | |
----------------------- | |
Mutant configuration: |
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
module Hobby | |
module Auth | |
def self.[] *users | |
Module.new do | |
define_singleton_method :included do |app| | |
users.each do |user| | |
app.define_singleton_method user.downcase do |route| | |
action = route.action | |
route.action = -> do | |
if user = (user.find_by_token request.headers['Authorization']) |
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
TRACE_POINTS = [] | |
TRACE = TracePoint.new :return, :c_return do |t| | |
TRACE_POINTS << [t.event, t.path, t.lineno, t.binding, t.defined_class, t.method_id, t.return_value] | |
end | |
def Trace | |
TRACE_POINTS.clear | |
TRACE.enable | |
yield | |
TRACE.disable |
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
curl https://rubygems.org/api/v1/gems/method_source/reverse_dependencies.json |
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
# http://eli.thegreenplace.net/2011/09/29/an-interesting-tree-serialization-algorithm-from-dwarf | |
def load array | |
root = Node.new array.shift.first | |
stack = [root] | |
array.each do |pair| | |
if pair.nil? | |
stack.pop | |
else |
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
#define _GNU_SOURCE | |
#include <dlfcn.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
typedef int (*LibcStartMainFnType)(int (*main)(int, char **, char **), int argc, char **argv, | |
int (*init)(void), void (*fini)(void), | |
void (*ldso_fini)(void), void (*stack_end)); | |
int __libc_start_main(int (*main)(int, char **, char **), int argc, char **argv, |
OlderNewer