3) not idiomatic ruby (e.g. camelCase not snake_case)
4) overtly complicated. A better, and shorter version, is:
bad_whitespace = " "
ARGF.inplace_mode = ""
ARGF.each_line do |line|
print line.gsub(" ", bad_whitespace)
end
5) bad commenting. The style of commenting each line for what it does is often silly. Something like "fileModified.close # Close file" tells me exactly nothing more than reading the code. Having "noisy" comments makes important comments less obvious, and thus actually makes the overall commenting worse.
This is a sign of a college coder who had some class where the teacher said "you're required to have at least this much commenting", or a beginner programmer.
And finally, this is obviously a dumb toy program.
This isn't useful to show-hn. This isn't anything novel, or even interesting. It's not hard to do. It's poorly implemented and not portable (really, why require the user to edit the filename? ARGF exists for a reason).
This was also submitted by a new hn account mere hours after it was created (clearly by the author). I have no problem with showing off your own work, but at least let it cool down to see if it's a good idea; see that other people think it's interesting or useful in its own right.
I consider presenting an essentially 5-line program that is not generally useable or insightful as being basically spam.
I do recommend keeping on programming and, once you've got a project you're proud of that has seen some use besides yourself, seen at least one other happy user, and relates to HN's interests, post away!
Out of curiosity (haven't done ruby for awhile): is your line-by-line implementation safe? Is it guaranteed that the lines are identical in the output file besides the character you're replacing? I'm thinking different CR+LR combinations. What if the final line is not terminated by newline? Doesn't print always add it?
Even worse, we actually had a regression at work caused by a zero width space sneaking into some code. Most editors won't even display anything for that character, even the code review tool we used didn't!
In the end I configured Emacs to highlight all unicode characters, trailing whitespace and tabs bright red. I also had it render zero width characters as normal spaces, otherwise they were still invisible. https://github.com/kzar/emacs.d/blob/master/init.el#L181-L19...
Why would you want to do that with ruby script instead of your favorite editor, or tr/sed on the commandline? And why would you write a "Close file" comment before file.close?
1) no LICENSE file
2) not configurable
3) not idiomatic ruby (e.g. camelCase not snake_case)
4) overtly complicated. A better, and shorter version, is:
5) bad commenting. The style of commenting each line for what it does is often silly. Something like "fileModified.close # Close file" tells me exactly nothing more than reading the code. Having "noisy" comments makes important comments less obvious, and thus actually makes the overall commenting worse.This is a sign of a college coder who had some class where the teacher said "you're required to have at least this much commenting", or a beginner programmer.
And finally, this is obviously a dumb toy program.
This isn't useful to show-hn. This isn't anything novel, or even interesting. It's not hard to do. It's poorly implemented and not portable (really, why require the user to edit the filename? ARGF exists for a reason).
This was also submitted by a new hn account mere hours after it was created (clearly by the author). I have no problem with showing off your own work, but at least let it cool down to see if it's a good idea; see that other people think it's interesting or useful in its own right.
I consider presenting an essentially 5-line program that is not generally useable or insightful as being basically spam.
I do recommend keeping on programming and, once you've got a project you're proud of that has seen some use besides yourself, seen at least one other happy user, and relates to HN's interests, post away!