Skip to content

Instantly share code, notes, and snippets.

@tancredi
Created May 1, 2014 11:32
Show Gist options
  • Save tancredi/232e00f68842a0b88bdc to your computer and use it in GitHub Desktop.
Save tancredi/232e00f68842a0b88bdc to your computer and use it in GitHub Desktop.
Quick script to flip text horizontally (Needed to fix some ASCII art)
var fs = require('fs');
var src = process.argv[2],
out = '',
text;
if (!src) {
console.error('Arguments: source_file');
process.exit(1);
}
if (!fs.existsSync(src)) {
console.error('Source file not fond');
process.exit(1);
}
text = fs.readFileSync(src, 'utf8');
text.split('\n').forEach(function (line) {
for (var i = line.length - 1; i >= 0; i -= 1) {
out += line[i];
}
out += '\n';
});
console.log(out);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment