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
#Create the Brewfile | |
touch Brewfile | |
# tap homebrew versions repo | |
echo 'tap homebrew/versions' >> Brewfile | |
# add install commands for everything installed in the Cellar | |
for i in `ls /usr/local/Cellar/`; do echo "install $i" >> Brewfile; done; | |
# to use run 'brew bundle' with the Brewfile in the current directory |
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
#!/bin/bash | |
set -eu | |
# store the current dir | |
CUR_DIR=$(pwd) | |
# Let the person running the script know what's going on. | |
echo -e "\n\033[1mPulling in latest changes for all repositories...\033[0m\n" |
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
$doc = new DOMDocument('1.0'); | |
$doc->preserveWhiteSpace = false; | |
@$doc->loadXML( $xml->asXML() ); | |
$doc->formatOutput = true; | |
//return as string | |
return $doc->saveXML(); | |
//save as file | |
//return $doc->save('data.xml'); |
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
class ArrayToXML | |
{ | |
/** | |
* The main function for converting to an XML document. | |
* Pass in a multi dimensional array and this recrusively loops through and builds up an XML document. | |
* Based on: http://snipplr.com/view/3491/convert-php-array-to-xml-or-simple-xml-object-if-you-wish/ | |
* | |
* @param array $data | |
* @param string $rootNodeName - what you want the root node to be - defaultsto data. | |
* @param SimpleXMLElement $xml - should only be used recursively |
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
function slug($str) | |
{ | |
$str = strtolower(trim($str)); | |
$str = preg_replace('/[^a-z0-9-]/', '-', $str); | |
$str = preg_replace('/-+/', "-", $str); | |
return $str; | |
} |
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
//from http://codesnippets.joyent.com/posts/show/959 | |
function close_dangling_tags($html){ | |
#put all opened tags into an array | |
preg_match_all("#<([a-z]+)( .*)?(?!/)>#iU",$html,$result); | |
$openedtags=$result[1]; | |
#put all closed tags into an array | |
preg_match_all("#</([a-z]+)>#iU",$html,$result); | |
$closedtags=$result[1]; | |
$len_opened = count($openedtags); |
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
function xmlEntities($string, $specialchars = false) { | |
$translationTable = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES); | |
foreach ($translationTable as $char => $entity) { | |
$from[] = $entity; | |
$to[] = '&#'.ord($char).';'; | |
} | |
//convert special characters &, ", ', <, > to html entities | |
if ($specialchars) { | |
$string = htmlspecialchars($string); |
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
function feedFilter($query) { | |
if ($query->is_feed) { | |
add_filter('rss2_item', 'feedContentFilter'); | |
} | |
return $query; | |
} | |
add_filter('pre_get_posts','feedFilter'); | |
function feedContentFilter($item) { | |