Skip to content

Instantly share code, notes, and snippets.

View Dynom's full-sized avatar
👋
Hi, how are you today!

Mark van der Velden Dynom

👋
Hi, how are you today!
View GitHub Profile
<?php
$scheduler = new Scheduler();
$batch = new Batch(new BatchContext(/* ... */), new ThrottleBatchStrategy());
// Add jobs
$batch->addJob(new FooJob( new JobContext() ));
@Dynom
Dynom / gist:9618999
Created March 18, 2014 12:19
Redis unexpected behaviour when enabling AOF after the fact.
Steps to reproduce:
# Make sure that in your redis.conf:
appendonly no
# Also make sure that, in your redis.conf:
dbfilename FOO-dump.rdb
save "900 1"
save "300 10"
save "60 10000"
<?php
$roundingInMinutes = 2;
$roundingInSeconds = ($roundingInMinutes * 60);
$t = time();
$rounded = ($t - ($t % $roundingInSeconds));
@Dynom
Dynom / calculate-encryption-time.php
Created May 30, 2014 08:10
A snippet that will calculate the work/cost factor of encrypting. Based on a number in seconds it suggest a cost factor
/**
* This code will benchmark your server to determine how high of a "cost" you
* can afford. You want to set the highest cost that you can without slowing
* down your server too much. 10 is a good baseline, and more is good if your
* servers are fast enough.
*
* Obviously You should run this on the server that will be encrypting..
*/
// What is the maximum time, your server should spend on encrypting?
space: function() {
var rad = ((this.rotation-90) * Math.PI)/180,
dx = 10 * Math.cos(rad),
dy = 10 * Math.sin(rad);
var sprite = Ext.getCmp('theShip').surface.add({
type: 'path',
stroke: 'green',
@Dynom
Dynom / composer.json
Created April 20, 2012 19:42
Series of files involved in the composer.phar stall
{
"require": {
"monolog/monolog": "1.0.*",
"guzzle/guzzle": "2.2.*",
"jms/serializer-bundle": "*",
"jms/metadata" : "*",
"twig/twig": "1.6.5",
"predis/predis": "0.7.2",
"doctrine/orm": "2.2.2",
"doctrine/common" : "2.2.2",
Catchable fatal error: Argument 1 passed to Zend_Controller_Action::__construct() must be an instance of Zend_Controller_Request_Abstract, none given, called in /mnt/hgfs/XX/vendor/Zend/Application/Resource/Frontcontroller.php on line 117 and defined in /mnt/hgfs/XX/vendor/Zend/Controller/Action.php on line 127
Call Stack:
0.0006 634352 1. {main}() /mnt/hgfs/XX/api/sally/public/index.php:0
0.0243 2038656 2. Zend_Application->bootstrap() /mnt/hgfs/XX/api/sally/public/index.php:12
0.0243 2038704 3. Zend_Application_Bootstrap_BootstrapAbstract->bootstrap() /mnt/hgfs/XX/vendor/Zend/Application.php:355
0.0243 2038704 4. Zend_Application_Bootstrap_BootstrapAbstract->_bootstrap() /mnt/hgfs/XX/vendor/Zend/Application/Bootstrap/BootstrapAbstract.php:586
0.0965 7508232 5. Zend_Application_Bootstrap_BootstrapAbstract->_executeResource() /mnt/hgfs/XX/vendor/Zend/Application/Bootstrap/BootstrapAbstract.php:626
0.0965 7508464 6. Zend_Application_Resource_Frontcontroll
@Dynom
Dynom / psr-autoloader.php
Created October 16, 2012 14:23
psr-autoloader.php
<?php
spl_autoload_register(
function ($className)
{
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strripos($className, '\\')) {
@Dynom
Dynom / gist:0e6ca1917bd9dc8cca8e
Created November 8, 2015 14:53
Git on OSX committing a case change in the fileame.
[/tmp/case]
mark@Dymek:$ git init
Initialized empty Git repository in /private/tmp/case/.git/
[/tmp/case] (master)
mark@Dymek:$ touch foo
[/tmp/case] (master)
mark@Dymek:$ git add foo
@Dynom
Dynom / runMigration.sh
Created January 2, 2013 16:12
This current Doctrine2 migrations shell wrapper fails, with the following message: "The specified connection file is a valid file", when run like this: ./bin/runMigrations.sh migrations:status The message is a typo, the actual message is about the connection file being NOT valid. When I paste the result (from the debug feedback, at the bottom of…
#!/usr/bin/env bash
# The arguments
ARGS="$@";
PHP_EXEC="$( which php )"
# TRYING to obtain the path we're located in.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
EXECUTABLE="$DIR/../tools/migrations/doctrine-migrations.phar"