Skip to content

Instantly share code, notes, and snippets.

Dean Radcliffe deanius

View GitHub Profile
@deanius
deanius / YouTubeEventHandling.js
Last active Sep 8, 2018 — forked from jshaw/YouTubeEventHandling.js
YouTube Video Playing and Finished Event Handling
View YouTubeEventHandling.js
let player
let onYouTubeIframeAPIReady
const youTubeReady = new Promise(resolve => {
var tag = document.createElement('script');
tag.src = "//www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
@deanius
deanius / background.js
Created Aug 16, 2018 — forked from omarstreak/background.js
Chrome API Extension
View background.js
//oauth2 auth
chrome.identity.getAuthToken(
{'interactive': true},
function(){
//load Google's javascript client libraries
window.gapi_onload = authorize;
loadScript('https://apis.google.com/js/client.js');
}
);
View words.clj
(defn score
[word]
(let [wc (count word)
uc (count (into #{} (map identity (clojure.string/lower-case word))))]
{:word word :score (if (= wc uc) wc 0)}))
(defn winner
[words]
(let [m (group-by :score (map score words))]
(m (apply max (keys m)))))
View meteor-subscription-promise-ready.js
Template.restaurant.onCreated(function() {
this.restaurant = new ReactiveVar()
this.ready = new ReactiveVar( false )
this.subscribe( 'Restaurant', [ FlowRouter.getParam('restaurantId') ] )
.readyPromise()
.then(function() {
this.restaurant.set( Restaurant.findOne() )
this.ready.set( true )
}.bind(this))
@deanius
deanius / callback_contract.md
Last active Aug 29, 2015 — forked from CrabDude/callback_contract.md
Node.js Callback Contract
View callback_contract.md

#callback/errback contract

  1. Function that takes 2 arguments
    • first argument is an error
    • second argument is the result
    • Never pass both
    • error should be instanceof Error
  2. Must never excecute on the same tick of the event loop
  3. Must be passed as last argument to function
  4. Return value is ignored
  5. Must not throw / must pass resulting errors
View ibm_cb
<style>
#foot {padding-bottom:20px;}
.two_column #customer_service_links {
height: inherit;
}
.tooltip{
display: inline;
position: relative;
}
You can’t perform that action at this time.