Skip to content

Instantly share code, notes, and snippets.

View rominirani's full-sized avatar

Romin Irani rominirani

  • Mumbai
View GitHub Profile
+-----------------+----------------------------------------------------------+
| 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? |
+-----------------+----------------------------------------------------------+
+----------------+---------------------------------------------------------------+
| Required | Yes |
| Parameter Name | comments |
| Entity | @sys.any |
| Value | $comments |
| Prompt | Any specific comments or feedback, you would like to give us? |
+----------------+---------------------------------------------------------------+
@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");
});
@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 / 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,
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)]);
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) {
{
"name": "bitcoin-price-function",
"version": "1.0.0",
"dependencies": {
"axios": "0.18.0"
}
}
'use strict';
const axios = require("axios");
const url = "https://api.coindesk.com/v1/bpi/currentprice.json"
function verifyWebhook (body) {
if (!body || body.token !== "--YOUR_VERIFICATION_TOKEN--") {
const error = new Error('Invalid credentials');
error.code = 401;
throw error;
@rominirani
rominirani / index.js
Created May 16, 2018 05:28
Firestore Cloud Functions Demo
const admin = require('firebase-admin');
const functions = require('firebase-functions');
//Initialize Firebase
admin.initializeApp(functions.config().firebase);
const db = admin.firestore();
//Number of Questions. We could have evaluated the count of questions, but thats for a future