^(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?$
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 | |
// LOAD FROM FILE | |
$xml = simplexml_load_file('sample.xml'); | |
// ALTERNATE LOAD FROM STRING | |
// $xml = simplexml_load_string($xmlResponse); | |
foreach($xml->data as $data) { | |
$namespaces = $data->getNameSpaces(true); | |
$a = $data->children($namespaces['a']); |
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
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"name": "Listen for XDebug", | |
"type": "php", | |
"request": "launch", | |
"port": 9000 | |
}, | |
{ |
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 | |
/* | |
* Function to get the post count from a given category or taxonomy | |
* term or terms, including their children. | |
* | |
* @param (int|array|string) $term Single integer value, or array of integers or "all" | |
* @param (string) $taxonomy | |
* @param (array) $args Array of arguments to pass to WP_Query | |
* @return $q->found_posts | |
* |
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
#!/bin/bash | |
TINYAPIKEY="YOUR_API_KEY" | |
# Make sure source dir is supplied | |
if [ -z "$1" ] | |
then | |
echo "Missing argument. Supply the source directory containing the images to be optimized. Usage: ./tiny.sh <source_dir>" | |
exit 1 | |
fi | |
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
// If element is in viewport | |
// EXAMPLE: $('.element').isOnScreen(); | |
$.fn.isOnScreen = function(){ | |
var win = $(window); | |
var viewport = { | |
top : win.scrollTop(), | |
left : win.scrollLeft() | |
}; |
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
import sublime | |
import sublime_plugin | |
class GulpDeleteCacheOnKill(sublime_plugin.WindowCommand): | |
def run(self): | |
self.window.run_command("gulp_kill") | |
self.window.run_command("gulp_delete_cache") |
You probably already know that WordPress can schedule events. For example, it can publish posts at preset dates and times. Using hooks and wp-cron
, we can easily schedule our own events. In this example, we will get our WordPress blog to send us an email once hourly.
Paste the following code block in the functions.php file of your theme.
if (!wp_next_scheduled('my_task_hook')) {
wp_schedule_event( time(), 'hourly', 'my_task_hook' );
}
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 toggleDecadeVisibility() { | |
var windowWidth = $(window).width(); | |
$('.element').each(function() { | |
var elementLeft = $(this).offset().left, | |
visibleOffset = (windowWidth / 2) - ($(this).width() / 2), | |
hideOffset = visibleOffset - $(this).width(); | |
// If element is in center of viewport, make visible | |
if (elementLeft <= visibleOffset && elementLeft >= hideOffset) { |