Skip to content

Instantly share code, notes, and snippets.

package ru.waveaccess.hibernate;
import org.hibernate.FetchMode;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.QueryException;
import org.hibernate.engine.spi.LoadQueryInfluencers;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.loader.collection.BasicCollectionLoader;
package cv.hibernate
import groovy.transform.CompileStatic
import org.hibernate.engine.spi.SessionImplementor
/**
* Date: 09/05/2017
* Time: 18:30
*/
@CompileStatic
@mirasrael
mirasrael / LockStream.cs
Last active November 2, 2018 06:03
Stream with lock released on Dispose
using System.IO;
using System.Threading;
/// <summary>
/// This Stream used in cases when we need only synchronized access to some objects, but these objects provides Stream to external consumers for read or write.
/// Then the stream can just be wrapped in this LockStream, it will automatically obtain lock in constructor and will release it only on Dispose.
///
/// WARNING: For external consumers ensure you closed this stream!
/// </summary>
public class LockStream : Stream
@mirasrael
mirasrael / ExpressionUtils.cs
Created November 9, 2018 09:51
CreateConstructor expression for C#
using System;
using System.Linq.Expressions;
public class ExpressionUtils
{
public static Func<TParam, TType> CreateConstructor<TType, TParam>()
{
var type = typeof(TType);
// Get the constructor info for these parameters
var constructorInfo = type.GetConstructor(new[] { typeof(TParam) });
@mirasrael
mirasrael / qsort.kt
Created November 17, 2018 11:36
Quick Sort on Kotlin
/**
* Date: 11/15/2018
* Time: 21:45
*/
fun main(args: Array<String>) {
assertArrayEquals(longArrayOf(), qSort(longArrayOf()))
assertArrayEquals(longArrayOf(1), qSort(longArrayOf(1)))
assertArrayEquals(longArrayOf(1, 2), qSort(longArrayOf(2, 1)))
assertArrayEquals(longArrayOf(1, 2, 3), qSort(longArrayOf(2, 3, 1)))
assertArrayEquals(longArrayOf(1, 1, 1, 1, 3, 3, 3), qSort(longArrayOf(3, 1, 1, 3, 1, 3, 1)))
@mirasrael
mirasrael / asserts.kt
Created November 18, 2018 06:35
Asserts for Kotlin lessons
import kotlin.test.assertEquals
/**
* Date: 11/18/2018
* Time: 09:25
*/
fun assertArrayEquals(expected: LongArray, actual: LongArray) {
assertEquals(expected.size, actual.size, "Arrays have different size: ${expected.size} != ${actual.size}")
var i = 0
while (i < expected.size) {
@mirasrael
mirasrael / arrays.kt
Created November 18, 2018 06:36
Array utility functions for Kotlin lessons
import java.util.*
/**
* Date: 11/18/2018
* Time: 09:26
*/
fun printArray(a: LongArray) {
var i = 0
while (i < a.size) {
print(a[i++])
@mirasrael
mirasrael / collections.kt
Last active January 19, 2019 17:47
Collections for Kotlin lesson
package education
import java.util.*
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertTrue
/**
* Date: 1/13/2019
* Time: 20:49
@mirasrael
mirasrael / DictConcurrency.cs
Created February 11, 2019 10:05
dict comparison
public static void Main (string[] args)
{
var iterations = 1000;
var size = 100000;
for (var i = 0; i < size; i++)
{
concurrent.Add(i.ToString(), i);
simple.Add(i.ToString(), i);
threadSafe.Add(i.ToString(), i);
}
@mirasrael
mirasrael / 1
Last active March 14, 2019 05:57
Dlls
Accessibility, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a:C:\Program Files\Unity\Hub\Editor\2018.3.8f1\Editor\Data\MonoBleedingEdge\lib\mono\unityjit\Accessibility.dll
Anonymously Hosted DynamicMethods Assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null:<Dynamic>
Eco.Client, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null:W:\projects\Eco\Client\Library\ScriptAssemblies\Eco.Client.dll
Eco.Client.IntegrationTests, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null:W:\projects\Eco\Client\Library\ScriptAssemblies\Eco.Client.IntegrationTests.dll
Eco.Client.Tests, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null:W:\projects\Eco\Client\Library\ScriptAssemblies\Eco.Client.Tests.dll
Eco.LocalizationTools, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null:W:\projects\Eco\Client\Assets\Plugins\Eco.LocalizationTools.dll
Eco.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null:W:\projects\Eco\Client\Assets\Plugins\Eco.Shared.dll
Editor.Eco, Version=0.0.0.0, Cul