Skip to content

Instantly share code, notes, and snippets.


  • Saint-Petersburg
Block or report user

Report or block ilya-g

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
ilya-g / cancellationTest.kt
Last active Dec 21, 2018
Cancellation support interceptor
View cancellationTest.kt
class JobCancellationInterceptor(val originalInterceptor: ContinuationInterceptor?) :
ContinuationInterceptor {
override fun <T> interceptContinuation(continuation: Continuation<T>): Continuation<T> =
CancellableCheckContinuation(continuation).let {
originalInterceptor?.interceptContinuation(it) ?: it
class CancellableCheckContinuation<T>(val continuation: Continuation<T>) : Continuation<T> {
ilya-g / gson-singletons.kt
Last active Nov 3, 2016
In order not to instantiate singletons with gson
View gson-singletons.kt
fun <T : Any> GsonBuilder.registerSingletonInstance(instance: T): GsonBuilder =
registerTypeAdapter(instance.javaClass, InstanceCreator { instance })
fun main(args: Array<String>) {
// val gsonBuilder = GsonBuilder().registerTypeAdapterFactory(object : TypeAdapterFactory {
// override fun <T: Any> create(gson: Gson, type: TypeToken<T>): TypeAdapter<T>? {
// val c: Class<T> = type.rawType as Class<T>
// return c.kotlin.objectInstance?.let { instance ->
ilya-g / appendListAndElement.cs
Last active Nov 12, 2015
Resolving between element and list
View appendListAndElement.cs
public static class TestResolve
public static List<T> Append<T>(this IEnumerable<T> list, T element) { throw new NotImplementedException(); }
public static List<T> Append<T>(this IEnumerable<T> list, IEnumerable<T> elements) { throw new NotImplementedException(); }
public static void Usage()
var list = new List<List<String>>();
var element = new List<String>();
View flagEnums.kt
package syntax.flagEnums
private val TODO: Nothing
get() = throw UnsupportedOperationException()
public open class PatternOptions(public val value: Int = 0) {
// the only meaning declarations
public object CASE_INSENSITIVE : PatternOptions(0x02)
public object COMMENTS : PatternOptions(0x04)
public object MULTILINE : PatternOptions(0x08)
ilya-g / GenericBenchmark.cs
Created Jan 22, 2015
Interface generic methods call time microbenchmark
View GenericBenchmark.cs
using System;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
namespace GenericBencmark
class Program
View CastLookup.cs
public static CastLookup<TKey, TElement> Cast<TKey, TElement>(this ILookup<TKey, TElement> lookup)
return new CastLookup<TKey,TElement>(lookup);
public class CastLookup<TKey, TElement>
private readonly ILookup<TKey, TElement> lookup;
public CastLookup(ILookup<TKey, TElement> lookup)
You can’t perform that action at this time.