Skip to content

Instantly share code, notes, and snippets.

lgvalle / firebase-scraping.js
Last active September 23, 2021 01:17
Firebase cloud function to scrap html and send the content with push notifications
const rp = require('request-promise');
const cheerio = require('cheerio');
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const db = admin.firestore();
exports.allyPallyFarmersMarket = functions.https.onRequest((request, response) => {
lgvalle / gist:d03f594c85db23b432ff9ab173f10e24
Created March 31, 2018 15:03
Run firebase tools docker image
docker run -v $PWD:/usr/app -w /usr/app -p 9005:9005 -u node -it lgvalle/firebasetools:v2 sh
lgvalle / Docker shell
Created March 31, 2018 12:45 — forked from bahmutov/Docker shell
A personal cheat sheet for running local Node project in a Docker container
# See list of docker virtual machines on the local box
$ docker-machine ls
default * virtualbox Running tcp:// v1.9.1
# Note the host URL - it will be used later!
# Build an image from current folder under given image name
$ docker build -t gleb/demo-app .
lgvalle / docker-compose.yml
Last active February 26, 2018 15:32
version: '3'
image: rethinkdb:2.3
- "8080:8080"
- "28015:28015"
- "29015:29015"
restart: always
lgvalle / index.js
Created September 10, 2017 18:38
Blogpost Firebase II - Full code
const ONE_HOUR = 3600000
var functions = require('firebase-functions');
var Client = require('node-rest-client').Client;
var client = new Client();
const admin = require('firebase-admin');
const functions = require('firebase-functions')
const Client = require('node-rest-client').Client
const client = new Client()
exports.fetch = functions.https.onRequest((req, res) => {
client.get(URL_THE_GUARDIAN, function (data, response) {
const items = cleanUp(data)
function cleanUp(data) {
// Empty array to add cleaned up elements to
const items = []
// We are only interested in children of the 'channel' element
const channel =
channel.item.forEach(element => {
item = {
title: element.title,
description: element.description,
"title": "'Leaving London means I can afford kids': readers on why the capital lost its sparkle",
"description": "Almost 100,000 Londoners moved out last year. Here they, and others who are avoiding the city altogether, explain why it is no longer the place to be<br></p><p>The rate of Londoners leaving the capital is more than <a href="">80% higher than five years ago</a>, according to Savills, with people in their thirties the age group most likely to leave. </p><p>We asked readers why they’re leaving London, or avoiding moving to the capital altogether. Here’s what you said:</p><p>All my salary was being spent on living costs in London</p> <a href="">Continue reading...</a>",
"date": "Mon, 31 Jul 2
<rss xmlns:media=”" xmlns:dc=”" version=”2.0">
 <title>London | The Guardian</title>
 <description>Latest news and features from, the world’s leading liberal voice</description>
 <copyright>Guardian News and Media Limited or its affiliated companies. All rights reserved. 2017</copyright>
 <pubDate>Mon, 31 Jul 2017 15:32:49 GMT</pubDate>
lgvalle / step2.js
Last active August 8, 2017 06:57
Post: Take control of your backend (II)
const Client = require('node - rest - client').Client
const client = new Client()
exports.fetch = functions.https.onRequest((req, res) => {
client.get(BACKEND_URL, function (data, response) {
(…) // TODO Clean up
return res.status(200)
.type('application / json')