Skip to content

Instantly share code, notes, and snippets.

View skalahonza's full-sized avatar

Jan Skála skalahonza

View GitHub Profile
http:
routers:
api-router:
rule: "PathPrefix(`/api`)"
service: "backend-service"
entryPoints:
- "web"
front-router:
rule: "PathPrefix(`/`)"
@skalahonza
skalahonza / overlapping_entries.py
Created September 2, 2023 07:24
Get all overlaping clockify time entries
import requests
from datetime import datetime
import pytz
# Replace with your Clockify API key, workspace ID and user ID
API_KEY = ''
WORKSPACE_ID = ''
USER_ID = ''
# Set the time zone
@skalahonza
skalahonza / Summary.cs
Created August 17, 2023 09:04
Reusing XML Documentation in C#
var dto = new DTO();
var tmp = dto.Description; // see the same summary as in Entity.Description
public class Entity
{
/// <summary>
/// The description of the entity.
/// </summary>
public string Description { get; set; }
@skalahonza
skalahonza / version.yml
Created February 17, 2023 06:19
This script is designed to be used in GitHub Actions workflows to set version-related environment variables based on the event that triggered the workflow. If the workflow was triggered by a tag event, the script sets the RELEASE_VERSION environment variable to the commit SHA and tag name separated by a semicolon. Otherwise, the RELEASE_VERSION …
- name: Set Release Version
run: |
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
echo "RELEASE_VERSION=${GITHUB_SHA};${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
else
echo "RELEASE_VERSION=${GITHUB_SHA}" >> $GITHUB_ENV
fi
@skalahonza
skalahonza / TypeSafeEnum.cs
Created August 23, 2022 10:10
Type safe enum that uses normal enum values for the underlying storage. Enhancment of Ardalis.SmartEnum.SmartEnum.
using Ardalis.SmartEnum;
/// <summary>
/// Type safe enum that uses normal enum values for the underlying storage.
/// Enhancment of Ardalis.SmartEnum.SmartEnum
/// </summary>
/// <typeparam name="TEnum">The type that is inheriting from this class.</typeparam>
/// <typeparam name="TDiscriminator">Enum used as discriminator</typeparam>
public abstract class TypeSafeEnum<TEnum, TDiscriminator> : SmartEnum<TEnum>
where TEnum : SmartEnum<TEnum, int>
@skalahonza
skalahonza / SamplesController.cs
Created March 22, 2022 13:53
Dynamic CRUD controller.
using Microsoft.AspNetCore.Mvc;
namespace Petricords.API.Controllers;
public class SamplesController : ApiController
{
private readonly IServiceProvider _services;
public SamplesController(IServiceProvider services)
{
@skalahonza
skalahonza / Dotnet libraries.md
Last active February 5, 2022 08:58
Set of usefull .NET libraries for various use cases.

.NET libraries

Set of usefull .NET libraries for various use cases.

Common

  • Swashbuckle - swagger
  • System.Linq.Async - IAsyncEnumerable LINQ support
  • Pathoschild.Http.FluentClient - fluent HTTP client
  • Blazorise - UI toolkit for Blazor
  • Microsoft.Extensions.Options - loading configration via dependency injection
@skalahonza
skalahonza / deploy.yml
Created January 29, 2022 14:13
CI for Balzor Web Assembly PWA
name: Deploy to GitHub Pages
on: workflow_dispatch
jobs:
deploy-to-github-pages:
# use ubuntu-latest image to run steps on
runs-on: ubuntu-latest
steps:
# uses GitHub's checkout action to checkout code form the master branch
@skalahonza
skalahonza / avi-mp4-convert.sh
Created October 16, 2021 14:47
Convert all avi files to mp4 using HW accelerated FFMPEG
for i in *.avi; do ffmpeg -hwaccel cuda -i "$i" "${i%.*}.mp4"; done
@skalahonza
skalahonza / CrontabService.cs
Created September 30, 2021 06:59
.NET SDK Background Service that can use CRON notation to run periodically.
public abstract class CrontabService : BackgroundService
{
private DateTime nextRun;
private readonly CrontabSchedule _schedule;
private readonly ILogger _logger;
public CrontabService(CrontabSchedule schedule, ILogger logger)
{
_schedule = schedule;