Last active
December 16, 2015 03:19
Revisions
-
joyrexus revised this gist
Apr 12, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ filter.coffee ============= A sample coffee [filter](http://en.wikipedia.org/wiki/Filter_(Unix\)). ``` $ echo "hi world" | filter.coffee -
joyrexus revised this gist
Apr 12, 2013 . 2 changed files with 8 additions and 11 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,12 @@ #!/usr/bin/env coffee fs = require 'fs' transform = (data) -> result = data.toString().replace /h/g, 'm' process.stdout.write result if process.argv.length > 2 transform fs.readFileSync(file, 'utf8') for file in process.argv[2..] else process.stdin.on 'data', transform process.stdin.resume() 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ filter.coffee ============= A sample coffee [filter](http://en.wikipedia.org/wiki/Filter_(Unix)). ``` $ echo "hi world" | filter.coffee -
joyrexus created this gist
Apr 12, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ !/usr/bin/env coffee fs = require 'fs' argv = require('optimist').argv print = console.log filter = (data) -> result = data.toString().replace /h/g, 'm' print result if argv._.length filter fs.readFileSync(file, 'utf8') for file in argv._ else process.stdin.on 'data', filter process.stdin.resume() 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ filter.coffee ============= A sample coffee filter. ``` $ echo "hi world" | filter.coffee mi world ``` ``` $ cat hello.txt hello world! $ filter.coffee hello.text mello world! ```