Skip to content

Instantly share code, notes, and snippets.

CREATE TABLE db.broken_table (
text_field text,
integer_field int,
another_text_field text,
date timestamp,
some_random_text text,
PRIMARY KEY ((text_field, integer_field, another_text_field), date)
) WITH CLUSTERING ORDER BY (date ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
@iwankgb
iwankgb / yield-from.php
Created October 26, 2015 08:21
Generator with subgenerator
<?php
$generatorWithTwoWayCommunication = function()
{
$randomValue = mt_rand();
yield $randomValue;
$receivedFromOuterSpace = yield;
$returnValue = yield from subGenerator($receivedFromOuterSpace, $randomValue);
return $returnValue;
};
@iwankgb
iwankgb / yield.php
Created October 26, 2015 07:23
Single generator
<?php
$generatorWithTwoWayCommunication = function()
{
$randomValue = mt_rand();
yield $randomValue;
$receivedFromOuterSpace = yield;
yield $receivedFromOuterSpace * $receivedFromOuterSpace;
return $receivedFromOuterSpace * $randomValue;
};
<?php
/*
* Wykorzystując Illuminate\Database\Query\Builder wyciągam dane z bazy
*/
$result = \DB::table('a')->join('b', 'a.id', '=', 'b.a_id')->where('b.id', 1)->get();
/*
* Po tej operacji będę miał w garści tablicę instancji stdClass (albowiem ten akurat builder nie wie nic o modelu)
* w związku z tym hydruję model i iteruję po wyniku
*/
@iwankgb
iwankgb / main.hh
Last active August 29, 2015 14:07
<?hh //strict
function main(): int {
//array_shift($args);
//var_dump($args);
/*$input = Vector{};
foreach ($args->items() as $url) {
$input->add(fetch_url($url));
}*/
//var_dump($input);