Skip to content

Instantly share code, notes, and snippets.

@jeremypetrequin
jeremypetrequin / migrate-db.php
Last active December 1, 2020 09:11
Task NPM//PHP to generate SQL queries to migrate a WP
<?php
if(empty($_SERVER['npm_config_to'])) {
die('Missing --to parameter'.PHP_EOL);
}
$to = $_SERVER['npm_config_to'];
$_SERVER['SERVER_NAME'] = $_SERVER['npm_package_url'];
define('WP_USE_THEMES', false);
require_once(dirname(__FILE__).'/../../app/wp-load.php');
@jeremypetrequin
jeremypetrequin / script
Created May 26, 2014 12:04
Find what f***** DOM element break your responsive by adding a horz scrollbar
//put this in your console, and see the red elements
var breakpoint = 320;
$('*').each(function() {
($t = $(this)).outerWidth() + $t.offset().left > breakpoint && console.log($t.css('background', 'red'));
});
@jeremypetrequin
jeremypetrequin / gutenberg.js
Created April 17, 2020 14:47
To be abble to transform gutenberg core block into ACF custom block
window.F = window.F || {}; //your custom namespace
//prepare yours transformers
window.F.blocks = {
transformParagraphToQuestion(attributes) { //the transform name you write un your PHP
//very ugly, maybe ask to ACF is there is a better option?
let interval = setInterval(() => { //we wait for the ACF block fields to be ready in the DOM
//your ACF field key in the block
//mine is a wysiwyg field, so I look for an iframe, but else you can simply look for the input you want
let $iframe = document.querySelector('[data-key="field_5e579284bf0a2"] iframe');
let iframeDoc = null;
@jeremypetrequin
jeremypetrequin / footer.php
Created January 10, 2018 13:47
Track SQL numbers in wordpress
@jeremypetrequin
jeremypetrequin / article.md
Last active December 25, 2016 08:06
How to convert a Flash/After Effects animation into a JSMovieclip animation

How to convert a Flash/After Effects animation into a JSMovieclip animation

Intro

JSMovieclip is a little javascript framework. It allows you to play, control... animations like a Movieclip object in AS3. It uses a sprite which contains all frames of the animation.

Purpose : We'll create a sprite to use with JSMovieclip, from a Flash animation, using TexturePacker

Requirement : We'll use Flash/After Effects, Texture Packer, and JSMovieclip script

//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
alert('okdoked');
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(100);