Instantly share code, notes, and snippets.

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);
View timehop-your-inbox.md

TimeHop Your Inbox Cares About Privacy!!

TimeHop Your Inbox only sees email information related to playing music!

When you visit TimeHop Your Inbox, your browser makes a direct connection to Gmail. You grant Gmail permission to share your data with the running web page, then the code can display info and play audio from your files.

At no point does the app look at the body of emails, nor does it send your info anywhere!

Architecture and Security

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 typescript.sh
~src $ aws
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
aws: error: too few arguments
~src $ aws help
~src $ mkdir haas
View github-ssh.sh
# Because of my current status, I dont have Haas credentials, and so a clone will fial
~haas $ ssh -T git@bitbucket.org
logged in as deanius.
You can use git or hg to connect to Bitbucket. Shell access is disabled.
~haas $ git clone git@bitbucket.org:haasalert/haasapi.git
Cloning into 'haasapi'...
repository access denied.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
View observable-stream-3.js
// A non-streaming way to return Observable<User> from a URL
function fetchObservableOf(url) {
return new Observable(obs => {
fetch(url).then(data => {
data.users.forEach(user => obs.next(user));
obs.complete()
},
err => obs.error(err)
})
}
View observable-stream-2.js
function fetchObservableOf(url) {
return new Observable(obs => {
const stream = oboeGet(url)
stream.node("![*]", user => obs.next(user))
stream.done(obs.complete)
stream.fail(obs.error)
})
}
View observable-stream-1.js
fetchObservableOf('/users/').subscribe(
user => addToList(user), // next
e => showModal(e), // error
() => hideSpinner() // complete
)
View observable-streaming.md

I like to ask of technical people:

In a situation like the following, must you retry the request and lose the data you'd already seen? Scenario: You make an AJAX request like /users, and the server returns all 100 of those users to you like [{},{},..., but the server dies before sending the final ]

I've heard many interesting answers. Leave yours in the comments! And generally they are "yes, that's the way it works" But I think the question is a distraction from the real issue: I think we used the wrong tool for the job. We sent the request over a document-oriented protocol (HTTP) instead of an incremental frame-oriented protocol and so we get document-oriented semantics (all-or-nothing) rather than list-oriented semantics (item, item, item..). Clear as crystal, right?

But as always on the internet, there are counter-arguments. Some will say - HTTP is just how we transfer stuff. Or I hear that WebSockets- a better fit for this problem of incremental delivery- are too hard to impl

View fs-write.js
fs.appendFileSync(
"scratch/actors.yml", // file path
" - Scarlett Johansson", // text
"utf8" // encoding
)