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 | |
function binarySearchRecursion($array, $find, $left, $right) | |
{ | |
if ($left > $right) { | |
return -1; | |
} | |
$middle = floor( ($left + $right) / 2 ); | |
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 | |
function interpolationSearch($list, $find) | |
{ | |
$low = 0; | |
$high = count($list) - 1; | |
while ($low <= $high && $find >= $list[$low] && $find <= $list[$high]) { | |
$pos = floor($low + (($high-$low) / | |
($list[$high]-$list[$low])) * ($find - $list[$low])); | |
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 | |
function binarySearchIterative($list, $find) | |
{ | |
$left = key($list); | |
$right = count($list) -1; | |
while ($left <= $right) { | |
$mid = floor(($left + $right) / 2); | |
if ($find == $list[$mid]) { | |
return $mid; |
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 | |
function JumpSearch($list, $find) | |
{ | |
$len = count($list) ; | |
$slice = floor(sqrt($len)); | |
$prev = 0; | |
while ($list[min($slice, $len)] < $find || $prev >= $len) { | |
$prev = $slice; | |
$slice += floor(sqrt($len)); |
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 | |
function binarySearchRecursion($array, $find, $left, $right) | |
{ | |
if ($left > $right) { | |
return -1; | |
} | |
$middle = floor( ($left + $right) / 2 ); | |
if ($find === $array[$middle]) { |
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
rm -r .git | |
git init | |
(create files) | |
git add -A | |
git commit -m 'Initial commit' | |
git remote add origin <url> | |
git push --force --set-upstream origin master |
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
UPDATE wp_users SET user_pass = MD5('mypwd') WHERE ID=1 LIMIT 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
//adding category support to pages | |
add_action('admin_init', 'ga_register_tax_for_pages'); | |
function ga_register_tax_for_pages() { | |
register_taxonomy_for_object_type('category', 'page'); | |
add_post_type_support('page', 'category'); | |
} |
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
add_filter('pre_get_posts','exclude_category'); | |
//exclude uncategorized category from rss | |
function exclude_category($query) { | |
if ( $query->is_feed ) { | |
$category_id = -1 * get_cat_ID('Uncategorized'); | |
$query->set('cat', $category_id); | |
} | |
return $query; | |
} |
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 sc_profile() { | |
//only if we are debugging | |
if (WP_DEBUG === true) { | |
//only for administrators | |
if (current_user_can('level_10')) { | |
printf("%s queries in %s seconds.", get_num_queries(), timer_stop(0,3)); | |
//show queries |
NewerOlder