Skip to content

Instantly share code, notes, and snippets.

@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\"]}"
@lornajane
lornajane / ubuntu-handbook.md
Last active Nov 5, 2017
Caitlin's Ubuntu Handbook
View ubuntu-handbook.md

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

View router.php
<?php
$action_filename = "action.php";
ob_start();
if($_POST){
switch($_SERVER['SCRIPT_NAME']) {
case "/init":
echo "OK\n";
View notification-worker.js
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);
View notification2.json
{
"comment": {
"name": "Helen",
"comment": "The whole experience was magical. Thank you to everyone who was part of it!",
"time": 1482512023
},
"url": {
"url": "http:\/\/requestb.in\/yflr9zyf"
}
}
View notification1.json
{
"comment": {
"name": "Helen",
"comment": "The whole experience was magical. Thank you to everyone who was part of it!",
"time": 1482512023
},
"url": {
"url": "http:\/\/requestb.in\/wq2ue6wq"
}
}
View comment.json
{
"comment": {
"name": "Helen",
"comment": "The whole experience was magical. Thank you to everyone who was part of it!",
"time": 1482512023
},
"webhooks": [
{
"url": "http:\/\/requestb.in\/wq2ue6wq"
},
View comment-worker.js
var amqp = require('amqplib/callback_api');
var atob = require('atob');
var cfenv = require('cfenv');
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);
opts = {ca: [ca]};
View config2.php
if(isset($_ENV['VCAP_SERVICES'])) {
$vcap_services = json_decode($_ENV['VCAP_SERVICES'], true);
$rabbit_url = $vcap_services['compose-for-rabbitmq'][0]['credentials']['uri'];
$url_bits = parse_url($rabbit_url);
$config['rabbitmq']['host'] = $url_bits['host'];
$config['rabbitmq']['port'] = $url_bits['port'];
$config['rabbitmq']['vhost'] = substr($url_bits['path'], 1);
$config['rabbitmq']['username'] = $url_bits['user'];
$config['rabbitmq']['password'] = $url_bits['pass'];
$config['rabbitmq']['ssl'] = true;
View config1.php
if(isset($_ENV['VCAP_SERVICES'])) {
$vcap_services = json_decode($_ENV['VCAP_SERVICES'], true);
$config['couchdb']['url'] = $vcap_services['cloudantNoSQLDB'][0]['credentials']['url'];
} else {
$config['couchdb']['url'] = "http://localhost:5984";
}