There are many reasons why you might not want to have Chef Server in your deployment path. Or, as this example shows, you don’t want to host your own Chef Server. We instead use Hosted Chef, but purely as a…
There are many reasons why you might not want to have Chef Server in your deployment path. Or, as this example shows, you don’t want to host your own Chef Server. We instead use Hosted Chef, but purely as a…
Sometimes I need to download big ISOs or other large files onto my work laptop, but GlobalProtect forces me to do so via the VPN. In order to speed things up and use my local network connection, I need to…
I’m a big user of Chef, but was bummed when I couldn’t find any resolver information in Ohai data. I needed to make some changes to an nginx config to use resolver, but wanted to use the resolver that’s already…
1 |
sudo yum install php-pecl-xhprof graphviz |
You’ll now need to have this module loaded in PHP; this varies depending on which handler you use:
1 2 |
sudo service restart php-fpm # if you're using PHP-FPM/FastCGI sudo service restart httpd # if you're using mod_php |
cd into wp-content/plugins
1 |
git clone https://github.com/Upstatement/xhprof-for-wordpress.git |
In wp-config.php:
1 |
define('PROFILE', true); |
In your admin dashboard, enable “WP XHProf Profiler” from the plugins section.…
I love Apache. I love nginx. I love them when they’re alone, and I love them when they’re together. But when they’re together, sometimes they don’t play nice. When behind a proxy, Apache will use the proxy’s IP address in…
Vagrant is awesome, but there are times where you might need to specify redundant/alternative URLs in a Vagrantfile. This could be a failover type scenario, although in my case, I needed it to give external developers access to our Vagrantbox,…
When working on a WordPress project recently where speed was a huge concern, I relied on everyone’s favorite reverse proxy, Nginx, to offload the work required by Apache to serve pages. This worked great, but an issue I encountered was…
This is a simple yet powerful way to get Bing’s Site Search API working on your site in PHP. Simply update the $config variables below and you’ll be good to go.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
<?php define('TITLE', 'Search Results'); include('header.php'); $config['appid'] = "01234567890"; // change this $config['search_domains'] = array("domain1.com", "domain2.com"); $config['results_per_page'] = 20; $url = "http://$_SERVER[HTTP_HOST]$_SERVER[PHP_SELF]"; ?> <?php echo (isset($_REQUEST['q']) ? "<h1>Search Results</h1>" : "<h1>Search</h1>"); ?> <form method="get"> <div style="text-align:right"> <input type="text" id="q" name="q" value="<?php echo (isset($_REQUEST['q']) ? $_REQUEST['q'] : 'Search...'); ?>"/> <input type="submit" value="Search" name="submit" id="searchButton" /> </div> </form> <?php if (isset($_REQUEST ['q'])) { $query = htmlentities($_REQUEST ['q']); if (strlen($query) < 1) echo "You didn't type anything!"; else { if (isset($_REQUEST ['page'])) { $page = htmlentities($_REQUEST ['page']); $offset = (($page - 1) * $config['results_per_page']); } else $offset = 0; $result = "http://api.search.live.net/json.aspx?Appid={$config['appid']}&sources=web"; $result .= "&query=" . urlencode("site:" . implode(" OR site:", $config['search_domains']) . " " . $query); $result .= "&Web.Count={$config['results_per_page']}&Web.Offset=$offset"; //echo $result; $result = file_get_contents($result); $result = json_decode($result); echo('<ul ID="resultList">'); foreach ($result->SearchResponse->Web->Results as $value) { echo('<li class="resultlistitem"><a href="' . $value->Url . '">'); echo('<h3>' . $value->Title . '</h3></a>'); echo('<p>' . $value->Description . '</p>'); } echo("</ul>"); // echo("<pre>"); // print_r($result); // echo("</pre>"); $results = $result->SearchResponse->Web->Total > 1000 ? 1000 : $result->SearchResponse->Web->Total; if ($results > 0) echo $results . " results <br />\n"; else echo "Sorry, no results to display. <br />\n"; $pages = (int) ($results / $config['results_per_page']); // echo "$pages pages <br />\n"; // pagination // echo "Page #s:<br />"; for ($i = 1; $i <= $pages; $i++) { echo "<a href=$url?q=$query&page=$i>$i</a> "; } } } ?> <?php include('footer.php'); ?> |
This is a quick and simple one, but I admittedly started off with a for loop before coming across array_multisort. This turned out to be very useful for an application I’m working on.
1 2 3 4 5 6 7 8 |
// example echo "Google's lowest MX is: " . lowestmx("google.com"); function lowestmx($server) { getmxrr($server, &$mxhosts, &$weight); array_multisort($weight, $mxhosts); return $mxhosts[0]; } |
UPDATE: It was fun, but this proxy is no longer needed. You can connect directly to Yahoo! via IMAP with the following servers: imap.mail.yahoo.com port 993 (SSL) smtp.mail.yahoo.com port 465 (SSL) There are a few Yahoo! Mail IMAP proxies out there (YPOPS!,…
Recent Comments