Skip to content

Instantly share code, notes, and snippets.

import json
from pathlib import Path
import numpy as np
import certifi
import ssl
import os
from typing import List
from zurich.space.security import add_zurichca
def mlflow_pip_deps() -> List[str]:
try:
poetry_export_result = subprocess.run(
["poetry", "export", "-f", "requirements.txt", "--without-hashes"],
capture_output=True,
encoding="utf8",
).stdout.splitlines()
result = []
for req in poetry_export_result:
# ignore extra/index url lines
def install_requirements(requirements: Union[str, List[str]], space_token: Optional[str] = None) -> None:
"""
Instally Pip dependencies defined in requirements list.
Parameters
----------
:param requirements: If `str`, its interpreted as a path to `requirements.txt`, if it is a list, the list of dependencies will be added.
:param space_token: The personal accesss token to access artifacts from Space artifacts library (required if Zurich internal packages should be deployed).
"""
args = [
@cokeSchlumpf
cokeSchlumpf / streams.scala
Created March 3, 2020 10:48
Executing two dependent streams with Akka Streams
package ch.suva.mlp.app
import akka.actor.ActorSystem
import akka.stream.OverflowStrategy
import akka.stream.scaladsl.{Concat, Flow, Keep, Sink, Source}
import scala.concurrent.{ExecutionContext, Future}
import scala.util.{Failure, Success}
object TestApp extends App {
def orderEntry(order: Order): Try[OrderEntryProcessed] = {
order.items foreach { item =>
val stock = stockRepository.getProductById(item.product)
stock.amount = stock.amount - item.amount
stockRepository.updateStockItem(stock)
}
incredible_ai.checkForFraud(order)
payments.makePayment(order.paymentDetails)
coolBonusPointsSystem.giveBonusForOrder(order)
# The first line should contain the title of the post
Then you can just write whatever you want with every Markdown feature available on GitHub.
You can mark the split between the preview and the rest of the post with ...
---
... a horizontal line. On the single view of the post, the preview as well as the rest of the article will be displayed.
{
"title": "Blog Title",
"dateFormat": "MMMM DD, YYYY",
"postPerPage": 3,
"description": "This is a sample blog template. You may not define any description at all. But, you can do here...",
"topics": [
"topic-a",
"topic-b",
"topic-c"
],
@cokeSchlumpf
cokeSchlumpf / Conffigs.java
Created May 27, 2019 09:51
Using Lightbend Config (Typesafe Config) to load configuration with environment/ role specific overrides
package wellnr.commons;
import com.google.common.collect.Maps;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigException;
import com.typesafe.config.ConfigFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
@cokeSchlumpf
cokeSchlumpf / SimpleApplication.scala
Last active April 29, 2019 13:51
Sample Application Snippets
package com.example
object SimpleApplication extends App {
SimpleServer.startServer("localhost", 8080)
}
@cokeSchlumpf
cokeSchlumpf / authentifizierung.js
Created November 23, 2017 15:02
Benutzerverwaltung
(req, res, next) => {
const auth = req.cookies.auth;
const token = _.get(auth, 'token');
if (token) {
cloudant((db) => {
const selector = {
entity: 'user',
token: token
};