This file contains hidden or 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 | |
/** | |
* Example useage: | |
* | |
* maybe_sideload_image( 'https://dummyimage.com/600x400/000/fff.png' ); // Downloads image to the media library and returns an attachment ID | |
* maybe_sideload_image( 'https://dummyimage.com/600x400/000/fff.png' ); // Returns an attachment ID as the image has already been downloaded and added to the media library | |
*/ | |
/** |
This file contains hidden or 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
// https://github.com/jonathantneal/closest/blob/master/src/index.js | |
var ElementPrototype = window.Element.prototype; | |
if (typeof ElementPrototype.matches !== 'function') { | |
ElementPrototype.matches = ElementPrototype.msMatchesSelector || ElementPrototype.mozMatchesSelector || ElementPrototype.webkitMatchesSelector || function matches(selector) { | |
var element = this; | |
var elements = (element.document || element.ownerDocument).querySelectorAll(selector); | |
var index = 0; | |
while (elements[index] && elements[index] !== element) { | |
++index; | |
} |
This file contains hidden or 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 | |
/** | |
* Plugin name: HTTP2 Push scripts | |
* Author: Tom J Nowell | |
*/ | |
function tomjn_get_dep_url( /*\WP_Dependency*/ $dep ) { | |
global $wp_version; | |
$relative = str_replace( site_url(), '', $dep->src ); | |
$ver = $dep->ver; |
This file contains hidden or 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 | |
/** | |
* Plugin Name: Offload API Helper | |
* Plugin URI: iwritecode.blog | |
* Description: Offload plugins during API requests to reduce overhead. | |
* Author: Chris Kelley | |
* Author URI: iwritecode.blog | |
* Version: 1.0.0 | |
*/ |
This file contains hidden or 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
(function (context, trackingId, options) { | |
const history = context.history; | |
const doc = document; | |
const nav = navigator || {}; | |
const storage = localStorage; | |
const encode = encodeURIComponent; | |
const pushState = history.pushState; | |
const typeException = 'exception'; | |
const generateId = () => Math.random().toString(36); | |
const getId = () => { |
This file contains hidden or 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
// License: GPLv2+ | |
var el = wp.element.createElement, | |
registerBlockType = wp.blocks.registerBlockType, | |
ServerSideRender = wp.components.ServerSideRender, | |
TextControl = wp.components.TextControl, | |
InspectorControls = wp.editor.InspectorControls; | |
/* | |
* Here's where we register the block in JavaScript. |
This file contains hidden or 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
xrupdate () { | |
curl -s 'https://dskbank.bg/restapi/dsk/GetCurrencyRates?format=json' | | |
sed -e 's/[{}]/\n/g' -e 's/"//g' | sed -e '2~2d' | | |
awk -v date="$(date +"%Y-%m-%d")" -F[,:] 'NF && $4!=0{print "P " date" 00:00:00 "$6" "$4 " BGN"}' >> ~/L/ledger/data/prices.db | |
} |
This file contains hidden or 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
from RPi import GPIO | |
from time import sleep | |
clk = 17 | |
dt = 18 | |
GPIO.setmode(GPIO.BCM) | |
GPIO.setup(clk, GPIO.IN, pull_up_down=GPIO.PUD_UP) | |
GPIO.setup(dt, GPIO.IN, pull_up_down=GPIO.PUD_UP) |
This file contains hidden or 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
( function( blocks, element ) { | |
var el = element.createElement; | |
function Stars( { stars } ) { | |
return el( 'div', { key: 'stars' }, | |
'★'.repeat( stars ), | |
( ( stars * 2 ) % 2 ) ? '½' : '' ); | |
} | |
blocks.registerBlockType( 'stars/stars-block', { |
This file contains hidden or 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 | |
/** | |
* Make sure the function does not exist before defining it | |
*/ | |
if( ! function_exists( 'remove_class_filter' ) ){ | |
/** | |
* Remove Class Filter Without Access to Class Object | |
* | |
* In order to use the core WordPress remove_filter() on a filter added with the callback |
NewerOlder