Skip to content

Instantly share code, notes, and snippets.

View zoetrope69's full-sized avatar
🦫
beavering away

z zoetrope69

🦫
beavering away
View GitHub Profile

Keybase proof

I hereby claim:

  • I am zaccolley on github.
  • I am zaccolley (https://keybase.io/zaccolley) on keybase.
  • I have a public key whose fingerprint is 35DB 3451 A554 3A15 1D8E 8B72 5517 6B90 5BEC F424

To claim this, I am signing this object:

@zoetrope69
zoetrope69 / wallpaper.sh
Last active March 21, 2016 23:36
dynamic wallpapers from unsplash
# get latest pic, change your screen resolution in the url paths: https://unsplash.it/width/height?random
wget -O /tmp/wallpaper 'https://unsplash.it/1366/768?random' > /dev/null 2>&1
# set it as desktop wallpaper
gsettings set org.gnome.desktop.background picture-uri /tmp/wallpaper # gnome ubuntu
# osascript -e 'tell application "Finder" to set desktop picture to POSIX file "/tmp/wallpaper"' # osx
@zoetrope69
zoetrope69 / lastfm-example.js
Last active July 21, 2017 11:19
last.fm stream example
const { LastFmNode } = require('lastfm');
const lastfm = new LastFmNode({});
lastfm.stream('zaccolley').on('nowPlaying', track => {
console.log(track);
});
@zoetrope69
zoetrope69 / lastfm-simplified-data-example.json
Created July 19, 2017 14:29
last.fm simplified data example
{
"tracks": [
{
"mbid": "6d5625ba-8cdc-489d-8b5b-f298e76f8862",
"name": "Aubrey Plaza",
"artist": "Bear Cavalry",
"album": "Puryys",
"url": "https://www.last.fm/music/Bear_Calvary/_/Puryys",
"image": "https://lastfm-img2.akamaized.net/image.png",
"nowplaying": true
@zoetrope69
zoetrope69 / printer-example.js
Last active July 21, 2017 11:22
Printer code example
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();
});
@zoetrope69
zoetrope69 / gm-example.js
Last active July 21, 2017 11:18
GM Example
const gm = require('gm');
gm('/path/to/inputFile.png')
.monochrome()
.write('/path/to/outputFile.png', () => {
// Image created
});
@zoetrope69
zoetrope69 / dnt-express-example.js
Created June 15, 2018 10:30
Example of using express to get the Do Not Track preferences from a request
app.get('/', (request, response) => {
console.log(request.header('DNT'))
})
@zoetrope69
zoetrope69 / dnt-server-side-function.js
Created June 15, 2018 10:32
Example function that can be used to detect Do Not Track preferences server side
function isDoNotTrackEnabled (request) {
const doNotTrackHeader = request.header('DNT')
if (!doNotTrackHeader) {
return false
}
if (doNotTrackHeader.charAt(0) === '1') {
return true
}
@zoetrope69
zoetrope69 / dnt-client-side-function.js
Last active July 5, 2018 14:42
Example of detecting Do Not Track on the client side
function isDoNotTrackEnabled () {
const doNotTrackOption = (
window.doNotTrack ||
window.navigator.doNotTrack ||
window.navigator.msDoNotTrack
)
if (!doNotTrackOption) {
return false
}
@zoetrope69
zoetrope69 / dnt-templating-example.js
Created June 15, 2018 10:34
Example of how you could choose not to send Google scripts if Do Not Track is enabled
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 = `