Skip to content

Instantly share code, notes, and snippets.

View deanrad's full-sized avatar
🎯
Staying On Target

Dean Radcliffe deanrad

🎯
Staying On Target
View GitHub Profile
@deanrad
deanrad / YouTubeEventHandling.js
Last active September 8, 2018 21:19 — forked from jshaw/YouTubeEventHandling.js
YouTube Video Playing and Finished Event Handling
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);
@deanrad
deanrad / background.js
Created August 16, 2018 14:05 — forked from omarstreak/background.js
Chrome API Extension
//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');
}
);
(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)))))
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))
@deanrad
deanrad / callback_contract.md
Last active August 29, 2015 14:27 — forked from CrabDude/callback_contract.md
Node.js Callback Contract

#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
@deanrad
deanrad / ibm_cb
Last active August 29, 2015 14:05 — forked from Opus1no2/ibm_cb
<style>
#foot {padding-bottom:20px;}
.two_column #customer_service_links {
height: inherit;
}
.tooltip{
display: inline;
position: relative;
}