Skip to content

Instantly share code, notes, and snippets.

View rpi-gpio-epaper-example.js
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 Oct 2, 2017
rpi-gpio-epaper full picture example
View rpi-gpio-epaper-full-picture.js
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() {
@dbushell
dbushell / steps.txt
Last active Nov 23, 2015
WordPress local development (MAMP)
View steps.txt
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:3f50c37351bffca47814
Created Jun 12, 2015
Proxy an Express static site and rewrite all content URLs to localhost
View gist:3f50c37351bffca47814
var http = require('http'),
cheerio = require('cheerio'),
express = require('express');
module.exports = plugin;
function plugin(grunt)
{
grunt.registerTask('dbushell_server', 'dbushell.com', function() {
@dbushell
dbushell / gist:beb25b8352ed896d85d4
Created Mar 23, 2015
Poll Stylesheets until they exist in document.styleSheets
View gist:beb25b8352ed896d85d4
var stylesheets = Array.prototype.slice.call(document.querySelectorAll('link[href*=".css"]'))
var sheets = document.styleSheets;
function pollSheets() {
var i, j, load_count = 0;
for (i = 0; i < stylesheets.length; i++) {
for (j = 0; j < sheets.length; j++) {
// check if stylesheet exists in document.styleSheets
if (sheets[j].href && sheets[j].href.indexOf( stylesheets[i].href ) > -1) {
@dbushell
dbushell / gist:fec0ba804e4f06c46d4d
Created Mar 16, 2015
Fake links in jQuery, useful for making whole elements clickable while the actual <a> is smaller inside.
View gist:fec0ba804e4f06c46d4d
$(document).on('click', '[data-href]', function(e)
{
var t = e.target;
if (t && t.nodeType === 1 && t.nodeName.toLowerCase() === 'a') {
return;
}
window.location.href = $(e.currentTarget).data('href');
});
View gist:9afdcb229f15a3bbb0a4
<?php
add_action('ninja_forms_display_js', 'dbushell__ninja_forms_display_js');
add_action('ninja_forms_display_css', 'dbushell__ninja_forms_display_css');
function dbushell__ninja_forms_display_js()
{
if (is_admin()) {
return;
}
View gist:6369330
// 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 Dec 15, 2015
Grunt task to build HTML templates with includes (original version: https://gist.github.com/dbushell/5186122)
View htmlizr.js
/*!
*
* 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 Dec 15, 2015
Grunt task to build HTML templates with includes (work in progress!)
View gist:5186122
/*!
*
* Copyright (c) David Bushell | @dbushell | http://dbushell.com/
*
*/
var fs = require("fs"),
path = require("path");
module.exports = function(grunt)
You can’t perform that action at this time.