Skip to content

Instantly share code, notes, and snippets.

View edgar-maciel's full-sized avatar

Edgar de Oliveira Maciel edgar-maciel

View GitHub Profile
@edgar-maciel
edgar-maciel / forward.md
Created November 6, 2016 16:53 — forked from jamestalmage/forward.md
Using Firebase to Authenticate to Google Drive

Note: There is a lot of information here, but if I have provided a link, it is probably something you should click on and read. OAuth is a complex enough subject on it's own, and hacking these two services together only adds to it.

Even so, I have found Firebase's API to be simpler than almost any other OAuth solution I have explored. When all is said and done, the important bits of code related to authentication is actually less than 10 lines. If you have ever tried to implement your own OAuth flow before, you know how amazing that is.

In the end, it may be worth using Firebase for authentication, even if that's the ONLY thing you use it for.

@edgar-maciel
edgar-maciel / client.js
Created November 3, 2016 07:21 — forked from hagino3000/client.js
WebSocket with binary data
var socket = null;
function bootstrap() {
// 適当な図形を描画
var c = document.getElementById('mycanvas');
var ctx = c.getContext('2d');
ctx.globalalpha = 0.3;
for(var i=0; i<1000; i++) {
ctx.beginPath();
@edgar-maciel
edgar-maciel / make_writable.js
Created October 31, 2016 21:43 — forked from moehlone/make_writable.js
Make JavaScript readonly propertys writable (example for overwriting navigator.userAgent; useful for unit tests -> browser detection)
/**
* Creates a read/writable property which returns a function set for write/set (assignment)
* and read/get access on a variable
*
* @param {Any} value initial value of the property
*/
function createProperty(value) {
var _value = value;
/**
@edgar-maciel
edgar-maciel / download.js
Created October 25, 2016 02:38 — forked from mkaminsky11/download.js
How to manipulate Google Drive files
/*
Download a file
*/
function downloadFile(fileId) {
var request = gapi.client.drive.files.get({
'fileId': fileId
});
request.execute(function(resp) {
window.location.assign(resp.webContentLink);
});

URLs into Indexed DB, via Service Workers

Let's say you're using Indexed DB for the offline data store for a catalog. One of the object stores contains product images. Wouldn't it be great if you could just have something like this in your catalog page?

<img src="indexeddb/database/store/id">
@edgar-maciel
edgar-maciel / .babelrc
Created June 10, 2016 10:12 — forked from bdchauvette/.babelrc
Minimal babel boilerplate
{
"presets": [ "es2015" ]
}
@edgar-maciel
edgar-maciel / readme.md
Created October 25, 2015 13:00 — forked from coolaj86/how-to-publish-to-npm.md
How to publish packages to NPM

Getting Started with NPM (as a developer)

If you haven't already set your NPM author info, now you should:

npm set init.author.name "Your Name"
npm set init.author.email "you@example.com"
npm set init.author.url "http://yourblog.com"

npm adduser

@edgar-maciel
edgar-maciel / FitCurves.js
Last active August 29, 2015 14:26 — forked from ynakajima/FitCurves.js
ポリラインをベジェ曲線で近似するアルゴリズムの実装 C言語版からJavaScriptへ移植
/**
* FitCurves.js - Piecewise cubic fitting code
*
* original: FitCurves.c
* http://tog.acm.org/resources/GraphicsGems/gems/FitCurves.c
*
* ported by ynakajima (https://github.com/ynakajima).
*
* THIS SOURCE CODE IS PUBLIC DOMAIN, and
* is freely available to the entire computer graphics community
@edgar-maciel
edgar-maciel / bling.js
Last active August 29, 2015 14:23 — forked from paulirish/bling.js
/* bling.js */
window.$ = document.querySelectorAll.bind(document)
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn)
}
NodeList.prototype.__proto__ = Array.prototype

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version