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
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 / 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"
@Dynom
Dynom / shiftin.php
Last active December 12, 2015 09:49
<?php
/**
* @author Mark van der Velden <[email protected]>
*/
/*
* Given, the following specification:
* - part 1, 40 bits wide -- a number between 0 - 1099511627775
* - part 2, 5 bits wide -- a number between 0 - 31
* - part 3, 9 bits wide -- a number between 0 - 511
@Dynom
Dynom / gist:5003750
Last active December 14, 2015 01:09
Obtaining various fractions of time, using the microtime() function
<?php
$time = microtime(true);
$seconds = (int) $time;
$milliseconds = (int) ($time * 1000);
$microseconds = (int) ($time * 1000000);
$nanoseconds = (int) ($time * 1000000000);
echo "seconds : $seconds\n"
@Dynom
Dynom / curie-example.hal.json
Last active December 14, 2015 22:39
Dealing with root-level curies in the HAL specification. This example is a modified version of the one mentioned on: http://stateless.co/hal_specification.html This example introduces a root-level _links definition with CURIE definitions. These definitions must be available in nested attributes, with the option to override a CURIE definition, wi…
{
"_links": {
"api-root:self": { "href": "orders" },
"api-root:next": { "href": "orders?page=2" },
"api-root:find": { "href": "orders{?id}", "templated": true },
"api-root:admin": [
{ "href": "admins/2", "title": "Fred" },
{ "href": "admins/5", "title": "Kate" }
],
"_curies" : [
@Dynom
Dynom / PRNG-test.php
Created March 31, 2013 12:44
Result of a run from the POC-PRNG-test/PRNG-test.php script, using openssl_random_pseudo_bytes(32). Goal of the test is to measure entropy exhaustion.
<?php
/**
* This script will generate a bunch of random data to test the exhaustion of kernel entropy.
*
* @author Mark van der Velden <[email protected]>
*
*
* Entropy can be checked at: /proc/sys/kernel/random/entropy_avail
*
* Tools like RND-tools can help keep the entropy above acceptable ranges. While this doesn`t (necessarily) improve
@Dynom
Dynom / file-bucket-strategy.php
Created April 10, 2013 07:50
Calculating a uniform distribution with respect to file-system limitation's (files/sub-directories per directory)
<?php
$networkEID = '0b3fe...a';
$fileEID = 'af4e0...f'
// e.g.: 19c679c10770acc216c26045cc5406c8155
$largeNumber = hash("sha1", $fileEID);
// Converting from base-16 to base-13
$hash = gmp_strval(gmp_init($largeNumber, 16), 13);