Skip to content

Instantly share code, notes, and snippets.

View bzikarsky's full-sized avatar

Benjamin Zikarsky bzikarsky

View GitHub Profile
@bzikarsky
bzikarsky / mongo_session_bench.php
Created November 20, 2014 07:30
Benchmark session lifetime condition: Mongo vs PHP
<?php
$mongo = new MongoClient();
$db = $mongo->test;
$collection = $db->selectCollection('session');
$sessionCount = $argv[1];
$sampleCount = $argv[2];
$samples = [];
// Setup collection
@bzikarsky
bzikarsky / test.bash
Last active August 29, 2015 14:10
Test timezone behavior with PHP and Mongo
#!/bin/bash
DB="test"
COL="tz"
ZONES="London Berlin Istanbul"
DATE="2000-01-01"
echo "System timezone: $(date -R)"
echo ""
#!/bin/bash
DB="test"
COL="tz"
ZONES="London Berlin Istanbul"
DATE="2000-01-01"
echo "System timezone: $(date -R)"
echo ""
@bzikarsky
bzikarsky / example.php
Last active August 29, 2015 14:13
Resolvable generators
<?php
// this is our generator, dns\* and socket\* are assumed
// to be async functions returning promises
function read_data_from($hostname, $port) {
$ip = yield dns\resolve($hostname);
$socket = yield socket\connect($ip, $port);
echo yield socket\read(1024);
};
@bzikarsky
bzikarsky / check_oneplus_stock.bash
Created January 23, 2017 11:07
Desperate measures for ordering a OnePlus 3T )
#!/bin/bash
# Check for availability of a OnePlus stock item (405 == OnePlus 3T 128GB EU)
# and notify over pushover.net
#
# Background: https://www.oneplusstock.net/ revealed that you do not get
# an instant notification as soon as it goes back on stock...so this might
# help...
#