Skip to content

Instantly share code, notes, and snippets.

Falsehoods programmers believe about prices

  1. You can store a price in a floating point variable.
  2. All currencies are subdivided in 1/100th units (like US dollar/cents, euro/eurocents etc.).
  3. All currencies are subdivided in decimal units (like dinar/fils)
  4. All currencies currently in circulation are subdivided in decimal units. (to exclude shillings, pennies) (counter-example: MGA)
  5. All currencies are subdivided. (counter-examples: KRW, COP, JPY... Or subdivisions can be deprecated.)
  6. Prices can't have more precision than the smaller sub-unit of the currency. (e.g. gas prices)
  7. For any currency you can have a price of 1. (ZWL)
  8. Every country has its own currency. (EUR is the best example, but also Franc CFA, etc.)
@vvasiloi
vvasiloi / ExampleFactoryDecoratorTrait.php
Last active November 17, 2020 12:26
Extract options when decorating an example factory. See example usage in ProductExampleFactory.php. #sylius #fixtures #example #factory
<?php
namespace App\Fixture\Factory;
use Symfony\Component\OptionsResolver\OptionsResolver;
trait ExampleFactoryDecoratorTrait
{
/**
* @param array $options
@vvasiloi
vvasiloi / BulkInsertQuery.php
Created May 31, 2018 17:11 — forked from gskema/BulkInsertQuery.php
PHP PDO / Doctrine DBAL bulk insert query
<?php
namespace YourApp\Repository\Query;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Schema\Identifier;
/**
* Class BulkInsertQuery
*
@vvasiloi
vvasiloi / gist:0e7b948828d9c62be3b41706df041c65
Created April 22, 2016 12:56 — forked from ckaklamanos/gist:448984aadd5897e2a8fc
CS Cart .gitignore for Addon development
# -----------------------------------------------------------------
# .gitignore for CS Cart theme and addon development
#
# By default all files are ignored. You'll need to whitelist
# any addons, folders, files you want to include in the repo.
#
# To ignore uncommitted changes in a file that is already tracked, use
# git update-index --assume-unchanged
#
# To stop tracking a file that is currently tracked, use