Skip to content

Instantly share code, notes, and snippets.

View OlegIlyenko's full-sized avatar

ΘLΞG OlegIlyenko

View GitHub Profile
@evancz
evancz / data-interchange.md
Last active April 29, 2024 16:53
Why do I have to write JSON decoders in Elm?

A vision for data interchange in Elm

How do you send information between clients and servers? What format should that information be in? What happens when the server changes the format, but the client has not been updated yet? What happens when the server changes the format, but the database cannot be updated?

These are difficult questions. It is not just about picking a format, but rather picking a format that can evolve as your application evolves.

Literature Review

By now there are many approaches to communicating between client and server. These approaches tend to be known within specific companies and language communities, but the techniques do not cross borders. I will outline JSON, ProtoBuf, and GraphQL here so we can learn from them all.

@OlegIlyenko
OlegIlyenko / ApolloTracingExtension.scala
Last active May 15, 2018 20:35
An example of the apollo tracing GraphQL extension with Sangria
import java.time.Instant
import java.time.format.DateTimeFormatter
import java.util.concurrent.ConcurrentLinkedQueue
import sangria.ast._
import sangria.execution._
import sangria.schema.Context
import sangria.marshalling.queryAst._
import sangria.renderer.SchemaRenderer
@fokot
fokot / SchemaCompare.scala
Last active June 29, 2017 11:51
GraphQL schema compare
package raptorclientapi
import io.circe.Encoder
import io.circe.parser.parse
import sangria.schema.{Schema, SchemaChange}
import scalaj.http.{Http => SJHttp}
import sangria.marshalling.circe.CirceInputUnmarshaller
import io.circe._
import io.circe.generic.semiauto._
@trbngr
trbngr / GraphQLService.scala
Created October 13, 2016 23:03
Parse GraphQl Request with Circe.
case class GraphQlRequest(query: String, operation: Option[String], variables: Json)
def parseRequest: Directive1[GraphQlRequest] = {
import cats.data.Xor
import io.circe.ParsingFailure
import io.circe.parser.{parse ⇒ parseJson}
entity(as[Json]).map { json ⇒
val cursor = json.hcursor
val variables = {
@OlegIlyenko
OlegIlyenko / Event-stream based GraphQL subscriptions.md
Last active February 24, 2024 04:41
Event-stream based GraphQL subscriptions for real-time updates

In this gist I would like to describe an idea for GraphQL subscriptions. It was inspired by conversations about subscriptions in the GraphQL slack channel and different GH issues, like #89 and #411.

Conceptual Model

At the moment GraphQL allows 2 types of queries:

  • query
  • mutation

Reference implementation also adds the third type: subscription. It does not have any semantics yet, so here I would like to propose one possible semantics interpretation and the reasoning behind it.

@cobbpg
cobbpg / Unity-hotswapping-notes.md
Last active February 17, 2024 19:04
Unity hotswapping notes

Unity hotswapping notes

Unity has built-in support for hotswapping, which is a huge productivity booster. This feature works not only with graphics assets like bitmaps and meshes, but also with code: if you edit the source and save it, the editor will save the state of the running game, compile and load the new code, then load the saved state and continue where it left off. Unfortunately, this feature is very easy to break, and most available 3rd party plugins have little regard for it.

It looks like there’s a lot of confusion about hotswapping in Unity, and many developers are not even aware of its existence – which is no wonder if their only experience is seeing lots of errors on the console when they forget to stop the game before recompiling... This document is an attempt to clear up some of this confusion.

Nota bene, I’m not a Unity developer, so everything below is based on blog posts and experimentation. Corrections are most welcome!

The basic flow of hotswapping

@dwhitney
dwhitney / Example.scala
Created August 14, 2015 19:43
Got Interfaces working in Sangria using the facebook spec examples
import sangria.schema._
import sangria.execution.Executor
import sangria.introspection.introspectionQuery
import sangria.integration.PlayJsonSupport._
import sangria.parser.{SyntaxError, QueryParser}
import sangria.renderer.SchemaRenderer
import scala.util.{Success,Failure}
trait NamedEntity{ val name: String }
@ppurang
ppurang / build.sbt
Last active August 29, 2015 13:56
sbt prompt with git branch and git status for modifications etc.
// the following results in
// superduperproject : master : 0.1.0 : MD??>
// where M => Modified, D => Deleted, ?? => not tracked
// and might include (not tested :))
// !, R, C, U for details check https://www.kernel.org/pub/software/scm/git/docs/git-status.html#_short_format
// if you see superduperproject : master : 0.1.0 : -?-> ... well then oops and happy debugging and do tell...
shellPrompt in ThisBuild := ShellPrompt.buildShellPrompt("0.1.0")
@paulp
paulp / transcript
Last active December 15, 2015 13:09
scala> class Bippy(xs: List[Int]) extends improving.TypesafeProxy(xs) { def isEmpty = true }
defined class Bippy
scala> val bippy = new Bippy(1 to 10 toList)
bippy: Bippy = List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
scala> bippy.slice(3, 7)
[proxy] $line4.$read.$iw.$iw.bippy.slice(3, 7)
res1: List[Int] = List(4, 5, 6, 7)