Skip to content

Instantly share code, notes, and snippets.

View davemfletcher's full-sized avatar

Dave Fletcher davemfletcher

  • Whangarei, New Zealand
View GitHub Profile
@davemfletcher
davemfletcher / Program.cs
Created January 9, 2016 18:34 — forked from DanielSWolf/Program.cs
Console progress bar. Code is under the MIT License: http://opensource.org/licenses/MIT
using System;
using System.Threading;
static class Program {
static void Main() {
Console.Write("Performing some task... ");
using (var progress = new ProgressBar()) {
for (int i = 0; i <= 100; i++) {
progress.Report((double) i / 100);

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@davemfletcher
davemfletcher / pdfCrowdDemo
Last active December 15, 2015 05:39
pdfCrowd demo
<html>
<body>
<?php
require 'pdfcrowd.php';
try
{
if($_SERVER['REQUEST_METHOD'] == 'POST') {
// create an API client instance
$client = new Pdfcrowd("XX", "XXXXXXXXXXXXXXXXXXXXXXXXX");
<?php
/**
* Simple wrapper around the
* PHPUnit assertion library.
*
* Should::equal(21, $age);
* Should::beGreaterThan(20, $age);
*/
class Should extends PHPUnit_Framework_Assert {
<?php
// ...
public function testProtected()
{
$dateFormatter = new DateFormatter;
$class = new \ReflectionClass('DateFormatter');
@davemfletcher
davemfletcher / html: starter page
Last active December 14, 2015 04:28
html: starter page
<!doctype html>
<html>
<head>
<title></title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
@davemfletcher
davemfletcher / gist:5025665
Created February 24, 2013 21:16
Javascript: sexy pubsub
var o = $( {} );
$.subscribe = o.on.bind(o);
$.unscribe = o.off.bind(o);
$.publish = o.trigger.bind(o);
@davemfletcher
davemfletcher / php: test
Created February 24, 2013 01:40
Code snippet for php test method
<snippet>
<content><![CDATA[
public function ${1:MethodName}_${2:StateUnderTest}_${3:ExpectedBehavior}()
{
${4: // assertions}
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>test</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->