Skip to content

Instantly share code, notes, and snippets.

View mornir's full-sized avatar
🎮
Gaming

Jérôme Pott mornir

🎮
Gaming
View GitHub Profile
@mornir
mornir / 0_reuse_code.js
Last active September 11, 2016 17:18
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@mornir
mornir / google-auth-functions.js
Created June 21, 2017 17:57 — forked from elon-gs/google-auth-functions.js
Google Functions code for generating Google Auth tokens
// Code to write Google API Oauth tokens to Firebase database
const FUNCTIONS_CLIENT_ID = functions.config().googleapi.client_id;
const FUNCTIONS_SECRET_KEY = functions.config().googleapi.client_secret;
const FUNCTIONS_REDIRECT = '{YOUR_FUNCTIONS_SUBDOMAIN}.cloudfunctions.net/OauthCallback';
// TODO: use firebase functions:config:set to configure your Google API client ID and secret
// Also update FUNCTIONS_REDIRECT
const googleAuth = require('google-auth-library');
@mornir
mornir / trigger-to-google-sheet.js
Created June 21, 2017 17:57 — forked from elon-gs/trigger-to-google-sheet.js
Trigger function that copies new data in FB database to Google Sheet
// Trigger function copies new data in FB database to Google Sheet
const FUNCTIONS_CLIENT_ID = functions.config().googleapi.client_id;
const FUNCTIONS_SECRET_KEY = functions.config().googleapi.client_secret;
const FUNCTIONS_REDIRECT = '{YOUR_FUNCTIONS_SUBDOMAIN}.cloudfunctions.net/OauthCallback';
// TODO: use firebase functions:config:set to configure your Google API client ID and secret
// Also update FUNCTIONS_REDIRECT
const googleAuth = require('google-auth-library');
const google = require('googleapis');
@mornir
mornir / array_iteration_thoughts.md
Created July 2, 2017 17:26 — forked from ljharb/array_iteration_thoughts.md
Array iteration methods summarized

While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.

Intro

JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it much simpler to think about both the old list and the new one, what they contain, and

@mornir
mornir / fetch_json.js
Last active December 13, 2017 17:28 — forked from msmfsd/es7-async-await.js
Javascript fetch JSON with ES7 Async Await
async function fetchAsync () {
// await response of fetch call
const response = await fetch('https://api.github.com');
// only proceed once promise is resolved
const data = await response.json();
// only proceed once second promise is resolved
return data;
}
// more concise
@mornir
mornir / Code.gs
Created December 21, 2017 20:05 — forked from CodingDoug/README.md
Copying Data from a Google Sheet into Firebase Realtime Database in real time via Apps Script
// Copyright 2017 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@mornir
mornir / README.md
Created December 21, 2017 20:06 — forked from CodingDoug/README.md
Copying data from Firebase Realtime Database to a Google Sheet in real time via Cloud Functions
@mornir
mornir / README.md
Created January 16, 2018 10:36 — forked from CodingDoug/README.md
Building an assistant (chatbot) that translates languages, integrated with Slack
@mornir
mornir / gist:9d495b2b0b15df45ae6c654ac5e35099
Created February 15, 2018 18:16 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@mornir
mornir / README.md
Created April 23, 2018 19:43 — forked from addyosmani/README.md
108 byte CSS Layout Debugger

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