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
.video-wrapper { | |
position: relative; | |
padding-bottom: 56.25%; | |
height: 0; | |
iframe, | |
object, | |
embed { | |
position: absolute; | |
top: 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
var inViewport = function(el, side) { | |
var win = window; | |
var viewport = { | |
top: win.scrollY, | |
left: win.scrollX | |
}; | |
viewport.right = viewport.left + win.outerWidth; | |
viewport.bottom = viewport.top + win.outerHeight; |
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 | |
/** | |
* Replace the last occurrence of a string. | |
* | |
* @param string $search The string to search for | |
* @param string $replace The string to replace the search string | |
* @param string $subject The string to search and replace | |
* @return string The new string | |
*/ | |
function str_replace_last( $search=null, $replace=null, $subject=null ) { |
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 | |
/** | |
* Convert an array to a CSV string. | |
* | |
* @param array $array The array to be converted | |
* @return string The newly created string | |
*/ | |
function array_to_csv( $array ) { | |
if(count( $array ) == 0 ) { | |
return null; |
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
#!/usr/bin/env bash | |
# Ask for the administrator password upfront. | |
sudo -v | |
# Keep-alive: update existing `sudo` time stamp until the script has finished. | |
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & | |
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
#!/usr/bin/env bash | |
# Dir to Filename | |
# Rename all the files in a directory with their parent directory name. | |
# Copyright (C) Kyle Brumm <http://kylebrumm.com> | |
if [ "$1" = "-h" -o "$1" = "--help" ]; then cat <<EOF | |
Dir to Filename |
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 | |
/** | |
* Match the current URL against the supplied URL. | |
* | |
* @param string $url The URL to be checked | |
* @return boolean | |
*/ | |
function current_page_url_in( $url ) { | |
return ( strpos( $_SERVER['REQUEST_URI'], parse_url( $url, PHP_URL_PATH ) ) !== false ); | |
} |
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 | |
/** | |
* Get the first category of a post. | |
* | |
* @param int $id The id of a post | |
* @param int $id The field value to return | |
* @return mixed The category object or single field | |
*/ | |
function wp_get_first_category( $id=null, $field='all' ) { | |
// Check if only a field value was supplied |
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
# Variables used | |
RED=$(tput setaf 1); | |
GREEN=$(tput setaf 2); | |
YELLOW=$(tput setaf 3); | |
WHITE=$(tput setaf 7); | |
# Throw an error | |
error() { | |
printf "${RED}Error:${WHITE} ${1}\n" | |
exit |