This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ------------------------------------------------- | |
// | |
// WordPress URL Auto-Updater | |
// https://gist.github.com/thomhines/f3350204e6db2de32b7f | |
// | |
// ------------------------------------------------- | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var validation_debounce_timeout; | |
$.fn.debounce = function(callback, delay) { | |
$this = $(this); | |
clearTimeout(validation_debounce_timeout); | |
validation_debounce_timeout = setTimeout(function() { | |
callback(); | |
}, delay); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.fn.getValue = function() { | |
if(this.is(':checkbox') && this.is(':checked')) return true; | |
else if(this.is(':checkbox') && !this.is(':checked')) return false; | |
else if(this.is(':radio') && $('input[name="'+this.attr('name')+'"]').filter(':checked').val()) return $('input[name="'+this.attr('name')+'"]').filter(':checked').val(); | |
else if(this.is(':radio') && !$('input[name="'+this.attr('name')+'"]').filter(':checked').val()) return false; | |
else if(this.val()) return this.val(); | |
return false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var max_swipe_duration = 800; | |
var min_swipe_distance = 30; | |
var touchstartX, touchstartY, touchstartTime, touchMove; | |
// Record initial touch positions | |
$(window).on('touchstart', function(e) { | |
touchstartX = e.touches[0].screenX; | |
touchstartY = e.touches[0].screenY; | |
touchstartTime = new Date(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// inlineSVG | |
// Convert <img> elements pointing to SVG files to inline SVG | |
// | |
// With some help from https://snippetlib.com/jquery/replace_all_svg_images_with_inline_svg | |
jQuery.fn.extend({ | |
inlineSVG: function(callback) { | |
$(this).each(function() { | |
var $img = $(this) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Register the plugin with Capacitor | |
import { Plugins } from '@capacitor/core'; | |
const { Keyboard } = Plugins; | |
// ORIENTATION | |
// Start tracking device orientation. This must be run in order for the following event listener to work | |
iosMotion.getOrientation() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In shell, run `sh vue_sfc.sh inputfile.vue outputfile.js` | |
# HTML template and JS conversion only (doesn't do CSS), but it *can* do multiple components in one file. | |
# Note: you need to wrap your components in a non-standard tag `<component name="component_name">...</component>` | |
cat $1 | \ | |
perl -00 -pe 's|\n\n|\n|gs' | \ | |
perl -00 -pe 's|<component name="(.*?)">|Vue.component("\1", {\n\ttemplate:|gs' | \ | |
perl -00 -pe 's|<template>(.*?)<\/template>|`\1`,|gs' | \ | |
perl -00 -pe 's|<script>.*?{| |gs' | \ | |
perl -00 -pe 's|<\/script>.*?</component>|);\n|gs' | \ |