Skip to content

Instantly share code, notes, and snippets.

@Lakritzator
Lakritzator / generic_host-vs-spring_boot.md
Last active August 21, 2024 07:13
A comparison between Javas Spring-Boot and the Generic Host of dotnet core

This is work in progress

I read about the .NET Generic Host for the first time in a Tweet of David Fowler. And I was hooked by the idea, it was just what I was looking for.

I like modules making things small but fit together like pieces of a puzzle, if possible being able to reuse them. I started refactoring Greenshot over a year ago, and was making modules out of the spaghetti code that it was. Trying to extract the modules into their own nuget packages, making them more generic and testable. I glued them together with some code I wrote, which is availble in Dapplo.Addons, but I knew that this was just a journey, until I found something that is a better with more potential.

I found the following description: _The purpose of Generic Host is to enable a wider array of host scenarios. Messaging, backg

trait IdConfig {
val timestampBits: Int
val dataCenterIdBits: Int
val workerIdBits: Int
val sequenceBits: Int
@watermint
watermint / application-logger.xml
Created October 7, 2013 12:56
Configure Play2.2/Scala logging format as LTSV (Labeled Tab-separated Values).
<configuration>
<conversionRule conversionWord="coloredLevel" converterClass="play.api.Logger$ColoredLevel" />
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${application.home}/logs/application.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${application.home}/logs/application.%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>14</maxHistory>
</rollingPolicy>
<encoder>
<charset>UTF-8</charset>
@mojaray2k
mojaray2k / JavaScript 2
Created September 8, 2013 17:35
You can use the vanilla Javascript Dom Ready event without jQuery
//domready2.js
// without jQuery (doesn't work in older IEs)
document.addEventListener('DOMContentLoaded', function(){
// your code goes here
}, false);
// and here's the trick (works everywhere):
r(function(){
alert('DOM Ready!');
@rbtnn
rbtnn / Nancy.md
Created July 10, 2013 08:38
https://github.com/NancyFx/Nancy/wiki ここの重要そうな部分を適当に翻訳したやつ。

Nancy

最初のNancyアプリケーション

ここではあなたはNugetをインストールしており、Visual Studio 2010を使って いることを前提として話を進めています。 しかしこれと同等なことをMono(Version 2.10.2以降)とMonoDevelopを使っても できます。 NancyとNancyのASP.NET Hostingを使った"hello world"アプリケーション作成に

@kmizu
kmizu / -Xprint:parser-Person1.scala
Created September 21, 2012 16:47
Difference between 'Placeholder Syntax for Anonymous Functions' and 'Method Values'
[[syntax trees at end of parser]]// Scala source: Person1.scala
package <empty> {
object Main extends scala.ScalaObject {
def <init>() = {
super.<init>();
()
};
def main(argv: Array[String]): scala.Unit = {
val args = argv;
{
@j5ik2o
j5ik2o / gist:2156447
Created March 22, 2012 05:41
Play framework 2.0でデーモン化する方法

commons-daemonの依存関係を追加する

次のようにproject/Build.scala を編集する。

object ApplicationBuild extends Build {
    // ...
    val appDependencies = Seq(
      "commons-daemon" % "commons-daemon" % "1.0.10"
    )

// ...

@jewelsea
jewelsea / CodeEditor.java
Created December 11, 2011 23:30
CodeMirror based code editor for JavaFX
import javafx.scene.layout.StackPane;
import javafx.scene.web.WebView;
/**
* A syntax highlighting code editor for JavaFX created by wrapping a
* CodeMirror code editor in a WebView.
*
* See http://codemirror.net for more information on using the codemirror editor.
*/
public class CodeEditor extends StackPane {
@chrisnicola
chrisnicola / GzipFilter.cs
Created August 15, 2011 19:36
Gzip Compression Filter for Nancy
/* A JSON gzip compression filter, which could easily be adapted to any pattern needed. This uses a custom AfterFilter
* type which is just a fancy wrapper of Action<NancyContext>. It's useful for convention based loading of filters
*/
public class GzipCompressionFilter : AfterFilter
{
protected override void Handle(NancyContext ctx)
{
if ((ctx.Response.ContentType == "application/json") && ctx.Request.Headers.AcceptEncoding.Any(