Skip to content

Instantly share code, notes, and snippets.

View jthomas's full-sized avatar
💻
serverless all the things.

James Thomas jthomas

💻
serverless all the things.
View GitHub Profile
@jthomas
jthomas / counter.js
Created December 11, 2017 14:11
OpenWhisk Action - Storing State Without a Database
const openwhisk = require('openwhisk');
const main = async evt => {
const count = (evt.count || 0) + 1
// use client library to retrieve current function configuration
const ow = openwhisk()
const action = await ow.actions.get('counter')
// update default parameters with new value
@jthomas
jthomas / wake_up.js
Last active October 27, 2017 13:26
Apache OpenWhisk Advanced Alarm Schedule Events
var openwhisk = require('openwhisk');
var request = require('request-promise');
function getNextSunrise(lat, lng, when) {
const options = {
uri: 'https://api.sunrise-sunset.org/json',
qs: { lat: lat, lng: lng, when: when },
json: true
}
@jthomas
jthomas / docker
Created October 19, 2017 14:43
Pushing logs over Lumberjack protocol using Node.js
$ docker run -p 5601:5601 -p 9200:9200 -p 5000:5000 -it --name old_elk sebp/elk:es241_l240_k461
@jthomas
jthomas / README.md
Last active February 20, 2023 20:52
OpenWhisk Workshop

OpenWhisk Workshop

Hello 👋.

This workshop will teach you how to develop serverless applications, composed of loosely coupled microservice-like functions, using an open-source serverless platform.

Starting with getting the development environment set up, it'll move onto creating, deploying and invoking serverless functions for multiple runtimes. Once you are comfortable creating serverless functions, the next step is to connect functions to events, like message queues, allowing microservices to fire automatically. Finally, we'll demonstrate how to expose serverless functions as public API endpoints, allowing to build serverless web applications.

Welcome to the future of cloud development, you'll never want to manage another server again 😎.

@jthomas
jthomas / Dockerfile
Created August 1, 2017 13:30
Custom Docker Skeleton for OpenWhisk
FROM openwhisk/dockerskeleton:latest
ADD actionproxy.py /actionProxy/
@jthomas
jthomas / Dockerfile
Created July 31, 2017 14:16
Custom Docker image for using Python ML libraries on OpenWhisk
FROM openwhisk/python3action
# lapack-dev is available in community repo.
RUN echo "http://dl-4.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
# add package build dependencies
RUN apk add --no-cache \
g++ \
lapack-dev \
gfortran
@jthomas
jthomas / cargo.toml
Created January 18, 2017 15:08
Sample Cargo dependencies for JSON processing
[package]
name = "action"
version = "0.1.0"
authors = ["Me <me@email.com>"]
[dependencies]
rustc-serialize = "0.3"
@jthomas
jthomas / main.rs
Created January 18, 2017 15:05
Sample OpenWhisk Action using Rust
extern crate rustc_serialize;
use rustc_serialize::json;
use rustc_serialize::json::Json;
use std::env;
#[derive(RustcDecodable, RustcEncodable)]
pub struct Greeting {
message: String
}
@jthomas
jthomas / command.sh
Created August 4, 2016 14:54
Time execution of running a command N times in parallel.
time parallel -n0 -j0 "cmd" ::: {1..N}
@jthomas
jthomas / Dockerfile
Created July 18, 2016 08:13
Running MQTT Server on IBM Containers
FROM node:4
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Bundle app source
COPY . /usr/src/app
EXPOSE 1883
EXPOSE 3000