Last active
November 10, 2018 01:57
-
-
Save lionello/b430c15d4b91b50e9d17badfc6ebba73 to your computer and use it in GitHub Desktop.
Tiny QR code generator for showing text/urls in the terminal
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 characters
#!/usr/bin/env node | |
const QR = require("qr-image"); | |
const arrayOf = (len, filler) => new Array(len).fill(filler); | |
const text = process.argv[2]; | |
const matrix = QR.matrix(text, "L"); | |
const topBottomPad = arrayOf(4, arrayOf(matrix[0].length, 0)); | |
const rowPad = arrayOf(4, 0); | |
const qr = topBottomPad | |
.concat(matrix, topBottomPad) | |
.map(row => | |
rowPad | |
.concat(row, rowPad) | |
.map(i => (i ? " " : "██")) | |
.join("") | |
) | |
.join("\n"); | |
console.log(qr); | |
console.log(text); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment