Skip to content

Instantly share code, notes, and snippets.

View derkork's full-sized avatar

Jan Thomä derkork

  • Leipzig, Germany
View GitHub Profile
@derkork
derkork / gist:7907114
Created December 11, 2013 08:57
The Activiti workflow engine keeps the metadata of all historic processes in it's database so you can query it later. Over time this meatdata can grow to quite significant amounts (several gigabytes). In many cases it is not required to save this metadata forever. This is an example how to clean up historic process metadata from the Activiti dat…
package de.janthomae.activiti;
import org.activiti.engine.HistoryService;
import org.activiti.engine.history.HistoricProcessInstance;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Required;
import java.text.DateFormat;
@derkork
derkork / gist:45d7fba64b54a41608e1
Created March 25, 2015 08:00
Testing service implementations without creating a spring context.
class SomeServiceImplTest extends Specification {
SomeServiceImpl underTest
SomeDao someDao
SomeOtherService someOtherService
void setup() {
// create the instance under test
underTest = new SomeServiceImpl()
@derkork
derkork / Sample.java
Last active April 1, 2021 12:31
Spring constructor dependency injection: Java vs. Kotlin
// With Java, it's a lot of boilerplate code if you want to do it right and have your dependencies
// injected via the constructor instead of annotating private variables.
// see also: http://olivergierke.de/2013/11/why-field-injection-is-evil/
@Component
public class Sample {
private SomeDependency someDependency;
@Autowired
public Sample(SomeDependency someDependency) {
@derkork
derkork / Fragment definition
Created April 14, 2015 18:46
Thymeleaf Fragments vs JSP custom tags
<!-- Thymeleaf fragment declaration -->
<!-- in fragments/form-row.html -->
<div class="row" layout:fragment="form-row(label,id)"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org">
<!-- You cannot import the dialect namespaces somehow, you have to define all of these in every file -->
<div class="large-12 columns">
<label th:for="${id}"><span th:text="${label}">Label</span>
@derkork
derkork / gist:eea330079b9f9b2165bd
Last active August 29, 2015 14:19
Recursive hash merge in Ruby
def merge_recursively(a, b)
result = Hash.new
a.each do |key, a_item|
if b.key?(key)
b_item = b[key]
if b_item.is_a? Hash and a_item.is_a? Hash
result[key] = merge_recursively(a_item, b_item)
else
result[key] = b_item.nil? ? a_item : b_item
end
@derkork
derkork / riderify.sh
Created November 22, 2016 19:49
Quickly add the JetBrains Rider plugin to any Unity project
#!/bin/bash
PROJECT_PATH=$1
if [ "$PROJECT_PATH" == "" ]; then
echo "Usage: riderify.sh <project root>"
exit 1
fi
rm -rf /tmp/riderplugin
mkdir -p /tmp/riderplugin
git clone https://github.com/JetBrains/Unity3dRider.git /tmp/riderplugin
cp -R /tmp/riderplugin/Assets $PROJECT_PATH
@derkork
derkork / script.js
Created December 14, 2018 06:59
Casual PM: Sum up remaining effort tampermonkey script
// ==UserScript==
// @name Calculate remaining effort
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Sums of the effort of all tasks that are not yet finished. 1 day is counted as 8 hours.
// @author Jan Thomä
// @match https://app.casual.pm/*
// @grant none
// ==/UserScript==
@derkork
derkork / resource_queue.gd
Created April 22, 2021 09:45
Godot Resource Queue with Signals
class_name ResourceQueue
extends Node
signal loaded(path,resource)
signal progress(path, current, total)
var _thread:Thread
var _mutex:Mutex
var _sem:Semaphore
var _queue = []

Quick Tip: Refer to nodes the right way

Hello Godotneers! Nodes are the heart of Godot and using them properly in your code will help you a lot in creating and maintaining your code. Here are three ways of referring to nodes that will instantly make your game code better.

One: Create node references in onready variables

In the Godot Discord channel I very often see code like this:

func _process():
public static class ResourceQueue
{
public static async Task<T> Load<T>(string path, [CanBeNull] Delegates.ReportProgress reportProgress = null)
where T : Resource
{
if (ResourceLoader.HasCached(path))
{
GD.Print("Is in cache: " + path);
return ResourceLoader.Load<T>(path);
}