Skip to content

Instantly share code, notes, and snippets.

View jobsamuel's full-sized avatar
🔥
creating

Jobsamuel Núñez jobsamuel

🔥
creating
View GitHub Profile
@jobsamuel
jobsamuel / readme.md
Last active January 19, 2024 18:26
Run NodeJS as a Service on Ubuntu 14.04 LTS

Run NodeJS as a Service on Ubuntu 14.04 LTS

With Node you can write very fast JavaScript programs serverside. It's pretty easy to install Node, code your program, and run it. But > how do you make it run nicely in the background like a true server?

  • Go to /etc/init/
  • $ sudo vim yourapp.conf
  • Paste script.conf
  • $ sudo start yourapp
  • And when you wanna kill the process $ sudo stop yourapp
I am attesting that this GitHub handle jobsamuel is linked to the Tezos account tz1c1ujBjmQDrq4nxKVrG3ibnPyZ1CUMU5Pn for tzprofiles
sig:edsigtzDR7R6mYea3nv8HsVt2vaTrwuL8KmFAqZnNMjeALhW8mqDeabAtVtt5rP5PTgFUfeCrf9fbqguP3FM2mrnvFbCYWiU8x6
@jobsamuel
jobsamuel / install.sh
Last active April 21, 2020 06:53
Install MongoDB 3.0 in Ubuntu 14.04 LTS
#!/bin/bash
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org=3.0.0 mongodb-org-server=3.0.0 mongodb-org-shell=3.0.0 mongodb-org-mongos=3.0.0 mongodb-org-tools=3.0.0
sudo service mongod start
@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.
# 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.
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)]);
}
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"
}
}