Skip to content

Instantly share code, notes, and snippets.

jhegedus42

  • Helsinki
Block or report user

Report or block jhegedus42

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
View gist:a4bfd9e24e893eb36dff88e2fdf364c4
this call:
val f: Future[XMLHttpRequest] = Ajax.put(url_str, json_line)
generates:
OPTIONS /Line HTTP/1.1
Content-Type: text/plain;charset=UTF-8
Referer: http://localhost/
User-Agent: Node.js (linux; U; rv:v6.11.0) AppleWebKit/537.36 (KHTML, like Gecko)
View gist:c6ef9257d828e99292778f3338f93e7d
object ClientRestAJAX {
import scala.scalajs.concurrent.JSExecutionContext.Implicits.queue
def getEntity[E <: Entity: ClassTag: Decoder](
ref: Ref[E]): Future[HttpGetRequestResult[E]] = {
val url: GetURL = ref
val url_str = url.toURLWithHostAsString
val f: Future[XMLHttpRequest] = Ajax.get(url_str)
View gist:aaf90bafe45db5b2e6b1a250f78ba494
package app.client.reactComponents._experiments
import app.client.reactComponents._experiments.InnerComp.{
ICType,
PropsWithState
}
import japgolly.scalajs.react.CompScope.DuringCallbackU
import japgolly.scalajs.react.ReactComponentB.{P, PSB}
import japgolly.scalajs.react.ReactComponentC.ReqProps
@jhegedus42
jhegedus42 / Implicit.scala
Created Apr 8, 2017
playing around with implicits
View Implicit.scala
import MyProducers.MapProducer
trait Entity
case class Ref[T](id: String)
case class IntEntity(int: Int)
case class StringEntity(s: String)
trait RefResolver {
View gist:9c478a07ff4244dac7581424d88a2e1c
@js.native
trait Props extends js.Object {
var value: String = js.native
var index: Int = js.native
var key: String = js.native
}
case class ScalaProps(val value:String, val index:Int, val key:String)
// how do i convert ScalaProps to Props ?
View Main.purs
module Main where
import Prelude
import Data.Foldable (for_)
import Data.String (length, fromCharArray)
import Data.Unfoldable (replicate)
import Control.Monad.Eff
import Control.Monad.Eff.Console (log)
View gist:97052583284f9c2015b9a8dbc725b21c
In Scala:
@js.native
trait Props extends js.Object {
val value: String = js.native
val items: scala.collection.mutable.Seq[String] = js.native
}
@JSExport
val TestCompB: ReqProps[Props, Unit, Unit, TopNode] =
View gist:287e6b24228bda786cf6ef8cce63cd3a
@js.native
trait Window extends js.Object {
def alert(message: String): Unit = js.native
}
@js.native
@JSName("window")
object W extends Window
View Monad Transformers Intro, credit goes to user5402 at SOF
This is available [here] as a .lhs file.
Let's just deal with the `MaybeT` transformer.
First some imports:
> import Control.Monad
> import Control.Monad.Trans
> import Control.Monad.Trans.Maybe
View gist:770ec994ed03aeb4b424
[nix-shell:~/try-reflex/reflex-todomvc]$ codex update
cabal: user error (Saved package config file seems to be corrupt. Try re-running the 'configure' command.)
codex: *warning* falling back on dependency resolution using hackage
Nothing to update.
You can’t perform that action at this time.