Skip to content

Instantly share code, notes, and snippets.

@uu59
Last active May 30, 2016 00:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save uu59/3d68ea2d1e2b59434cfb04c2961c49b9 to your computer and use it in GitHub Desktop.
Save uu59/3d68ea2d1e2b59434cfb04c2961c49b9 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
percent = (ENV["D"] || "50").to_i
content = ARGF.read
if STDOUT.tty?
print content.chars.map{|c| next c unless c.match(/[\x20-\x7f]/); rand(1..100) <= percent ? " " : c}.join
else
print content
end
def fib(a)
return a if a <= 1
fib(a - 2) + fib(a - 1)
end
puts fib(10)
$ ./dl.rb ./fib.rb
 e    b( )
  ret    a  f   <=
  fib(a - 2) + fib(a - 1)
e d

p  s    (  )
$ D=50 ./dl.rb ./fib.rb
  f fi (a)
      r  a  f   <=
    b(    2    f b a   1
 n

puts   b   )
$ D=100 ./dl.rb ./fib.rb








$ ./dl.rb ./fib.rb | ruby
55
$ ./dl.rb ./fib.rb | ./dl.rb | ruby
55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment