Skip to content

Instantly share code, notes, and snippets.

View bjori's full-sized avatar

Hannes Magnusson bjori

  • Tallied
  • Danville, CA
View GitHub Profile
@bjori
bjori / profile.example.php
Created September 16, 2013 21:07
The MongoDB Profiling example, using the PHP Stream Notification API For more info, see: http://bjori.blogspot.com/2013/09/query-logging-and-profiling-in-mongodb.html
<?php
class MongoNotifications {
public $reqs = array();
/* Our callback function
* The prototype is define by the PHP Stream Notification system: http://php.net/stream_notification_callback
*/
function update($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max) {
switch($notification_code) {
@bjori
bjori / numbers
Created October 31, 2011 22:02
Parsing crazy telephone numbers
<?php
function filter_number($number) {
if (substr($number, 0, 2) == "00") {
$number = "+". (string)(float)$number;
}
$l = strlen($number);
$retval = array(0 => "");
$idx = 0;
for($n=0; $n<$l; $n++) {
switch($number[$n]) {