Skip to content

Instantly share code, notes, and snippets.

View ObjectIsAdvantag's full-sized avatar

Stève Sfartz ObjectIsAdvantag

View GitHub Profile
@ObjectIsAdvantag
ObjectIsAdvantag / builtio-regexp.js
Last active June 22, 2016 05:37
Built.io RegExp NodeJS filter
// for completing this activity and exporting data to next
// activity use $export(error, data)
// More help can be found here: http://bmp.io/4uih3ej
// sample text provided by user
var text = $params.text;
// regex to match and extract pattern user want
var data = text.match(/^(\/sms)\s+([+\d]+)(.+)/);
@ObjectIsAdvantag
ObjectIsAdvantag / tech2day2016-postevent.js
Last active June 20, 2016 08:34
Tech2Day post event Welcome IVR
//
// Cisco Spark Logging Library for Tropo
//
// Factory for the Spark Logging Library, with 2 parameters
// - the name of the application will prefix all your logs,
// - the Spark Incoming integration (to which logs will be posted)
// To create an Incoming Integration
// - click integrations in the right pane of a Spark Room (Example : I create a dedicated "Tropo Logs" room)
// - select incoming integration
@ObjectIsAdvantag
ObjectIsAdvantag / bootstrap-tropo-with-sparklog.js
Last active November 4, 2016 01:26
Simple script to boostrap Tropo with Spark log enabled
// QUICK START GUIDE
//
// 1. Clone this gists and make it private
// 2. Create an incoming integratin in a Spark Room from the Spark Web client : http://web.ciscospark.com
// 3. Replace YOUR_INTEGRATION_SUFFIX by the integration id, example: Y2lzY29zcGFyazovL3VzL1dFQkhPT0svZjE4ZTI0MDctYzg3MS00ZTdmLTgzYzEtM2EyOGI1N2ZZZZZ
// 4. Replace APP by your Tropo application name, example: TropoBootstrap
// 5. Create your Tropo application pointing to your raw gist URL, by appending /raw/YOUR_GIST_NAME.js to the gist URL
//
// Cisco Spark Logging Library for Tropo
@ObjectIsAdvantag
ObjectIsAdvantag / spark-room-id.sh
Last active December 23, 2020 19:17
Tip to retreive a Room Identifier from the Spark API
# This tip shows how to retreive a Spark Room Id with the Cisco Spark API
# It leverages curl, jq and base64 commands
# Let’s retreive Room Details for "spark4devs"
> SPARK_TOKEN="pick your spark token from https://developer.ciscospark.com"
> curl -X GET -H "Authorization: Bearer $SPARK_TOKEN" "https://api.ciscospark.com/v1/rooms?max=1000" | jq '.items[] | select(.title | contains("spark4dev"))'
{
"id": "Y2lzY29zcGFyazovL3VzL1JPT00vZDJmZGUwOTAtOWQwYy0xMWU1LWFlZWQtMjE3NmZkY2Q4YTU4",
"title": "#spark4dev - Public Support for Cisco Spark API",
"type": "group",
@ObjectIsAdvantag
ObjectIsAdvantag / sparklog4tropo.js
Last active June 14, 2016 06:46
Spark Log Library for Tropo Scripting Platform
// DO NOT DELETE : this gist is referenced by a live article
//
// Cisco Spark Logging Library for Tropo
//
// Factory for the Spark Logging Library, with 2 parameters
// - the name of the application will prefix all your logs,
// - the Spark Incoming integration (to which logs will be posted)
// To create an Incoming Integration
// DO NOT DELETE : this gist is referenced by a live article
//
// Cisco Spark Logging Library for Tropo
//
// Factory for the Spark Logging Library, with 2 parameters
// - the name of the application will prefix all your logs,
// - the Spark Incoming integration (to which logs will be posted)
// To create an Incoming Integration
// DO NOT DELETE : this gist is referenced by https://www.tropo.com/2016/06/gists-can-help-tropo-scripting-development/
// and https://www.tropo.com/2016/06/devops-follow-tropo-spark/
// returns true or false
function isEmail(email) {
// extract from http://stackoverflow.com/questions/46155/validate-email-address-in-javascript
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
@ObjectIsAdvantag
ObjectIsAdvantag / ciscospark-node-sdk-sample.js
Created May 30, 2016 11:01
Spark example with CiscoSpark nodejs SDK
// Instructions :
// > npm install ciscospark
// > CISCOSPARK_ACCESS_TOKEN=XXXXXXXXXX node ciscospark-node-sdk-sample.js
// ALL GOOD: message & room created !
var ciscospark = require('ciscospark');
if (!process.env.CISCOSPARK_ACCESS_TOKEN) {
console.error("Please set env variable CISCOSPARK_ACCESS_TOKEN, exiting");
process.exit(1);
}
@ObjectIsAdvantag
ObjectIsAdvantag / spark-onboarding.js
Last active May 29, 2016 12:59
Tropo script to onboard new users into Spark
//
// Spark Logging Library
//
// Factory for the Spark Logging Library, with 2 parameters
// - the name of the application will prefix all your logs,
// - the Spark Incoming integration (to which logs will be posted)
// To create an Incoming Integration
// - click integrations in the right pane of a Spark Room (Example : I create a dedicated "Tropo Logs" room)
@ObjectIsAdvantag
ObjectIsAdvantag / spark-count.sh
Last active June 6, 2016 04:44
Computing defaults for Cisco Spark
#!/bin/bash
#
# note: jq is a lightweight and flexible command-line JSON processor, https://stedolan.github.io/jq/manual/
> SPARK_TOKEN="xxxxxxxxxxxxxxxxxxxxxx"
# Number of rooms by default
> curl -X GET -H "Authorization: Bearer $SPARK_TOKEN" "https://api.ciscospark.com/v1/rooms" | jq ".items | length"
100