Skip to content

Instantly share code, notes, and snippets.

const fs = require('fs');
const path = require('path');
const PNG = require('pngjs').PNG;
const EPD = require('rpi-gpio-epaper');
function readImage(imagePath) {
return new Promise((resolve, reject) => {
fs
.createReadStream(imagePath)
.pipe(new PNG())
@dbushell
dbushell / rpi-gpio-epaper-full-picture.js
Created October 2, 2017 07:45
rpi-gpio-epaper full picture example
const fs = require('fs');
const PNG = require('pngjs').PNG;
const EPD = require('rpi-gpio-epaper');
function readImage(imagePath) {
return new Promise((resolve, reject) => {
fs
.createReadStream(imagePath)
.pipe(new PNG())
.on('parsed', function() {
// http://jasonwyatt.tumblr.com/post/10481498815/how-to-correctly-debounce-a-javascript-function
function debounce(fn, debounceDuration)
{
debounceDuration = debounceDuration || 100;
return function(){
if(!fn.debouncing){
var args = Array.prototype.slice.apply(arguments);
fn.lastReturnVal = fn.apply(window, args);
fn.debouncing = true;
@dbushell
dbushell / htmlizr.js
Last active December 15, 2015 20:19
Grunt task to build HTML templates with includes (original version: https://gist.github.com/dbushell/5186122)
/*!
*
* Copyright (c) David Bushell | @dbushell | http://dbushell.com/
*
*/
var fs = require("fs"),
path = require("path");
module.exports = function(grunt)
@dbushell
dbushell / gist:5186122
Last active December 15, 2015 02:19
Grunt task to build HTML templates with includes (work in progress!)
/*!
*
* Copyright (c) David Bushell | @dbushell | http://dbushell.com/
*
*/
var fs = require("fs"),
path = require("path");
module.exports = function(grunt)
$('input[type="date"]').each(function()
{
var picker = new Pikaday({ field: this });
$(this).data('pikaday', picker);
});
@dbushell
dbushell / steps.txt
Last active November 23, 2015 10:17
WordPress local development (MAMP)
Easy steps for cloning a live WordPress site for local development with MAMP. Am I missing anything?
1. add new MAMP server
2. download all files
3. export MySQL database
4. import SQL to MAMP via command line:
/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -p dbname < ~/Downloads/database.sql
5. update: wp-config.php
@dbushell
dbushell / gist:4247060
Created December 9, 2012 21:19
Add SVG upload support to a WordPress theme
// add to functions.php in your WordPress theme
add_filter('upload_mimes', 'my_upload_mimes');
function my_upload_mimes($mimes = array())
{
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
@dbushell
dbushell / gist:4131104
Created November 22, 2012 13:10
Animate scrolling to an element or offset
/*!
* requires jQuery
* usage:
* Scroller.to({ offset: 100 });
* Scroller.to({ target: $('#main') });
*
* advanced usage (with additional easing function not provided here)
* Scroller.to({ target: $('#main'), delay: 500, multiplier: 1.5, easing: 'easeOutQuad' });
*/
var Scroller = (function()
@dbushell
dbushell / dabblet.css
Created July 12, 2012 17:04
Diagonal Stripe Background with CSS and SVG
/**
* Diagonal Stripe Background with CSS and SVG
*/
body {
padding: 0;
margin: 0;
}
#content {