Skip to content

Instantly share code, notes, and snippets.

View danielfone's full-sized avatar

Daniel Fone danielfone

View GitHub Profile
@danielfone
danielfone / unindent.rb
Last active August 29, 2015 14:06 — forked from avdi/unindent.rb
TEXT = <<EOF
See, the interesting thing about this text
is that while it seems like the first line defines an indent
it's actually the last line which has the smallest indent
there are also some blank lines
both with and without extra spaces in them
and it just goes on and on
@danielfone
danielfone / unindent.rb
Last active August 29, 2015 14:06 — forked from avdi/unindent.rb
TEXT = <<EOF
See, the interesting thing about this text
is that while it seems like the first line defines an indent
it's actually the last line which has the smallest indent
there are also some blank lines
both with and without extra spaces in them
and it just goes on and on
@danielfone
danielfone / unindent.rb
Last active August 29, 2015 14:06 — forked from avdi/unindent.rb
TEXT = <<EOF
See, the interesting thing about this text
is that while it seems like the first line defines an indent
it's actually the last line which has the smallest indent
there are also some blank lines
both with and without extra spaces in them
and it just goes on and on
@danielfone
danielfone / unindent.rb
Last active August 29, 2015 14:06 — forked from avdi/unindent.rb
TEXT = <<EOF
See, the interesting thing about this text
is that while it seems like the first line defines an indent
it's actually the last line which has the smallest indent
there are also some blank lines
both with and without extra spaces in them
and it just goes on and on
@danielfone
danielfone / unindent.rb
Last active August 29, 2015 14:06 — forked from avdi/unindent.rb
TEXT = <<EOF
See, the interesting thing about this text
is that while it seems like the first line defines an indent
it's actually the last line which has the smallest indent
there are also some blank lines
both with and without extra spaces in them
and it just goes on and on
# returns [output string, err string, exit code]
def cmd(args, input = nil)
parent_read, child_write = IO.pipe
err_read, err_write = IO.pipe
child_read, parent_write = IO.pipe if input
pid = fork do
if input
parent_write.close
$stdin.reopen(child_read)