Skip to content

Instantly share code, notes, and snippets.

View owenv
function owenv() {
bold=$(tput bold)
normal=$(tput sgr0)
switches=""
space=$1
case "$space" in
"cloudshell")
host=runtime.adobe.io
key=<api key>
@macdonst
macdonst / wolfram.js
Created Sep 4, 2018
MS Azure Function to ask Wolfram Alpha a question
View wolfram.js
const fetch = require('node-fetch');
const credentials = require('./credentials');
module.exports = async function(context, req) {
if (req.query.searchTerm || (req.body && req.body.searchTerm)) {
const searchTerm = req.query.searchTerm ||
req.body.searchTerm;
let url = `http://api.wolframalpha.com/v2/query?input=${searchTerm}&appid=${
credentials.wolfram
}`;
@macdonst
macdonst / translate.js
Created Sep 4, 2018
MS Azure Function to call Google Translate
View translate.js
const fetch = require('node-fetch');
const credentials = require('./credentials');
module.exports = async function(context, req) {
if (req.query.searchTerm || (req.body && req.body.searchTerm)) {
const searchTerm = req.query.searchTerm ||
req.body.searchTerm;
let url = `https://www.googleapis.com/language/translate/v2?key=${
credentials.google
}&source=en&target=fr&q=${searchTerm}`;
@macdonst
macdonst / server.js
Last active Sep 4, 2018
Node server using Hapi.js
View server.js
'use strict';
const Hapi = require('hapi');
const Joi = require('joi');
const fetch = require('node-fetch');
const credentials = require('./credentials');
const server = Hapi.server({
host: '0.0.0.0',
port: 8000
View index-padleft.js
const leftPad = require('left-pad');
function main(args) {
const name = args.name || 'World';
return { payload: `Hello, ${leftPad(name, 30, ".")}!` };
}
global.main = main;
View index.js
function main(args) {
return { payload: 'Hello world' };
}
global.main = main;
View handler-padleft.js
'use strict';
const leftPad = require('left-pad');
function hello(params) {
const name = params.name || 'World';
return { payload: `Hello, ${leftPad(name, 30, ".")}!` };
}
exports.hello = hello;
View handler.js
'use strict';
function hello(params) {
const name = params.name || 'World';
return { payload: `Hello, ${name}!` };
}
exports.hello = hello;
View sandman.json
{
"image":"https://static1.squarespace.com/static/58b8e713db29d62626926f2d/58bcb3945016e1f82fb3206f/58bcb3951b10e3957cd09137/1488761751400/DaveWachter.jpg?format=750w",
"artist":"Dave Wachter"
}
View First
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css"/>
<script src="http://cmx.io/v/0.1/cmx.js"></script>
<body>
<scene id="scene1">
<label t="translate(0,346)">
<tspan x="0" y="0em">A Mobile Developer's Journey'</tspan>
</label>
<actor t="translate(131,49)" pose="-11,9|-5,117|-11,99|-11,89|-11,79|-11,59|-16,34|-21,9|-6,34|-1,9|-18,79|-18,59|-6,79|-1,59">