Skip to content

Instantly share code, notes, and snippets.

View matchdav's full-sized avatar

Matthew Davidson matchdav

View GitHub Profile
@matchdav
matchdav / taxmeta.class.php
Created August 9, 2012 20:50 — forked from jonathonbyrdziak/taxmeta.class.php
Taxonomy Metaboxes, allows you to create additional taxonomy metas, including images.
<?php
/**
* @Author Anonymous
* @link http://www.redrokk.com
* @Package Wordpress
* @SubPackage RedRokk Library
* @copyright Copyright (C) 2011+ Redrokk Interactive Media
*
* @version 2.0
*/
@matchdav
matchdav / check4assignments.py
Created September 22, 2012 18:08
Uvic - CSC 326 Algorithms - check for posted assignments and send them by email.
import commands
import re
#I wrote this script to check whether our Uvic CSC 326 assignments are posted.
#That's because our instructor can't be bothered to let us know when he posts them.
#I suggest using cron to schedule it every 15 mins on your server
email = "[email protected]"
def do_mailout(email, filename, url):
@matchdav
matchdav / ko-deferred-binding.html
Last active August 29, 2015 14:03
How to defer a knockout binding.
<html>
<head>
<title></title>
</head>
<body>
<div id="bindme">
<p data-bind="text:prop"></p>
</div>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/knockout/3.1.0/knockout-min.js"></script>
@matchdav
matchdav / index.js
Last active August 29, 2015 14:06
requirebin sketch
var Vue = require('vue'),
Mustache = require('mustache'),
_ = require('lodash');
var obj = {
name:'Roger',
species:'rabbit',
mood:'grumpy'
};
@matchdav
matchdav / index.js
Last active August 29, 2015 14:18
requirebin sketch
var Backbone = require('backbone'),
rivets = require('rivets'),
Model = Backbone.Model,
View = Backbone.View;
var $ = Backbone.$ = require('jquery');
var a = new Model({});

Keybase proof

I hereby claim:

  • I am matchdav on github.
  • I am mcd (https://keybase.io/mcd) on keybase.
  • I have a public key whose fingerprint is 753C 1FAD A323 C272 B6D7 D816 C8C4 D7CF 5170 A137

To claim this, I am signing this object:

@matchdav
matchdav / index.js
Created July 6, 2015 19:28
requirebin sketch
var $ = require('jquery');
var Backbone = require('backbone');
window.jQuery = $;
var _ = require('lodash'),
rivets = require('rivets');
rivets.adapters[':'] = {
observe: function(obj, keypath, callback) {
obj.on('change:' + keypath, callback)

We want to create a realistic illustration of how async generators can deal with timing issues in ad rendering.

Here we're considering the example of multiple ad slots for the same provider in a scrolling feed. In our example, a Repository can only initiate an ad fetch to populate the AdSlot component when the AdContainer component comes into view. What we want is an observer to emit a visible event from the AdContainer that signals the async iterator to emit the next ad index, which we need because the ad fetches are paginated. On the other end of this chain, when the AdSlot is rendered (on the visible AdContainer), we want to emit a viewed event with the correct ad slot data. This pattern effectively decouples the UI interaction (scrolling) from the data logic (fetching), creating a clean "pull-based" system from "push-based" UI events.

Here is a complete, runnable Node.js example that simulates this ad-loading flow.


The Simulation Setup