(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
<?php | |
/* | |
* Chunk through result set and output as CSV file in browser. | |
*/ | |
function outputCSV($columns, $query, $chunkSize = 200) { | |
header("Content-type: text/csv"); | |
header("Content-Disposition: attachment; filename='export-" . date("YmdHis") . ".csv"); | |
header("Pragma: no-cache"); | |
header("Expires: 0"); | |
<?php | |
/** | |
* i changed class name as mPDO because, give me an error | |
* | |
* " Fatal error: Cannot redeclare class pdo. If this code worked without the Zend Optimizer+, | |
* please set zend_optimizerplus.dups_fix=1 in your php.ini " | |
*/ | |
class Mpdo | |
{ |
function *fibonacci(n) { | |
const infinite = !n && n !== 0; | |
let current = 0; | |
let next = 1; | |
while (infinite || n--) { | |
yield current; | |
[current, next] = [next, current + next]; | |
} | |
} |
<?php | |
// Greatest Common Divisor and Least Common Multiple | |
function lcm_arr($items){ | |
// Input: An Array of numbers | |
// Output: The LCM of the numbers | |
while(2 <= count($items)){ | |
array_push($items, lcm(array_shift($items), array_shift($items))); | |
} |
The Github doesn't provide country code for Brazil (+55). To add this option, just run the code below in your console. The option Brazil +55
will be the first on the list, already selected:
🇧🇷 [pt-BR]
<?php | |
namespace App\Console; | |
use App\Console\Commands\StopQueueListeners; | |
use Illuminate\Console\Scheduling\Schedule; | |
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; | |
class Kernel extends ConsoleKernel | |
{ |
<?php | |
namespace App\ActiveRecord; | |
class PostRepository | |
{ | |
private $cache; | |
public function __construct(Cache $cache) | |
{ | |
// Any set() / get() cache implementation. |
#Understanding closures, callbacks and promises
For a code newbie like myself, callbacks, closures and promises are scary JavaScript concepts.
10 months into my full-time dev career, and I would struggle to explain these words to a peer.
So I decided it was time to face my fears, and try to get my head around each concept.
Here are the notes from my initial reading. I'll continue to refine them as my understanding improves.
This guide assumes you have the emmet
and language-babel
packages already installed in Atom
keymap.cson
file by clicking on Atom -> Keymap…
in the menu bar'atom-text-editor[data-grammar~="jsx"]:not([mini])':