Skip to content

Instantly share code, notes, and snippets.

@arturaz
arturaz / MyDBContext.scala
Last active February 28, 2020 09:52
Quill JSON Play support
class MyDBContext(
dataSource: DataSource with Closeable,
ec: ExecutionContextWithExecutor
) extends PostgresJdbcContext(SnakeCase, dataSource)
with Queries with Quotes with JsonB with Codecs
@arturaz
arturaz / kotlin.kt
Created January 28, 2020 10:45
Interoperability between scala and kotlin persistent collections
package zowo_shared.lib.compat
import kotlinx.collections.immutable.ImmutableCollection
import kotlinx.collections.immutable.ImmutableSet
import kotlinx.collections.immutable.PersistentMap
import kotlinx.collections.immutable.persistentMapOf
import zowo_shared.lib.functional.ZOption
interface ICompatPersistentMap<K, V> {
val entries: ImmutableSet<Map.Entry<K, V>>
@arturaz
arturaz / gist:80cf15617aa4c83b719933958b5b4ec4
Created July 21, 2019 18:21
Windows API (Win32) to flash (blink) the taskbar window in Unity
https://github.com/tinylabproductions/tlplib/commit/3d96ea5e6d90d168ea41bc0d2470c7b2d86b74b0
@arturaz
arturaz / InteractiveBrokersDividends.scala
Created April 22, 2019 10:55
Little scala script for calculating the dividends and withholdings for them for InteractiveBrokers platform
import java.nio.charset.StandardCharsets
import java.nio.file.{Files, Path, Paths}
case class Identifier(ticker: String, isin: String)
val DescriptionRe = """^(.+?)\s*\((.+?)\).*$""".r
def read(path: Path): Map[Identifier, Vector[BigDecimal]] = {
val lines = Files.readAllLines(path, StandardCharsets.UTF_8)
var map = Map.empty[Identifier, Vector[BigDecimal]].withDefaultValue(Vector.empty)
@arturaz
arturaz / Conversions.cs
Created April 6, 2019 10:13
JVM and .NET compatible GUID usable in Unity that can be converted back and forth without any allocations.
using com.tinylabproductions.TLPLib.Data;
using Quantum;
namespace Game.code.quantum_bind {
public static class Conversions {
public static unsafe QGuid toQGuid(this SerializableGUID guid) {
var srcBytes = stackalloc byte[16];
var dstBytes = stackalloc byte[16];
*((ulong*) srcBytes) = guid.long1;
*((ulong*) (srcBytes + 8)) = guid.long2;
// photon does not serialize ulong by default
public static readonly IPhotonProperty<QGuid> PROP_USER_ID =
PhotonProperty.a(new TypedKey<long>("UserId_p0"))
.add(
PhotonProperty.a(new TypedKey<long>("UserId_p1")),
(l1, l2) => new QGuid((ulong) l1, (ulong) l2),
id => (long) id.long1,
id => (long) id.long2
);
### Why
* programmers are religious people
* people seem hostile to new ideas
* "it worked for me before, why change?"
- HomeToGo JS vs TS
- JUG vs FP
### What
@arturaz
arturaz / shapeless-test.scala
Created December 17, 2018 19:49
Playing around with shapeless
package app
import shapeless.ops.hlist.{ConstMapper, Intersection, Union, ZipWith}
import shapeless.{::, HList, HNil, Poly2}
case class Params()
sealed trait EvaluatableGeneratorFilter[+Result] {
def eval(p: Params): Result
}
package app
import shapeless.ops.hlist.{ConstMapper, Mapper, ZipWith}
import shapeless.{::, HList, HNil, Poly2}
case class Params()
sealed trait EvaluatableGeneratorFilter[+Result] {
def eval(p: Params): Result
}
package app
import shapeless.ops.hlist.Mapper
import shapeless.{::, HList, HNil, Poly2}
case class Params()
sealed trait EvaluatableGeneratorFilter[+Result] {
def eval(p: Params): Result
}