Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View Fkawala's full-sized avatar

François Kawala Fkawala

  • Infomaniak
  • Genève, Suisse
View GitHub Profile
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()
@Fkawala
Fkawala / mwe.py
Last active July 12, 2016 09:58
MWE graph_tool shortest path / distance with multiple targets
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:])
@Fkawala
Fkawala / Dockerfile
Last active October 19, 2016 16:44
google cloud logging protobuff RequestLog
# 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
# 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
# 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,
# 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,
@Fkawala
Fkawala / x.scala
Last active December 5, 2018 15:41
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()))
@Fkawala
Fkawala / build_certs.sh
Last active March 29, 2020 10:37
Use the install.sh script to setup a nginx reverse proxy serving POSBOX on https using self issued SSL certificates. This will also setup the CA in the trusted CA for chrome and firefox browsers for $COOP_USER.
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
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: