This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convertToML(val, unit, conversions) { | |
var conversionFactors = {}; | |
for (i = 1; i < conversions.length; i++) { | |
conversionFactors[conversions[i][0]] = conversions[i][1] | |
} | |
return val * conversionFactors[unit]; | |
} | |
function calculateAverageValueByVolume(volumes, values) { | |
var totalVolume = 0.0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<!-- You can quickly add it to your website via an iFrame: --> | |
<!-- Don't forget to change the state you want to display --> | |
<iframe | |
src="https://covidactnow.org/embed/us/co" | |
title="CoVid Act Now" | |
width="350" | |
height="700" | |
frameBorder="0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:8 | |
WORKDIR /usr/src/app | |
COPY package*.json ./ | |
ENV NODE_ENV=production | |
RUN npm install --production | |
COPY . . | |
CMD [ "npm", "start" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Step 0: Configure FUNCTION_URL and SERVICE_ACCOUNT as needed | |
OAUTH_ENDPOINT="https://www.googleapis.com/oauth2/v4/token" | |
FUNCTION_URL="..." | |
SERVICE_ACCOUNT="..." | |
### Step 1: Generate JWT payload | |
cat <<EOF > input.json | |
{ | |
"iat": $(date +%s), | |
"exp": $(($(date +%s) + 3600)), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function logger(string) { | |
console.log("Logging [" + Date.now() + "]: " + string); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
runtime: nodejs8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isChatMessage(message) { | |
return message.size() == 4 | |
&& message.username is string | |
&& message.userId is string | |
&& message.createdAt is timestamp | |
&& message.messageText is string | |
&& message.messageText.size() <= 160; | |
} | |
function isUser(user) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
You can create a Role Based Access Control system by storing ownership and access membership in the custom metadata of the file. | |
The proposed solution uses the existing "owner" "editor" and "reader" permissions. | |
If you store a user and the associated permission as a key/value pair in the file metadata: | |
// custom file metadata looks like: | |
metadata: { | |
"user:1234": "owner", | |
"user:5678": "editor", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// set it up | |
firebase.storage().ref().constructor.prototype.putFiles = function(files) { | |
var ref = this; | |
return Promise.all(files.map(function(file) { | |
return ref.child(file.name).put(file); | |
})); | |
} | |
// use it! | |
firebase.storage().ref().putFiles(files).then(function(metadatas) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ios_app( | |
name = "App", | |
hdrs = ["src/*.h"], | |
srcs = ["src/*.m"], | |
deps = [ | |
"@SDWebImage//:latest_library", | |
], | |
) | |
ios_test( |
NewerOlder