Skip to content

Instantly share code, notes, and snippets.

Avatar

Lorna Jane Mitchell lornajane

View GitHub Profile
@lornajane
lornajane / app.py
Created Jul 13, 2020
Very simple Flask webhook receiver
View app.py
import logging
import pprint
from flask import Flask
from flask import jsonify
from flask import request
from pprint import pformat
app = Flask(__name__)
logging.basicConfig(level=logging.DEBUG)
@lornajane
lornajane / guzzle-github.php
Created May 12, 2020
Leeds PHP: Guzzle and SDKs Example Snippets
View guzzle-github.php
<?php
// composer require guzzlehttp/guzzle
require "vendor/autoload.php";
$client = new GuzzleHttp\Client(["base_uri" => "https://api.github.com/"]);
try {
$response = $client->get("/users/lornajane/repos");
if($response->getStatusCode() == 200) {
View manual.html
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" />
<title>How to use rst2pdf</title>
<meta name="author" content="Roberto Alsina &lt;ralsina&#64;netmanagers.com.ar&gt;" />
<style type="text/css">
@lornajane
lornajane / hi-conf.json
Last active Aug 21, 2018
NCCO greets, then silence
View hi-conf.json
[
{
"action": "talk",
"voiceName": "Salli",
"text": "Your call is connected, you will now join the conference"
},
{
"action": "conversation",
"name": "conf5678"
}
View nexmo-call.sh
UUID=$(curl -s -X POST https://api.nexmo.com/v1/calls \
-H "Authorization: Bearer "$JWT\
-H "Content-Type: application/json"\
-d '{"to":[{"type": "phone","number": "'$TO_NUMBER'"}],
"from": {"type": "phone","number": "'$NEXMO_NUMBER'"},
"answer_url":["https://developer.nexmo.com/ncco/tts.json"]}' \
| awk -F "[,:]" '/uuid/{print substr($2,2,length($2)-2)}')
@lornajane
lornajane / notifier.js
Created Nov 17, 2017
Send a webhook from serverless js on openwhisk
View notifier.js
function main(data) {
return new Promise(function(resolve, reject) {
var request = require('request');
if(data.status == 'new') {
var message = "New question: <" + data.question.link + "|" + data.question.title + "> (tagged: " + data.question.tags + ")";
var options = {
"text": message,
"icon_emoji": ":postit:"
View storer.js
// fetch document or return null
function getDoc(db, id) {
return new Promise(function(resolve, reject) {
db.get(id).then(resolve).catch(function(err) {
resolve(null);
});
});
};
function main(message) {
View invoker.js
function main(args) {
return new Promise(function(resolve, reject) {
var openwhisk = require('openwhisk');
var ow = openwhisk();
var actions = args.items.map(function (item) {
console.log(item.question_id + ": " + item.title);
return ow.actions.invoke({actionName: "stackoverflow/qhandler", params: {question: item}});
View collector.js
var request = require('request');
function main(message) {
return new Promise(function(resolve, reject) {
// create API request
var now = new Date();
var tagged = message.tags.join(';');
var url = 'https://api.stackexchange.com/2.2/search';
@lornajane
lornajane / trigger.txt
Last active Nov 17, 2017
StackOverflow Trigger
View trigger.txt
bx wsk trigger delete couchdbish
bx wsk trigger create couchdbish --feed /whisk.system/alarms/alarm --param cron "*/5 * * * *" --param trigger_payload "{\"tags\": [\"cloudant\",\"ibm-cloudant\"]}"
You can’t perform that action at this time.