Skip to content

Instantly share code, notes, and snippets.

View anton-dudarev's full-sized avatar
🎯
Focusing

Anoubis anton-dudarev

🎯
Focusing
View GitHub Profile
const {
dialogflow,
Permission, //拿出 Permission 物件
} = require('actions-on-google');
const app = dialogflow({debug: true});
app.intent('request_name_permission', (conv) => {
conv.data.requestedPermission = 'NAME';
if (!conv.user.storage.name) {
@nistath
nistath / terminator.vbs
Last active February 19, 2023 22:15 — forked from ropnop/startTerminator.vbs
Script to start terminator on WSL from CMD or PowerShell
' Usage: terminator[.vbs] [path to starting directory]
' contents enclosed in square brackets optional
args = "-c" & " -l " & """DISPLAY=:0 terminator"""
' If there's a single argument, interpret it as the starting directory
If WScript.Arguments.Count = 1 Then
dir = WScript.Arguments(0)
Else
dir = ""
@brainysmurf
brainysmurf / DatabaseFromSpreadsheet.js
Last active September 24, 2023 12:08
In AppMaker, use this to read in data from a Spreadsheet.
/**
* DataFromSpreadsheet: Read in Spreadsheet info for a Calculated Datasource in AppMaker. Use a spreadsheet to define a datasource.
* Useful for data modeling, simple Apps.
* Does not support paging; sheets with large number of rows will see performance penalties
* @param {object} params
* @param {string} params.spreadsheetId The ID of the source spreadsheet
* @param {string} params.sheetName The name of the source sheet
* @param {string} params.datasource The name of the target datasource
* @param {number} params.numHeaders How many rows are headers (default = 1)
* @param {number} params.headerRow Which row contains the name of the field (default=params.numHeaders-1)
@jirawatee
jirawatee / dialogflow-firestore.js
Last active February 21, 2024 23:42
Dialogflow integrate with Cloud Functions - Cloud Firestore
"use strict";
const functions = require("firebase-functions");
const { WebhookClient } = require("dialogflow-fulfillment");
const { Card, Suggestion } = require("dialogflow-fulfillment");
const admin = require("firebase-admin");
admin.initializeApp({
credential: admin.credential.applicationDefault(),
databaseURL: 'https://<YOUR-PROJECT-ID>.firebaseio.com'
@mhawksey
mhawksey / UrlShortener.gs
Last active April 2, 2021 05:51
Google Apps Script shim to replace UrlShortener calls with a Bit.ly version
// https://addyosmani.com/blog/essential-js-namespacing/
// extend.js
// written by andrew dupont, optimized by addy osmani
function extend(destination, source) {
var toString = Object.prototype.toString,
objTest = toString.call({});
for (var property in source) {
if (source[property] && objTest == toString.call(source[property])) {
destination[property] = destination[property] || {};
extend(destination[property], source[property]);
@scastrec
scastrec / entities.creator.js
Last active May 25, 2019 22:16
A simple script to create simple entities for Dialogflow from json source
/**
* Waiting input:
* @param : json filename
* @param : json key for entities
*/
var fs = require('fs');
//var file = fs.readFileSync('data/' + argv.file, 'utf8');
const file = process.argv[2];
const key = process.argv[3];

Получение строки для регулярного выражения

Рабочий код находится в файле run.gs. Чтобы проверить его работоспособность можно запустить код ниже в любом редакторе Google Apps Script.

function doit(){
  if ((typeof run)==='undefined') {
    var cs = CacheService.getScriptCache().get('cache');
    if(!cs){
      cs = UrlFetchApp
 .fetch('https://gist.githubusercontent.com/oshliaer/386844d1dc524605a1eec9e54c50d30e/raw/83ee38949c25993dc54b5f66721475ba0c7c3c70/run.gs')
@tbass134
tbass134 / getInfo.js
Last active May 25, 2019 22:18
Dialogflow webhook to transfer user to live agent
function getInfo(contexts) {
var product = contexts[contexts.length - 1]['parameters']['Product']
var state = contexts[contexts.length - 1]['parameters']['geo-state-us']
for (var i = 0; i < contexts.length; i++) {
var context = contexts[i]['parameters']
if (typeof context['Product'] != "undefined" && typeof context['geo-state-us'] != "undefined") {
return context
}
@michaelprosario
michaelprosario / trello-firebase-function-for-google-actions.js
Last active August 11, 2019 07:06
Trello Firebase Function for Google Actions
'use strict';
// Import the Dialogflow module from the Actions on Google client library.
const {dialogflow} = require('actions-on-google');
// Import the firebase-functions package for deployment.
const functions = require('firebase-functions');
// Instantiate the Dialogflow client.
const app = dialogflow({debug: true});
@oshliaer
oshliaer / cb-in
Created July 22, 2018 09:32 — forked from Gen2ly/cb-in
Copy file or pipe to Xorg clipboard
#!/bin/bash
# Copy file or pipe to Xorg clipboard
# Required program(s)
req_progs=(xclip)
for p in ${req_progs[@]}; do
hash "$p" 2>&- || \
{ echo >&2 " Required program \"$p\" not installed."; exit 1; }
done