Skip to content

Instantly share code, notes, and snippets.

View jmikola's full-sized avatar
💭
🌭

Jeremy Mikola jmikola

💭
🌭
View GitHub Profile
@jmikola
jmikola / README.md
Last active February 3, 2023 18:58
Using gallery-dl to backup a Twitter account
@jmikola
jmikola / output.log
Created November 3, 2022 08:25
Change tracking using ext-mongodb's BSON API
$ php tracked_persistable.php
object(MongoDB\Examples\User)#29 (3) {
["name"]=>
string(7) "alcaeus"
["emails"]=>
object(MongoDB\Examples\TrackedBSONArray)#24 (0) {
}
["_id"]=>
object(MongoDB\BSON\ObjectId)#15 (1) {
["oid"]=>
@jmikola
jmikola / README.md
Last active June 24, 2022 15:58
Testing the PHP driver with Atlas failovers

Testing the PHP driver with Atlas failovers

Ping

The following was added to the URI for an Atlas 3.6 cluster and assigned to a $uri variable in the PHP script:

?serverSelectionTryOnce=false&serverSelectionTimeoutMS=15000
<?php
enum TimeUnit : string
{
case Nanos = 'ns';
case Micros = 'μs';
case Millis = 'ms';
}
class TimeUnitString
@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 / benchmark.php
Created May 29, 2012 18:19
Mongo indexing benchmark
<?php
$m = new Mongo();
$c = $m->test->foo;
$c->drop();
$a = microtime(true);
foreach (range(1,1000000) as $i) {
$c->insert(array('x' => $i));
}
@jmikola
jmikola / AggregatedTaggedServicesPass.php
Created January 18, 2011 20:35
Retrieving tagged services after the Symfony2 DIC has already been compiled
<?php
namespace OpenSky\Bundle\MainBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
class AggregatedTaggedServicesPass implements CompilerPassInterface
{
@jmikola
jmikola / FindInvalidReferencesCommand.php
Created July 27, 2012 21:47
Find invalid references among Doctrine MongoDB ODM documents
<?php
namespace Acme\FooBundle\Command;
use Doctrine\Common\Persistence\ManagerRegistry;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class FindInvalidReferencesCommand extends ContainerAwareCommand
@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 / example.php
Created October 4, 2017 16:22
PHPLIB mapReduce example
<?php
require_once 'vendor/autoload.php';
$client = new MongoDB\Client;
$collection = $client->selectCollection('test', 'mr_example');
$collection->drop();
$collection->insertMany([
['x' => 1, 'y' => 1],