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
# Very simple Ruby diff for strings. | |
# It works only on strings with the same number of lines, but it was perfect | |
# for my usecase where I was modifying templates saved in the database and I | |
# wanted to be sure that I am changing only what needs to be changed. | |
def differ(str_a, str_b) | |
str_a.lines.zip(str_b.lines) do |line_a, line_b| | |
if line_a != line_b | |
puts "< #{line_a}" | |
puts "> #{line_b}" |
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
#define a /* | |
#! \ | |
sub 'echo {print @_; print "\n"} | |
#' 2>/dev/null | |
# \ | |
echo "my polyglot"; exit; | |
# \ | |
sub puts{}; | |
puts "my polyglot"; | |
exit; |
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
#!/usr/bin/env ruby | |
class Splitter | |
SEPARATOR = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00DICM\x02\x00" | |
attr_reader :file_in_string | |
def initialize(file) | |
@file_in_string = File.binread(file) | |
end |
NewerOlder