Skip to content

Instantly share code, notes, and snippets.

Avatar
💯

Jordan Coeyman acoyfellow

💯
View GitHub Profile
@acoyfellow
acoyfellow / storage.js
Last active Feb 9, 2019 — forked from M4sterShake/storage.js
Simple localStorage like wrapper around indexeddb
View storage.js
function Storage(name) {
this.name= name;
this.ready = (done)=> {
var request = window.indexedDB.open(name);
request.onupgradeneeded = e => {
this.db = e.target.result;
this.db.createObjectStore(name);
};
request.onsuccess = e => {
this.db = e.target.result;
View createUserDoc.ts
import * as functions from "firebase-functions";
import * as firebase from "firebase-admin";
import {MD5} from "crypto-js";
export const createUserDoc = functions.auth.user().onCreate(event => {
const firebaseUser = event.data;
// Use gravatar as default if photoUrl isn't specified in user data
const gravatarHash = MD5(firebaseUser.email).toString().toLowerCase();
let photoURL = `https://www.gravatar.com/avatar/${gravatarHash}.jpg?s=1024&d=robohash`;
@acoyfellow
acoyfellow / instaGet
Created May 10, 2017 — forked from lkLeonov/instaGet
How to get media from instagram via XHR
View instaGet
function getMedia(instaData, mediaCount, callback) {
var profileData = instaData.entry_data.ProfilePage[0];
var userID = profileData.user.id;
var totalMedia = profileData.user.media.count;
var mediaCount = mediaCount > totalMedia ? totalMedia : mediaCount;
var csrf_token = instaData.config.csrf_token;
var xhrBody = "ig_user(" + userID + ") { media.after(0, " + mediaCount + ") {nodes {display_src }}}";
var xhr = new XMLHttpRequest();
xhr.open("POST", '/query/', true)