Skip to content

Instantly share code, notes, and snippets.

View jobsamuel's full-sized avatar
🔥
creating

Jobsamuel Núñez jobsamuel

🔥
creating
View GitHub Profile
I am attesting that this GitHub handle jobsamuel is linked to the Tezos account tz1c1ujBjmQDrq4nxKVrG3ibnPyZ1CUMU5Pn for tzprofiles
sig:edsigtzDR7R6mYea3nv8HsVt2vaTrwuL8KmFAqZnNMjeALhW8mqDeabAtVtt5rP5PTgFUfeCrf9fbqguP3FM2mrnvFbCYWiU8x6
@jobsamuel
jobsamuel / cors-cloud-storage.sh
Created April 26, 2019 12:52
How to set up CORS in your Google Cloud Storage Bucket
# Go to "Activate Google Cloud Shell" in https://console.cloud.google.com/home.
echo '[{"origin": ["*"],"responseHeader": ["Content-Type"],"method": ["GET", "HEAD"],"maxAgeSeconds": 3600}]' > cors-config.json
# If you want to restrict the access one or more specific domains, add their URL to the array:
echo '[{"origin": ["https://yourdomain.com"],"responseHeader": ["Content-Type"],"method": ["GET", "HEAD"],"maxAgeSeconds": 3600}]' > cors-config.json
# Set CORS config.
gsutil cors set cors-config.json gs://YOUR_BUCKET_NAME
# Verify if everything is OK.
function quitarAcentos(texto) {
const x = 'abcdefghijklmnopqrstvuwxyz';
const y = 'ábćdéfǵhíjḱĺḿńóṕqŕśtúǘẃxýź';
const z = new RegExp(`[${y}]`, 'g');
return texto.toLowerCase()
.replace(z, letra => x[y.indexOf(letra)]);
}
# Git commits style
bold=$(tput bold)
normal=$(tput sgr0)
alias commit="echo '
${bold}<acción>(<ámbito>): <descripción>${normal}
• ${bold}${underline}acción:${normal} razón del commit. Debe ser una de estas:
${bold}feat:${normal} Implementación de nueva funcionalidad.
Verifying my Blockstack ID is secured with the address 1C8RqxQgwfRC4W5g7SePdRYoMcgnwb9FTf https://explorer.blockstack.org/address/1C8RqxQgwfRC4W5g7SePdRYoMcgnwb9FTf
Verifying my Blockstack ID is secured with the address 1GyQPFfVkMxe8Y2k3eHax8aMS4KUNDcibn https://explorer.blockstack.org/address/1GyQPFfVkMxe8Y2k3eHax8aMS4KUNDcibn
const functions = require('firebase-functions');
const admin = require('firebase-admin');
// Aquí ocurre la magia de las variables de entorno:
const token = functions.config().variable.key;
exports.ejemploVariableDeEntorno = functions.https.onRequest((req, res) => {
if (req.method === 'GET') {
res.send(`Tu variable de entorno es ${token}`);
} else {
# Puede tardar un poco en responder, no desesperes ;)
firebase functions:config:get
# La respuesta debería ser así:
{
"variable": {
"key": "ab1cde234def567890abcde12345f",
"id": "VARIABLE"
}
}
# Un ejemplo genérico.
firebase functions:config:set variable.key="ab1cde234def567890abcde12345f" variable.id="VARIABLE"
# Un ejemplo no tan genérico.
firebase functions:config:set bitly.key="ab1cde234def567890abcde12345f" bitly.id="BITLY"
# Otro ejemplo no tan genérico. Noten como el parámetro 'id' puede ser diferente.
firebase functions:config:set instagram.key="ab1cde234def567890abcde12345f" instagram.id="IG_TOKEN"
window.addEventListener('scroll', () => {
if (window.scrollY === document.body.scrollHeight - window.innerHeight) {
// Do something
}
}