Skip to content

Instantly share code, notes, and snippets.

View rominirani's full-sized avatar

Romin Irani rominirani

  • Mumbai
View GitHub Profile
{
"name": "bitcoin-price-function",
"version": "1.0.0",
"dependencies": {
"axios": "0.18.0"
}
}
import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
exports.getRandomQuote = (req, res) => {
var Items = [
{"person":"H. Jackson Brown, Jr.","quote":"Remember that the happiest people are not those getting more, but those giving more."},
{"person":"Mark Twain","quote":"Twenty years from now you will be more disappointed by the things that you didn’t do than by the ones you did do."},
{"person":"Elanor Roosevelt","quote":"Great minds discuss ideas; average minds discuss events; small minds discuss people."}
];
res.send(Items[Math.floor(Math.random()*Items.length)]);
@rominirani
rominirani / bq.js
Last active February 4, 2018 09:43
const bigquery = require('@google-cloud/bigquery')({
projectId: 'your-project-id',
keyFilename: 'key.json'
});
const sqlQuery = "SELECT total_amount, pickup_datetime, trip_distance FROM 'nyc-tlc.yellow.trips' ORDER BY total_amount DESC LIMIT 1;";
const options = {
query: sqlQuery,
timeoutMs: 10000,
@rominirani
rominirani / gcp-tips-timeout-property-cloud-functions.md
Last active March 10, 2021 15:14
Timeout property in Google Cloud Functions

Timeout property in Google Cloud Functions

When you configure Google Cloud Functions, you can set the Timeout property of the function. This property specifies the amount of time that the function will keep running if you do not complete the function. The default timeout is set to 60 seconds.

While this might look ok, keep in mind that when it comes to Cloud Functions pricing, one key factor you are charged for is the amount of time that the functions are running. So you want to keep this to a minimum and not let it timeout.

As a best practice, you should use the appropriate mechanism to complete the function as soon as possible and this depends on Function type.

  • HTTP Functions: Invoke the the send(), resend() or the end() methods on the Express JS response once you are done with the functionality.
@rominirani
rominirani / app.js
Last active September 10, 2017 09:10
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.get('/version', (req, res) => {
res.status(200).send("APIAI Webhook Integration. Version 1.0");
});
+----------------+---------------------------------------------------------------+
| Required | Yes |
| Parameter Name | comments |
| Entity | @sys.any |
| Value | $comments |
| Prompt | Any specific comments or feedback, you would like to give us? |
+----------------+---------------------------------------------------------------+
+-----------------+----------------------------------------------------------+
| Parameter Name | Prompt Text |
+-----------------+----------------------------------------------------------+
| resort-location | Which city did you visit our Resort in? |
| rating | How would you rate your experience on a scale of 1 to 5? |
+-----------------+----------------------------------------------------------+
'use strict';
const Storage = require('@google-cloud/storage');
const Translate = require('@google-cloud/translate');
// Instantiates a client
const storage = Storage();
const translate = Translate();
function getFileStream (file) {
if (!file.bucket) {
package main
import (
"fmt"
"github.com/gorilla/mux"
"log"
"net/http"
"net/http/httputil"
)