Skip to content

Instantly share code, notes, and snippets.

@glynnbird
glynnbird / installing-ethereum-and-solidity.md
Created February 13, 2017 10:19
Installing Ethereum and Solidity

Method

Install the "geth" Ethereum client

sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum-unstable
var request = require('request-promise');
var main = function() {
var myAPIKey = process.env.MYAPIKEY;
var url = 'https://externalapi.service.com/v1/query?key=' + myAPIKey;
return request(url);
};
var request = require('request-promise');
var main = function() {
var myAPIKey = 'ndsvn2g8dnsb9hsg';
var url = 'https://externalapi.service.com/v1/query?key=' + myAPIKey;
return request(url);
};
@glynnbird
glynnbird / deploy.sh
Created February 9, 2017 10:10
OpenWhisk Deployment script
#!/bin/bash
# This script is expecting five environment variables
# - COUCH_URL = the URL of the Cloudant service e.g. https://u:p@host.cloudant.com
# - COUCH_DBNAME = the name of the Cloudant database e.g. petition
# - SENDGRIDBEARER = the API key used to communicate with sendgrid
# - SENDGRIDSENDER = the email address that emails will appear to come from
# - SENDGRIDTEMPLATEID = the email template id to email
if [ -z "$COUCH_URL" ]; then echo "COUCH_URL is required"; exit 1; fi
if [ -z "$COUCH_DBNAME" ]; then echo "COUCH_DBNAME is required"; exit 1; fi
@glynnbird
glynnbird / myapp4.js
Created February 2, 2017 16:30
Node.js app receiving events from Simple Notification Service
sns.on('notification', function(n) {
// your code here
}
@glynnbird
glynnbird / myapp3.js
Created February 2, 2017 16:29
Node.js app sending data to the Simple Notification Service
var pos = {
"x": 168.5514677267044,
"y": 529.3377142251632,
"rounds": 509,
"missile": [],
"direction": 6
}
sns.send(
{ type: 'game', colour: 'red' },
{ action: 'position', colour: 'white', data: pos });
@glynnbird
glynnbird / myapp2.js
Created February 2, 2017 16:28
Node.js app connecting to the Simple Notification Service
var sns = new SNSClient('myapikey', {
userData: {
type: 'game',
colour: 'white'
},
userQuery: {
type: 'game'
}
});
@glynnbird
glynnbird / myapp1.js
Last active February 7, 2017 08:06
A node.js app the uses the Simple Notification Service as a baked-in library
"use strict"
const path = require('path');
const router = require('express').Router();
const hostname = 'localhost'
// my custom routes add to 'router'
router.get('/my/route', function(req, res) {
res.send({ok:true});
);
@glynnbird
glynnbird / plane.json
Created February 2, 2017 16:25
Data model for an aircraft for Dogfight 1983
{
"x": 168.5514677267044,
"y": 529.3377142251632,
"rounds": 509,
"missile": [{
"x": 1.471789304834207,
"y": 511.7769323961955,
"speed": 9,
"direction": 6
}, {
@glynnbird
glynnbird / cloudant-couchdb-api.json
Last active November 22, 2016 08:09 — forked from vabarbosa/cloudant-couchdb-api.json
Cloudant & CouchDB API Reference
[
{
"endpoint": "/",
"method": "GET",
"database": ["Cloudant", "CouchDB"],
"summary": "Meta information about the cluster.",
"comment": ""
},
{
"endpoint": "/_active_tasks",