Skip to content

Instantly share code, notes, and snippets.

View giorgiosironi's full-sized avatar

Giorgio Sironi giorgiosironi

View GitHub Profile
@giorgiosironi
giorgiosironi / gist:8012114
Created December 17, 2013 20:33
Constructor parameters
<?php
class Car
{
public function __toString()
{
return 'I am a car';
}
}
$ferrari = new Car(new Model("Ferrari"));
<?php
$mongo = new Mongo();
$widgets = $mongo->onebip->widgets;
for ($i = 0; $i < 5000; $i++) {
$value = rand();
$widgets->insert(['value' => $value]);
echo "Inserted $i!", PHP_EOL;
sleep(1);
}
@giorgiosironi
giorgiosironi / gist:7f5055c3fb3b7a4deeae
Created October 19, 2014 18:00
Using a trait to share test code for multiple implementations
trait RepositoryContract
{
public function testAdd() { ... }
public function testRemove() { ... }
}
class MongoDBRepositoryTest {
use RepositoryContract;
public function setUp()
{
@giorgiosironi
giorgiosironi / gist:84fe5d62acb7c0740891
Last active February 4, 2022 09:17
Fifty Quick Ideas to Improve your User Stories (Gojko Adzic) quotes
Effective teams with third party dependencies, or those that rely on external specialist knowledge, generally dedicate one or two people to investigate those dependencies a week or two before starting a story. The results of the investigations are a great starting point for the story analysis discussions. Some teams analyse stories twice as a group: once a week or two ahead of the iteration to collect open questions and focus the upfront investigation, and the second time just ahead of the iteration to communicate and agree on the details.
avoid feature requests. If you have only a short summary on a card, it must not be a solution without context. So, ‘How much potential cash is in blocked projects?’ is a valid summary, but a ‘Cash report’ isn’t.
Independent and valuable are often difficult to reconcile with small. The value of software is a vague and esoteric concept in the domain of business users, but task size is under the control of a delivery team, so many teams end up choosing size over value.
De
@giorgiosironi
giorgiosironi / gist:9012fd79a945c1433aa6
Last active August 29, 2015 14:23
Generating a random sequence of up to 100 natural numbers
Generator\seq(
Generator\nat(),
Generator\pos(100)
)
@giorgiosironi
giorgiosironi / gist:4d49638448e9c8ea63c0
Last active August 29, 2015 14:23
Verifying sort() over an input
sort($array);
for ($i = 0; $i < count($array) - 1; $i++) {
$this->assertTrue(
$array[$i] <= $array[$i+1],
"Array is not sorted: " . var_export($array, true)
);
}
@giorgiosironi
giorgiosironi / gist:4616671fafb3098a4369
Created June 14, 2015 12:14
bugged version of fromZeroBasedDayOfYear()
function fromZeroBasedDayOfYear($year, $dayOfYear)
{
return DateTime::createFromFormat(
'z Y H i s',
$dayOfYear . ' '. $year . ' 00 00 00',
new DateTimeZone("UTC")
);
}
@giorgiosironi
giorgiosironi / gist:4721aba8f1949cc3c938
Created June 14, 2015 12:17
Property-based testing fromZeroBasedDayOfYear()
$this->forAll(
Generator\int(2000, 2020),
Generator\int(0, 364),
Generator\int(0, 364)
)
->then(function($year, $dayOfYear, $anotherDayOfYear) {
$day = fromZeroBasedDayOfYear($year, $dayOfYear);
$anotherDay = fromZeroBasedDayOfYear($year, $anotherDayOfYear);
$this->assertEquals(
abs($dayOfYear - $anotherDayOfYear) * 86400,
@giorgiosironi
giorgiosironi / gist:8466d58df1793692005d
Created June 14, 2015 12:21
Results of property-based testing fromZeroBasedDayOfYear()
Time: 95 ms, Memory: 6.00Mb
There was 1 failure:
1) DateTest::testFromDayOfYearFactoryMethodRespectsDistanceBetweenDays
Days of the year 2016: 59, 0
2016-03-01T00:00:00+0000, 2016-01-01T00:00:00+0000
Failed asserting that 5184000 matches expected 5097600.
/home/giorgio/code/eris/examples/DateTest.php:53
@giorgiosironi
giorgiosironi / gist:7902f921593f7adc45b2
Created June 23, 2015 08:04
Feedback 1DK dashboard
- nella scheda Revenues é un po' controintuivo che non venga mostrata la linea rossa corrispondente alle Total Revenues ma solo quella verde (quella blu é a 0 nell'esempio, ok)
- mi piace la presenza di onError() nel codice generato, che propone di gestire esplicitamente il caso di errore
- molto forte l'android-1dk-example
- anche l'approccio alla documentazione molto dinamico
- in alto a destra ci sono due link che si aprono nel menu, User Profile e Settings, che portano a pagine vuote. Forse andrebbero nascosti se tanto sono vuoti?