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 / 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]) {
@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) {
$ php -n -c php.ini it.php # PHP/5.3.27 ⮀ MongoDB/2.4.6
float(0.0030438899993896)
Took 0.0030439 to iterate 500 times over a cursor
@bjori
bjori / gist:8165044
Created December 28, 2013 22:28
Cycle through header using keyboard shortcuts
diff --git a/js/common.js b/js/common.js
index 97abbbd..63726bb 100755
--- a/js/common.js
+++ b/js/common.js
@@ -96,11 +96,37 @@ Mousetrap.bind("g n", function() {
});
Mousetrap.bind("j", function() {
var fixedheader = 50;
+ /* Doc page */
var node = $(".layout-menu .current");
@bjori
bjori / Ordered by count
Created February 5, 2014 19:16
@lists.php.net subscriber count, as of February 15th, 2014
self-approved - 69198
php-announce - 9367
php3 - 2790
php-kb - 2572
php-general - 2218
internals - 1328
php-db - 1321
php4beta - 1006
php-windows - 669
php-es - 620
@bjori
bjori / keybase.md
Created September 17, 2014 23:01
keybase.md

Keybase proof

I hereby claim:

  • I am bjori on github.
  • I am bjori (https://keybase.io/bjori) on keybase.
  • I have a public key whose fingerprint is 3630 EFAD 3539 834E A66F 38D9 CA1C DAD9 97A8 E347

To claim this, I am signing this object:

@bjori
bjori / rcnotes
Created November 11, 2014 21:21
MongoDB 1.6.0RC1 release notes
The 1.6.0 Release Candidate of the PHP driver for MongoDB has been released!
Right on the heals of the 1.5.8 maintenance release, this release brings full compatibility with the upcoming MongoDB 2.8.0 release.
Release Notes:
http://pecl.php.net/package-changelog.php?package=mongo&release=1.6.0RC1
Found an issue? Please report it:
https://github.com/mongodb/mongo-php-driver#bugs--feature-requests
ID Name Options Flags Description
-------------------------------------- ------------------------ --------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------ --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@bjori
bjori / PHONGO-SERVERS.json
Last active August 29, 2015 14:17
Example mongod server description for running the pecl/mongodb tests. It can also be generated by "make vm test-bootstrap"
{
"STANDALONE": "mongodb:\/\/192.168.112.10:2000",
"STANDALONE_SSL": "mongodb:\/\/192.168.112.10:2100",
"STANDALONE_AUTH": "mongodb:\/\/root:toor@192.168.112.10:2200\/?authSource=admin",
"STANDALONE_X509": "mongodb:\/\/C=US,ST=New York,L=New York City,O=MongoDB,OU=KernelUser,CN=client@192.168.112.10:2300\/?authSource=$external&authMechanism=MONGODB-X509",
"STANDALONE_PLAIN": "mongodb:\/\/root:toor@192.168.112.10:2400\/?authSource=admin",
"REPLICASET": "mongodb:\/\/192.168.112.10:3000,192.168.112.10:3001,192.168.112.10:3002\/?replicaSet=REPLICASET"
}
2015-03-31T10:13:50.250-0700 I REPL [conn4] replSetInitiate admin command received from client
2015-03-31T10:13:50.263-0700 E NETWORK [conn4] The server certificate does not match the host name 192.168.112.10
2015-03-31T10:13:50.263-0700 W NETWORK [conn4] could't check isSelf (192.168.112.10:3101) socket exception [CONNECT_ERROR] for
2015-03-31T10:13:50.271-0700 E NETWORK [conn4] The server certificate does not match the host name 192.168.112.10
2015-03-31T10:13:50.271-0700 W NETWORK [conn4] could't check isSelf (192.168.112.10:3102) socket exception [CONNECT_ERROR] for
2015-03-31T10:13:50.271-0700 I REPL [conn4] replSet replSetInitiate config object with 3 members parses ok
2015-03-31T10:13:50.282-0700 E NETWORK [ReplExecNetThread-0] The server certificate does not match the host name 192.168.112.10
2015-03-31T10:13:50.282-0700 W REPL [ReplicationExecutor] Failed to complete heartbeat request to 192.168.112.10:3101; Location9001 socket exception [CONNECT_ERROR] for
2015-03-31T10:13:50.282