Skip to content

Instantly share code, notes, and snippets.

@kopepasah
kopepasah / filter-infinite-scroll-text.php
Last active January 24, 2017 22:55
Quickly change Jetpack's Infinite Scroll text on button that loads more posts.
<?php
function filter_jetpack_infinite_scroll_js_settings( $settings ) {
$settings['text'] = __( 'Load more...', 'l18n' );
return $settings;
}
add_filter( 'infinite_scroll_js_settings', 'filter_jetpack_infinite_scroll_js_settings' );
@debloper
debloper / index.html
Created December 14, 2011 11:37
Pulsating HTML Element with just pinchful of CSS Animation
<!DOCTYPE html>
<html>
<head>
<title>CSS Pulsator</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="pulsor">Pulsate!</div>
</body>
</html>
@isGabe
isGabe / wp_custom_title_placeholder_text.php
Last active February 25, 2019 21:28
WordPress: Custom placeholder text for custom post type title input box #snippet #WordPress
<?php
/*
replacing the default "Enter title here" placeholder text in the title input box
with something more descriptive can be helpful for custom post types
place this code in your theme's functions.php or relevant file
source: http://flashingcursor.com/wordpress/change-the-enter-title-here-text-in-wordpress-963
*/
@robballou
robballou / someModule.js
Created October 29, 2014 23:04
Testing jQuery code in Mocha
// The hacky bit of this approach is that this module uses
// jQuery, but it is not referenced here. This is because I
// am populating it in the test via global namespace.
//
// In the browser this still works because I am adding jQuery
// via a Browserify transform (browserify-global-shim).
function someModule() {
}
modules.export = someModule;
@manuganji
manuganji / height_regex.js
Last active November 25, 2019 18:12
JavaScript Regex to figure out the value in inches when the input value is in feet-inch notation( Eg: height) . Properly catches 5'10", 11'10", 5'2", 5'07, 5', 5'", 5 Also fails correctly for 5'13", 5'233", 521'1",
height_val = $("#id_height").val();
var regex_op = /^(\d{1,2})[\']?((\d)|([0-1][0-2]))?[\"]?$/g.exec(height_val);
//very rare chance for someone to be of two digit feet height.
//but i put it there, just in case.
var feet = regex_op[1];
var inches = regex_op[2];
// converting to inches
var height = (parseInt(feet) || 0) * 12 + (parseInt(inches) || 0);
let orders = [26, 3, 5, 7, 8, 5, 0, 8, 4]
let arrSum = arr => (arr.reduce((x, accumulate) => accumulate + x, 0))
let avgOrders = arrSum(orders)/orders.length
console.log(avgOrders)
let differences = orders.map(x => x - avgOrders).map(x => x * x)
console.log(differences)
@psyrendust
psyrendust / elementChange.js
Created November 17, 2015 20:44
Add and remove MutationObserver events to a registered DOM element.
/**
* @typedef MutationCallback
* @param {NodeList} addedNodes A NodeList of elements that have been added to the DOM.
* @param {NodeList} removedNodes A NodeList of elements that have been removed from the DOM.
*/
/**
* Add a MutationObserver to a DOM node.
*
* @example
*
@maheshwaghmare
maheshwaghmare / php-class-boilderplate.php
Last active April 26, 2021 15:56
PHP Class boilerplate - *The Singleton Pattern*
<?php
/**
* MY CLASS NAME
*
* @package MY PACKAGE
* @since 1.0.0
*/
if( ! class_exists( 'MY_CLASS_NAME' ) ) :
@pmgarman
pmgarman / delete.sql
Created August 1, 2013 22:35
How to find and delete orphaned product variations from WooCommerce sites.
DELETE o FROM `wp_posts` o
LEFT OUTER JOIN `wp_posts` r
ON o.post_parent = r.ID
WHERE r.id IS null AND o.post_type = 'product_variation'
@ColinEberhardt
ColinEberhardt / Swift Events
Created February 11, 2015 09:15
An eventing mechanism for Swift
/// An object that has some tear-down logic
public protocol Disposable {
func dispose()
}
/// An event provides a mechanism for raising notifications, together with some
/// associated data. Multiple function handlers can be added, with each being invoked,
/// with the event data, when the event is raised.
public class Event<T> {