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
/** | |
* Find how often words appear in a string, optionally | |
* limiting to ones that occur with a given frequency. | |
* | |
* @param {String} searchString The sentence to search on. | |
* @param {Integer} frequency The frequency at which you want to find words with. | |
* @param {Boolean} caseSensitive Whether to use case sensitive searching. | |
* @param {Booolean} stripPunctuation If punctuation should be removed before parsing. | |
*/ | |
var wordFrequency = function( searchString, frequency, caseSensitive, stripPunctuation ) { |
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
/** | |
* Translate a path to match host OS | |
* | |
* @param string $path Path or URI to be translated | |
* @return string Translated path | |
*/ | |
function translate_UNC_delimiters( $path ) { | |
$path = str_replace( '\\', DIRECTORY_SEPARATOR, $path ); | |
return str_replace( '/', DIRECTORY_SEPARATOR, $path ); | |
} |
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
/** | |
* Get a page's ID from it's slug | |
* | |
* @param string $slug Page slug to search on | |
* @return null Empty on error | |
* @return int Page ID | |
*/ | |
function get_page_ID_by_slug( $slug ) { | |
$page = get_page_by_path( $slug ); | |
if ( $page ) { |
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
// Get a file's extension | |
$ext = array_pop( explode( '.', $fileName ) ); | |
// Get a file's name without extension | |
$name = array_shift( explode( '.', $fileName ) ); |
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
<?php | |
// Determine if there is an equal number of parentheses | |
// and if they balance logically, i.e. | |
// ()()) = Bad (trailing ")") | |
// (())()() = GOOD | |
// )()()(()) = BAD (leading ")") | |
function is_balanced( $s ) { | |
// Keep track of number of open parens |
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
<?php | |
// Only allow this script to be run via the command line | |
if ( strtoupper(PHP_SAPI) !== 'CLI' ) { | |
header( 'Content-type: text/plain' ); | |
echo 'This script can only be run via the command line.', | |
PHP_EOL, 'Usage: php -f ', | |
array_pop(explode('/', $_SERVER['SCRIPT_NAME'])); | |
exit( 1 ); | |
} |
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
SELECT option_value | |
FROM wp_options | |
WHERE option_name = "home" | |
OR option_name = "siteurl" | |
LIMIT 1; | |
UPDATE wp_options | |
SET option_value = "http://newlink" | |
WHERE option_name IN ("home", "siteurl"); |
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
var print_r=function(x,max,sep,l){l=l||0;max=max||10;sep=sep||' ';if(l>max){return"[WARNING: Too much recursion]\n"}var i,r='',t=typeof x,tab='';if(x===null){r+="(null)\n"}else if(t=='object'){l++;for(i=0;i<l;i++){tab+=sep}if(x&&x.length){t='array'}r+='('+t+") :\n";for(i in x){try{r+=tab+'['+i+'] : '+print_r(x[i],max,sep,(l+1))}catch(e){return"[ERROR: "+e+"]\n"}}}else{if(t=='string'){if(x==''){x='(empty)'}}r+='('+t+') '+x+"\n"}return r};var_dump=print_r; |
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
<?php | |
// Don't allow PHP to stop after global timeout setting | |
set_time_limit( 0 ); | |
// Increase memory limit | |
ini_set( 'memory_limit', '1024M' ); | |
// Remove output buffering | |
while ( ob_get_level() ) ob_end_clean(); |
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
PS1="\w \`if [ \$? = 0 ]; then echo -e '\[\e[01;32m\]\n^_^'; else echo -e '\[\e[01;31m\]\n>_<'; fi\` \[\e]0;\w\a\] \[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\\$\n" |
OlderNewer