Skip to content

Instantly share code, notes, and snippets.

@giacecco
Last active December 27, 2015 02:09
Show Gist options
  • Save giacecco/7250166 to your computer and use it in GitHub Desktop.
Save giacecco/7250166 to your computer and use it in GitHub Desktop.
To reproduce the bug described in issue 23 https://github.com/soldair/node-qrcode/issues/23 in soldair/node-qrcode
Ode to Autumn
by John Keats
Season of mists and mellow fruitfulness,
Close bosom-friend of the maturing sun;
Conspiring with him how to load and bless
With fruit the vines that round the thatch-eaves run;
To bend with apples the moss'd cottage-trees,
And fill all fruit with ripeness to the core;
To swell the gourd, and plump the hazel shells
With a sweet kernel; to set budding more,
And still more, later flowers for the bees,
Until they think warm days will never cease;
For Summer has o'erbrimm'd their clammy cells.
Who hath not seen thee oft amid thy store?
Sometimes whoever seeks abroad may find
Thee sitting careless on a granary floor,
Thy hair soft-lifted by the winnowing wind;
Or on a half-reap'd furrow sound asleep,
Drowsed with the fume of poppies, while thy hook
Spares the next swath and all its twinèd flowers:
And sometimes like a gleaner thou dost keep
Steady thy laden head across a brook;
Or by a cyder-press, with patient look,
Thou watchest the last oozings, hours by hours.
Where are the songs of Spring? Ay, where are they?
Think not of them, thou hast thy music too,—
While barrèd clouds bloom the soft-dying day
And touch the stubble-plains with rosy hue;
Then in a wailful choir the small gnats mourn
Among the river-sallows, borne aloft
Or sinking as the light wind lives or dies;
And full-grown lambs loud bleat from hilly bourn;
Hedge-crickets sing; and now with treble soft
The redbreast whistles from a garden-croft;
And gathering swallows twitter in the skies.
var fs = require('fs'),
Canvas = require('canvas'),
QR = require('qrcode');
// "level H" QR codes should support up to 1273 characters, but I have seen the
// qrcode library failing beyond 1268
var TEST_STRING_SIZE = 1269,
sourceText = fs.readFileSync("example.txt", { encoding: 'utf8' }),
croppedText = sourceText.substring(0, TEST_STRING_SIZE);
QR.draw(croppedText, function (err, qRCanvas) {
var img = new Canvas.Image;
img.src = qRCanvas.toBuffer();
qRCanvas.toBuffer(function (err, buf) {
fs.writeFileSync('test.png', buf);
});
});
{
"name": "test",
"version": "0.0.1",
"author": "Gianfranco Cecconi <[email protected]>",
"description": "Does what it says on the tin",
"contributors": [
{
"name": "Gianfranco Cecconi",
"email": "[email protected]"
}
],
"keywords": [
],
"dependencies" : {
"async": ">=0.2.9",
"canvas": ">=1.1.1",
"qrcode": ">=0.2.8",
"underscore": ">=1.5.2"
},
"license": "MIT",
"engines": {
"node": ">=0.10.18"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment