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 django.db import models | |
from django.contrib.auth.models import AbstractUser | |
from django.contrib.auth.models import BaseUserManager | |
# This project uses Django Authentication System | |
# For more information visit: https://docs.djangoproject.com/en/1.11/topics/auth/default/ | |
#referenced from https://medium.com/@ramykhuffash/django-authentication-with-just-an-email-and-password-no-username-required-33e47976b517 | |
class MyUserManager(BaseUserManager): | |
""" | |
A custom user manager to deal with emails as unique identifiers for auth |
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
kmeansp2 <- function(x, k, iter.max = 10, nstart = 1, ...) { | |
n <- nrow(x) # number of data points | |
centers <- numeric(k) # IDs of centers | |
distances <- matrix(numeric(n * (k - 1)), ncol = k - 1) # distances[i, j]: The distance between x[i,] and x[centers[j],] | |
res.best <- list(tot.withinss = Inf) # the best result among <nstart> iterations | |
for (rep in 1:nstart) { | |
pr <- rep(1, n) # probability for sampling centers | |
for (i in 1:(k - 1)) { | |
centers[i] <- sample.int(n, 1, prob = pr) # Pick up the ith center | |
distances[1:length(distances)] <- colSums((t(x) - x[centers[i], ])^2) # Compute (the square of) distances to the center |
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
service: my-service | |
provider: | |
name: aws | |
runtime: nodejs6.10 | |
iamRoleStatements: | |
- Effect: "Allow" | |
Action: | |
- dynamodb:DescribeTable | |
- dynamodb:Query |