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 typing import ClassVar, Type, Dict, Generic, TypeVar, Any, List | |
from pydantic import BaseModel | |
# | |
T = TypeVar('T', bound=BaseModel) | |
class Response(BaseModel, Generic[T]): | |
data: Type[BaseModel] | |
metadata: Dict[str, Any] | |
def __init__(self, *a, **kw) -> None: |
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
apt -y --no-install-recommends install libssl1.0.0 | |
openssl genrsa -aes256 -out ca.key.pem 2048 | |
chmod 400 ca.key.pem | |
openssl genrsa -out localhost.key.pem 2048 | |
openssl req -subj "/CN=${CERT_NAME}" -extensions v3_req -sha256 -new -key localhost.key.pem -out localhost.csr | |
openssl req -new -x509 -subj "/CN=${CERT_NAME}" -extensions v3_ca -days 3650 -key ca.key.pem -sha256 -out ${CERT_NAME}.pem -config localhost.cnf | |
openssl x509 -req -extensions v3_req -days 3650 -sha256 -in localhost.csr -CA ${CERT_NAME}.pem -CAkey ca.key.pem -CAcreateserial -out localhost.crt -extfile localhost.cnf |
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 org.apache.spark.SparkConf | |
import org.apache.spark.serializer.KryoSerializer | |
import org.apache.spark.sql.SparkSession | |
import org.apache.spark.ml.feature.VectorAssembler | |
import scala.util.Random | |
import ml.dmlc.xgboost4j.scala.spark.{XGBoostClassifier, XGBoostRegressor} | |
val n = 10000 | |
val x0 = 2 | |
val data = (1 to n).map(x => (Random.nextFloat())) |
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
# Copyright 2016 Google Inc. All rights reserved. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, |
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
# Copyright 2016 Google Inc. All rights reserved. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, |
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
# Dockerfile extending the generic Python image with application files for a single application. | |
FROM ubuntu:latest | |
# First we install https transportation for APT. Indeed skewed.de forces https. | |
RUN apt-get update | |
RUN apt-get install -y \ | |
python-pip | |
ADD requirements /tmp/requirements | |
RUN pip install --upgrade pip |
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
# Dockerfile extending the generic Python image with application files for a | |
# single application. | |
FROM ubuntu:latest | |
# And add a bunch of packages. | |
RUN apt-get update | |
RUN apt-get install -y \ | |
python-pip \ | |
python-crypto \ | |
python-openssl |
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 graph_tool as gt | |
import graph_tool.topology as topology | |
import cProfile, pstats, StringIO | |
pr = cProfile.Profile() | |
g = gt.load_graph('graph.gt.gz') | |
source = 1569333 | |
pr.enable() | |
topology.shortest_distance(g, source=source, weights=g.ep["length"], max_dist=2000, pred_map=True) | |
pr.disable() |
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 graph_tool as gt | |
from graph_tool.topology import shortest_path, shortest_distance | |
g = gt.Graph() | |
v = list(g.add_vertex(10)) | |
for i in range(9): | |
g.add_edge(i,i+1) | |
# MVE of shortest_path with several targets | |
vlists, elists = shortest_path(g,v[0], v[-3:]) |