Skip to content

Instantly share code, notes, and snippets.

View jmikola's full-sized avatar
💭
🌭

Jeremy Mikola jmikola

💭
🌭
View GitHub Profile
@jmikola
jmikola / build_php.sh
Last active March 10, 2017 06:17
Building and managing multiple versions of PHP
#!/bin/sh
set -e
base_install_dir="$HOME/bin/php-bin"
download_dir="$HOME/bin/php-cache"
php_tarball="" # set after calling get_php()
debug() {
echo "===> $1"
}
<?php
namespace Doctrine\ODM\MongoDB\Tests;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
class GH895Test extends \Doctrine\ODM\MongoDB\Tests\BaseTest
{
public function testQueryWithSelectShouldRefreshDocument()
{
<?php
namespace Doctrine\ODM\MongoDB\Tests;
use Doctrine\Common\EventSubscriber;
use Doctrine\ODM\MongoDB\Events;
use Doctrine\ODM\MongoDB\Event\PreUpdateEventArgs;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
class SO23927996Test extends BaseTest
@jmikola
jmikola / transcript.txt
Created May 22, 2014 16:58
php[tek] ReactPHP chat server
$ telnet 192.168.13.14 2014
Trying 192.168.13.14...
Connected to 192.168.13.14.
Escape character is '^]'.
hello
192.168.12.221: ohai
192.168.13.89: GET / HTTP/1.1
Host: 192.168.13.14:2014
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
@jmikola
jmikola / transcript.txt
Created May 15, 2014 18:56
Laracon ReactPHP chat server
217.249: 10.10.218.139: 10.10.217.247: 10.10.217.232: 10.10.218.16: 10.10.219.203: 10.10.217.101: 10.10.217.212: 10.10.217.249: 10.10.217.249: 10.10.217.162: 10.10.218.74: 10.10.218.170: 10.10.218.178: 10.10.219.196: 10.10.218.249: 10.10.218.60: 10.10.218.70: 10.10.218.154: 10.10.217.197: 10.10.218.81: 10.10.218.5: 10.10.218.128: 10.10.217.173: 10.10.218.149: 10.10.219.147: 10.10.217.249: 10.10.217.186: 10.10.217.232: 10.10.218.168: 10.10.218.174: 10.10.218.191: 10.10.217.212: 10.10.218.16: 10.10.218.139: 10.10.219.203: 10.10.218.193: 10.10.217.101: 10.10.217.247: 10.10.217.173: 10.10.218.168: 10.10.218.74: 10.10.218.5: 10.10.218.249: 10.10.218.170: 10.10.218.149: 10.10.219.196: 10.10.218.178: 10.10.218.70: 10.10.217.197: 10.10.218.60: 10.10.218.154: 10.10.218.128: 10.10.218.81: 10.10.219.147: 10.10.218.191: 10.10.218.174: 10.10.218.139: 10.10.218.193: 10.10.217.249: 10.10.217.186: 10.10.217.162: 10.10.217.212: 10.10.217.101: 10.10.218.16: 10.10.217.232: 10.10.217.247: 10.10.218.5: :q
10.10.219.203: 10.10.
@jmikola
jmikola / readme.md
Last active January 2, 2016 10:19
Upserting identifier-only documents in MongoDB

MongoDB 2.4.8

> db.foo.update({_id:1}, {$set: {}}, true); db.getLastErrorObj();
{
	"updatedExisting" : false,
	"n" : 1,
	"connectionId" : 1,
	"err" : null,
	"ok" : 1
@jmikola
jmikola / make_php.sh
Last active January 4, 2022 22:50
Build scripts for multiple PHP versions
make_php () {
# Directory for PHP git repo (for git-new-workdir)
phpsrcdir="/home/jmikola/workspace/php/php-src"
# Git branch for this build (for git-new-workdir)
phpbranch="PHP-$1"
# Where compiled builds should be installed
installdir="/home/jmikola/bin/php"
@jmikola
jmikola / README.md
Last active September 17, 2018 16:23
MongoDB schema comparison: large objects vs. hash buckets

Original Schema

The original-insert.php script creates 2,000 documents with the following schema:

{
    "_id" : ObjectId("52b3815de84df102428b4567"),
    "appver" : NumberLong(123456),
    "deploytype" : "production",
 "g" : NumberLong(123456),
@jmikola
jmikola / make_php.sh
Last active December 21, 2015 14:49
Manage multiple PHP development versions
make_php () {
# Directory for PHP git repo (for git-new-workdir)
phpsrcdir="$HOME/workspace/php/php-src"
# Git branch for this build (for git-new-workdir)
phpbranch="PHP-$1"
# Directory where PHP builds will be stored
buildsdir="$HOME/workspace/php/builds"
@jmikola
jmikola / tailable-cursor.php
Created May 3, 2013 16:38
Testing awaitData and tailable cursors against mongod
$m = new MongoClient();
$m->test->foo->drop();
$m->test->createCollection('foo', ['capped' => true, 'size' => 67108864]);
$c = $m->test->foo;
$c->insert(['x' => 1]);
$cursor = $c->find()->awaitData()->tailable();
while (1) {
if (!$cursor->hasNext()) {
if ($cursor->dead()) {