This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Swift category/extension for animating between rootViewControllers at the UIWindow level | |
import UIKit | |
extension UIWindow { | |
func setRootViewController(newRootViewController: UIViewController, animated: Bool) { | |
// No animation required | |
if !animated || self.rootViewController == nil { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express') | |
const { WebhookClient } = require('dialogflow-fulfillment') | |
const app = express() | |
app.get('/', (req, res) => res.send('online')) | |
app.post('/dialogflow', express.json(), (req, res) => { | |
const agent = new WebhookClient({ request: req, response: res }) | |
function welcome () { | |
agent.add('Welcome to my agent!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express') | |
const { WebhookClient } = require('dialogflow-fulfillment') | |
const app = express() | |
app.get('/', (req, res) => res.send('online')) | |
app.post('/dialogflow', express.json(), (req, res) => { | |
const agent = new WebhookClient({ request: req, response: res }) | |
function welcome () { | |
agent.add('Welcome to my agent!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "webhook-demo", | |
"version": "0.0.1", | |
"description": "A template for creating web hooks for Dialogflow", | |
"author": "Antony Harfield", | |
"main": "src/cloudFuncs.js", | |
"engines": { "node": "8" }, | |
"scripts": { | |
"dev": "nodemon --inspect src/server.js", | |
"start": "node src/server.js", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed class Result<T> | |
data class Success<T>(val value: T): Result<T>() | |
data class Failure<T>(val errorMessage: String): Result<T>() | |
infix fun <T,U> Result<T>.compose(f: (T) -> Result<U>) = | |
when (this) { | |
is Success -> f(this.value) | |
is Failure -> Failure(this.errorMessage) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Result is a superpowered enum that can be Success or Failure | |
// and the basis for a railway junction | |
sealed class Result<T> | |
data class Success<T>(val value: T): Result<T>() | |
data class Failure<T>(val errorMessage: String): Result<T>() | |
// Composition: apply a function f to Success results | |
infix fun <T,U> Result<T>.then(f: (T) -> Result<U>) = | |
when (this) { | |
is Success -> f(this.value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from google.api_core import page_iterator | |
from google.cloud import storage | |
def _item_to_value(iterator, item): | |
return item | |
def list_directories(bucket_name, path): | |
if not path.endswith('/'): | |
path += '/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
import params | |
import yamnet | |
def main(): | |
# Load the model and weights | |
model = yamnet.yamnet_frames_model(params) | |
model.load_weights('yamnet.h5') | |
# Convert the model |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
from tensorflow.keras import Model, layers | |
import features as features_lib | |
import params | |
from yamnet import yamnet | |
def yamnet_frames_tflite_model(feature_params): | |
num_samples = int(round(params.SAMPLE_RATE * 0.975)) | |
waveform = layers.Input(batch_shape=(1, num_samples)) | |
# Store the intermediate spectrogram features to use in visualization. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
from tensorflow.keras import Model, layers | |
import features as features_lib | |
import features_tflite as features_tflite_lib | |
import params | |
from yamnet import yamnet | |
def yamnet_frames_tflite_model(feature_params): | |
"""Defines the YAMNet model suitable for tflite conversion.""" | |
num_samples = int(round(params.SAMPLE_RATE * 0.975)) |