Skip to content

Instantly share code, notes, and snippets.

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 / people.sql
Created April 4, 2016 16:03
Material to accompany JSON data type examples
-- MySQL dump 10.13 Distrib 5.6.28, for debian-linux-gnu (x86_64)
--
-- Host: 127.0.0.1 Database: demo
-- ------------------------------------------------------
-- Server version 5.7.11
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
@lornajane
lornajane / notifier.js
Created November 17, 2017 15:47
Send a webhook from serverless js on openwhisk
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:"
// 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) {
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}});
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 November 17, 2017 15:09
StackOverflow Trigger
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\"]}"
@lornajane
lornajane / ubuntu-handbook.md
Last active November 5, 2017 21:05
Caitlin's Ubuntu Handbook

Caitlin's Ubuntu Handbook

This laptop is called "asterope" and it is running "Ubuntu" rather than Windows. Here are some things you might need to know (and I can edit this document to add things when you have questions!). Beware that I had some power problems with this laptop so I don't know how long it will last. Turn it off when you aren't using it, and make sure you are using dropbox or google docs so that you won't lose anything if it does die!

First Principles

This laptop has a touch screen and the screen rotates so you can sort of fold it up with the screen facing outwards. This might be surprising.

Whatever you want to do, press the windows key and start typing. Alt+F4 closes windows, Alt+Tab switches between them, I think those are both the same as Windows

<?php
$action_filename = "action.php";
ob_start();
if($_POST){
switch($_SERVER['SCRIPT_NAME']) {
case "/init":
echo "OK\n";
var amqp = require('amqplib/callback_api');
var atob = require('atob');
var cfenv = require('cfenv');
var request = require('request');
if (process.env.VCAP_SERVICES) {
var appEnv = cfenv.getAppEnv()
rabbitmq_url = appEnv.getService('guestbook-messages').credentials.uri;
cert_string = atob(appEnv.getService('guestbook-messages').credentials.ca_certificate_base64);
ca = new Buffer(cert_string);