function removeSmallest(numbers) {
// First step is to remove the smallest value given array
// Filter the smallest number out with Math.min.apply
let smallestNumber = Math.min.apply(Math,numbers);
// Now remove the number from the array
// Find the index of smallest number
import flask | |
import google.oauth2.credentials | |
import google_auth_oauthlib.flow | |
import os | |
from flask import Flask | |
from flask import redirect | |
from flask import request | |
from googleapiclient.discovery import build | |
# set up a Flow object that reads the clients from our secrets file with the |
# create our Flask web app | |
app = Flask(__name__) | |
# this allows transport over HTTP for development purposes, if excluded | |
# HTTPS is needed | |
os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1' | |
@app.route("/authorize-user") | |
def auth_user(): | |
""" |
import flask | |
import google.oauth2.credentials | |
import google_auth_oauthlib.flow | |
import os | |
from flask import Flask | |
from flask import redirect | |
from flask import request | |
from googleapiclient.discovery import build | |
# set up a Flow object that reads the clients from our secrets file with the |
# set up a Flow object that reads the clients from our secrets file with the | |
# corresponding scope | |
flow = google_auth_oauthlib.flow.Flow.from_client_secrets_file( | |
'client_secrets.json', | |
scopes=['https://www.googleapis.com/auth/calendar']) | |
# indicate the redirect URI that we placed in the console redirect URI when we | |
# created the oauth credentials | |
flow.redirect_uri = 'http://localhost:8080/oauth2redirect' |
import os | |
import numpy as np | |
import pandas as pd | |
from keras.preprocessing.text import text_to_word_sequence, Tokenizer | |
from keras.preprocessing.sequence import pad_sequences | |
from keras.models import Sequential, Model | |
from keras.layers import Dense, Flatten, Embedding, Input, Concatenate, Add, RepeatVector, RNN, LSTM, Dot, Dropout | |
from keras.optimizers import Adam, SGD | |
from keras.metrics import categorical_accuracy | |
from itertools import chain |
def txt_to_raw(file_name): | |
''' | |
take in a file_name and then return a raw String corpus of the contained text | |
''' | |
with open(file_name, 'r') as file: | |
raw_corpus = file.readlines() | |
return raw_corpus | |
task_training_corpus = txt_to_raw(task_training) | |
task_testing_corpus = txt_to_raw(task_testing) |
def get_unique_vocab(file_name): | |
with open(file_name,'r') as file: | |
raw_corpus = file.read() | |
tokenized = text_to_word_sequence(raw_corpus, filters='\n\t?123456789101112131415.') | |
return set(tokenized + ['.']) | |
vocab = get_unique_vocab(task_training) | |
print(f'Vocabulary set\n---\n {vocab}') |
// Top level declaration of the alphabet array | |
val alphabet = arrayOf('a', | |
'b', | |
'c', | |
'd', | |
'e', | |
'f', | |
'g', | |
'h', | |
'i', |
Despite being derived from classical MVC pattern JavaScript and the environment it runs in makes Javascript MVC implementation have its own twists. Lets see how typical web MVC functions and then dive into simple, concrete JavaScript MVC implementation.
Typical server-side MVC implementation has one MVC stack layered behind the singe point of entry. This single point of entry means that all HTTP requests, e.g. http://www.example.com or http://www.example.com/whichever-page/ etc., are routed, by a server configuration, through one point or, to be bold, one file, e.g. index.php.
At that point, there would be an implementation of Front Controller pattern which analyzes HTTP request (URI at first place) and based on it decides which class (Controller) and its method (Action) are to be invoked as a response to the request (method is name for function and member is name for a variable when part of the class/object).