Skip to content

Instantly share code, notes, and snippets.

@yustme
yustme / Datacontract.yaml
Created August 4, 2025 07:16
Datacontract example
dataContractSpecification: 1.2.0
id: orders-latest
info:
title: Orders Latest
version: 2.0.0
description: |
Successful customer orders in the webshop.
All orders since 2020-01-01.
Orders with their line items are in their current state (no history included).
owner: Checkout Team
@yustme
yustme / pydatic.py
Created July 9, 2025 11:16
LLM-structured-answer.py
from crewai import LLM
from pydantic import BaseModel
import os
class Dog(BaseModel):
name: str
age: int
breed: str
llm = LLM(
@yustme
yustme / app.py
Created August 15, 2023 08:30
Keboola alcohol demo
import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import io
from kbcstorage.client import Client
st.set_page_config(page_title="X Builder X", layout="wide")
df = pd.read_csv('/data/in/tables/fake_table.csv')
@yustme
yustme / RandomService.php
Last active December 12, 2018 16:19
Remove service factories
<?php
....
private function requireUser(string $idOrEmail): Model_Row_Admin
{
if (!$this->tokenProvider->getAdmin()->isSuperAdmin()) {
throw new HttpException("You can't access other users", 403);
}
@yustme
yustme / regexp.php
Last active October 18, 2018 10:33
Regular expression for Zdenda
<?php
//original string from textarea
$string = "1. Vojta\n 2. Zdenda \n 3.Kamarádovi rodiče";
$lines = explode("\n", $string);
print_r($lines);
foreach ($lines as $line) {
$matches = [];
preg_match('/^([1-9\ ]*)[\.\ ]*(.*)/', $line, $matches);
//if no matches found in arrray will be 0 rows
if(count($matches) > 0) {
@yustme
yustme / Dockerfile
Created January 27, 2018 11:46
Example of dockerfile
FROM docker-registry.----.cz/platform/webserver-libs2
ENV DOCUMENT_ROOT_DIR=web
ENV SYMFONY_ENV=prod
ENV SYMFONY_DEBUG=0
WORKDIR /var/www/html
# install vendors
COPY composer.* ./
@yustme
yustme / MxCheckerTest.php
Created January 27, 2018 11:42
Example of test class
<?php
namespace AdFinance\SmartEmailing\Test\Checker;
use AdFinance\SmartEmailing\Checker\MxRecordChecker;
class MxCheckerTest extends \PHPUnit_Framework_TestCase
{
@yustme
yustme / ExampleController.php
Created January 27, 2018 11:39
Example of controller code
<?php
namespace AppBundle\Controller;
use AppBundle\CalculationEntity;
use AppBundle\CalculationHandler;
use AppBundle\LoanParameterDataProvider;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use AdFinance\Constants;
<?php
/**
* @DI\Service("contract_bundle.contract_factory.form_factory")
*/
class FormFactory
{
/**
* @var FormFactoryInterface
*/
private $formFactory;
/**
* Zaregistruje všechny repozitáře pro kalkulačky do kontejneru
* Klíč calculators.repositories.mobile_interner_repository
*
* @param IDependencyContainer $container
*/
private function bootstrapCalcRepositories(IDependencyContainer $container)
{
foreach ( new \DirectoryIterator(__DIR__ . '/Calculators/Repositories/') as $fileInfo) {
if($fileInfo->isFile() && ($fileInfo->getFilename() != 'AbstractRepository.php')){