Skip to content

Instantly share code, notes, and snippets.

View marcorei's full-sized avatar

Markus Riegel marcorei

View GitHub Profile
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"strict": true
},
"exclude": [ "node_modules" ]
}
@marcorei
marcorei / app.ts
Created December 31, 2017 11:09
app.ts modifications
...
// Import actions here.
import * as DemoAction from './actions/DemoAction'
...
const actions: Action[] = [
// Add actions here.
DemoAction
]
...
import { DialogflowApp } from 'actions-on-google'
export const name = 'demo_action'
export function handler(app: DialogflowApp) {
const paramNumber = parseInt(app.getArgument('number').toString())
app.tell(`I incremented your number. Here you go: ${paramNumber + 1}`)
}
@marcorei
marcorei / serverless.yml
Created December 31, 2017 11:02
serverless function
functions:
fulfillment:
handler: handler.fulfillment
events:
- http:
path: fulfillment
method: post
@marcorei
marcorei / serverless.yml
Created December 31, 2017 11:01
serverless plugins
plugins:
- serverless-plugin-typescript
- serverless-offline
@marcorei
marcorei / serverless.yml
Created December 31, 2017 10:59
exclude and include rules
package:
exclude:
include:
- src/**/*
import { Request, Response } from 'express'
import { DialogflowApp } from 'actions-on-google'
// Import actions here.
export function createDialogflowApp(request: Request, response: Response) {
const dialogflowApp = new DialogflowApp({request, response})
interface Action {
name: string,
handler: (app: DialogflowApp) => void
import * as express from 'express'
import * as bodyParser from 'body-parser'
const serverless = require('serverless-http')
import { createDialogflowApp } from './src/app'
export const expressApp = express()
expressApp.use(bodyParser.json());
expressApp.post('/fulfillment', createDialogflowApp)
module.exports.fulfillment = serverless(expressApp)
@marcorei
marcorei / first.js
Last active December 24, 2017 16:53
Check if you can access Firebase data with anonymous auth
var fbScripTag = document.createElement('script');
fbScripTag.setAttribute('src','https://www.gstatic.com/firebasejs/4.8.1/firebase.js');
document.head.appendChild(fbScripTag);
@marcorei
marcorei / ClosuresReferenceCycle.playground
Created September 1, 2016 10:02
Test if closures alone create reference cycles
import Foundation
class Alf {
static var numberOfInstances = 0
init() {
Alf.numberOfInstances += 1
print("Alf instances: \(Alf.numberOfInstances)")
}
deinit {
Alf.numberOfInstances -= 1