Skip to content

Instantly share code, notes, and snippets.

View daveyjones's full-sized avatar

David Jones daveyjones

  • ProdataKey
  • Pasco, WA
View GitHub Profile
@daveyjones
daveyjones / easing.js
Last active May 1, 2021 17:31
JavaScript Easing Functions
// Source: https://github.com/danro/jquery-easing/blob/master/jquery.easing.js
// t: current time
// b: beginning value
// c: change in value
// d: duration
ease_in_cubic(t, b, c, d) {
return c*(t/=d)*t*t + b;
}
@daveyjones
daveyjones / regenerate-thumbnails.js
Last active June 20, 2023 16:03
Insanely fast multi-core Node.js script for generating (or regenerating) custom WordPress image sizes (e.g. thumbnails) for very large media libraries
// Your server must have wp-cli installed (http://wp-cli.org/)
var async = require("async");
var exec = require("child_process").exec;
var cores = 32; // Adjust the number of cores to match your environment
var total = 0;
var finished = 0;
var q = async.queue(function(task, callback) {
@daveyjones
daveyjones / style.less
Last active October 3, 2016 06:53
Modal fade in and out using LESS
@easing: cubic-bezier(0.19, 1, 0.22, 1);
.modal {
opacity: 0;
transition: opacity 500ms @easing, visibility 0s linear 500ms;
&.visible {
visibility: visible;
opacity: 1;
transition: opacity 500ms @easing;
}
@daveyjones
daveyjones / script.js
Last active May 5, 2016 17:02
Injecting a Wistia video after encoding has finished
var interval = setInterval(function() {
$.ajax({
url: "https://api.wistia.com/v1/medias/" + HASHED_ID + ".json?api_password=" + WISTIA_API_TOKEN,
success: function(data) {
// Update the encoding progress bar
$(".progress .bar").css("width", Math.round(100 * data.progress) + "%");
// Inject the video when ready
if (data.status == "ready") {
$("#container").append($("<div/>").addClass("wistia_embed wistia_async_" + HASHED_ID));
clearInterval(interval);
@daveyjones
daveyjones / image-forensics.js
Last active August 29, 2015 14:14
A simple Node.js script that uses GraphicsMagick (or ImageMagick) to perform image forensics on a JPEG. The script detects areas of a JPEG image that have been modified and highlights them in red.
var exec = require("child_process").exec;
var fs = require("fs");
exec("gm convert test.jpg -quality 95 new.jpg", function (error, stdout, stderr) {
exec("gm compare -highlight-style Assign -highlight-color red -file out.jpg test.jpg new.jpg", function (error, stdout, stderr) {
// Done.
});
});