Skip to content

Instantly share code, notes, and snippets.

View marcorei's full-sized avatar

Markus Riegel marcorei

View GitHub Profile
@marcorei
marcorei / clean-toc.gs
Created March 10, 2016 12:05
Google Apps Script which cleans the Table of Content from unwanted headings.
/**
* Creates a menu entry in the Google Docs UI when the document is opened.
*
* @param {object} e The event parameter for a simple onOpen trigger. To
* determine which authorization mode (ScriptApp.AuthMode) the trigger is
* running in, inspect e.authMode.
*/
function onOpen(e) {
DocumentApp.getUi().createAddonMenu()
.addItem('Clean Table of Contents', 'cleanToC')
@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
@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);
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)
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
@marcorei
marcorei / serverless.yml
Created December 31, 2017 10:59
exclude and include rules
package:
exclude:
include:
- src/**/*
@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 11:02
serverless function
functions:
fulfillment:
handler: handler.fulfillment
events:
- http:
path: fulfillment
method: post
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 / 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
]
...