This file contains hidden or 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
const arr = ['a', 'b', 'c', 'd']; | |
const [,,,result] = arr; | |
console.log(result); | |
// 'd' |
This file contains hidden or 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
/* | |
We're using the watermark feature in Imgix to combine these images together: | |
https://docs.imgix.com/apis/url/watermark | |
If we simplified this component in terms of design we could remove this... | |
*/ | |
const combineImages = ({ foreground, background, width, height }) => { | |
const devicePixelRatio = (window && window.devicePixelRatio) || 1; | |
const newForegroundUrl = replaceImgixParams(foreground, { |
This file contains hidden or 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
if (!isDoNotTrackEnabled) { | |
window.ga('GA_APP_TRACKER.example', 'foo') | |
} |
This file contains hidden or 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
const trackingScripts = ` | |
<script> | |
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | |
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | |
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) | |
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); | |
</script> | |
` | |
const html = ` |
This file contains hidden or 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
function isDoNotTrackEnabled () { | |
const doNotTrackOption = ( | |
window.doNotTrack || | |
window.navigator.doNotTrack || | |
window.navigator.msDoNotTrack | |
) | |
if (!doNotTrackOption) { | |
return false | |
} |
This file contains hidden or 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
function isDoNotTrackEnabled (request) { | |
const doNotTrackHeader = request.header('DNT') | |
if (!doNotTrackHeader) { | |
return false | |
} | |
if (doNotTrackHeader.charAt(0) === '1') { | |
return true | |
} |
This file contains hidden or 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
app.get('/', (request, response) => { | |
console.log(request.header('DNT')) | |
}) |
This file contains hidden or 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
const gm = require('gm'); | |
gm('/path/to/inputFile.png') | |
.monochrome() | |
.write('/path/to/outputFile.png', () => { | |
// Image created | |
}); |
This file contains hidden or 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
const SerialPort = require('serialport') | |
const serialPort = new SerialPort('/dev/ttyUSB0', { baudrate: 19200 }) | |
const Printer = require('thermalprinter'); | |
const printer = new Printer(serialPort); | |
printer.on('ready', () => { | |
printer.printImage(imagePath).print(); | |
}); |