Skip to content

Instantly share code, notes, and snippets.

View schmitch's full-sized avatar

Schmitt Christian schmitch

View GitHub Profile
@schmitch
schmitch / Program.cs
Created March 30, 2023 20:19
reproducer
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
using NodaTime;
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
await using ApplicationDbContext db = new();
await db.Database.EnsureDeletedAsync();
await db.Database.EnsureCreatedAsync();
using System;
using System.Diagnostics;
using System.IO;
namespace ConsoleApp1
{
/// <summary>
/// Helper stream class to represent a slice of a larger stream to save memory when dealing with large streams
/// and remove the extra copy operations
/// This class is inspired from System.IO.Compression in dot net core. Reference implementation can be found here
@schmitch
schmitch / README.md
Created August 9, 2021 07:44 — forked from paulgregg/README.md
Converting a gitlab export to simple git repo

Converting a gitlab export to simple git repo

Gitlab exports a tar.gz file which contains a file called project.bundle. We can convert this file into a normal git repo using the following steps:

Extract the project.bundle file

$ tar xvfz GitLabExport.gz
@schmitch
schmitch / GrpcServerBuilder.cs
Created June 30, 2020 14:49
standalone grpc server builder
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting.Builder;
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Routing;
@schmitch
schmitch / Blocking.cs
Last active October 7, 2019 10:41
Is it possible
public class BackgroundQueuedHostedService : BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken cancellationToken)
{
while (!cancellationToken.IsCancellationRequested)
{
var workItem = await TaskQueue.DequeueAsync(cancellationToken);
await FastTask(); //
await Task.Factory.StartNew(
() =>
@schmitch
schmitch / graal_error
Last active May 18, 2018 12:32
GraalVM SubstrateVM error when running play
Warning: Native image server limit exceeded. Use options --server{-list,-shutdown[-all]} to fix the problem.
classlist: 13,304.29 ms
(cap): 1,741.70 ms
setup: 2,708.53 ms
analysis: 35,828.31 ms
error: unsupported features in 2 methods
Detailed message:
Error: Must not have a FileDescriptor in the image heap.
Trace: object java.io.FileOutputStream
object java.io.BufferedOutputStream
@schmitch
schmitch / Angular2.scala
Created July 25, 2017 12:34 — forked from jroper/Angular2.scala
Play Angular 2 integration
import play.sbt.PlayRunHook
import sbt._
import java.net.InetSocketAddress
object Angular2 {
def apply(log: Logger, base: File, target: File): PlayRunHook = {
object Angular2Process extends PlayRunHook {
private var watchProcess: Option[Process] = None
@schmitch
schmitch / Main.java
Last active December 14, 2016 08:39
Main.java perf problems
/*
Outcome: c.schmitt - MacBook Pro (Retina, 15", Ende 2013) - macOS 10.12.1
sbt "jmh:run -i 10 -wi 10 -f1 -t1"
[info] Benchmark Mode Cnt Score Error Units
[info] Main.testMethod thrpt 10 19538048,171 ± 2224217,470 ops/s
[info] Main.testMethodHandleIntSupplierUnreflect thrpt 10 6735285,753 ± 281407,613 ops/s
[info] Main.testMethodHandleUnreflect thrpt 10 28706699,796 ± 755897,511 ops/s
[info] Main.testMethodHandleUnreflectListSize thrpt 10 20084867,818 ± 449023,818 ops/s
[info] Main.testMethodHandleUnreflectSimple thrpt 10 28637750,180 ± 685004,308 ops/s
[info] Main.testMethodHandleUnreflectSimpleArguments thrpt 10 5267296,404 ± 71604,568 ops/s
@schmitch
schmitch / ResultSource.scala
Last active December 9, 2016 09:58
AkkaStream <=> java.sql
import java.sql.Connection
import java.sql.PreparedStatement
import java.sql.ResultSet
import javax.sql.DataSource
import akka.stream.Attributes
import akka.stream.Outlet
import akka.stream.SourceShape
import akka.stream.stage.GraphStage
import akka.stream.stage.GraphStageLogic
@schmitch
schmitch / play-2.12.patch
Last active October 25, 2016 09:10
play-2.12.0-RC2 patch
diff --git a/framework/project/Build.scala b/framework/project/Build.scala
index 4f6a639..872b74e 100644
--- a/framework/project/Build.scala
+++ b/framework/project/Build.scala
@@ -51,7 +51,6 @@ object BuildSettings {
* These settings are used by all projects
*/
def playCommonSettings: Seq[Setting[_]] = {
-
scalariformSettings ++ Seq(