Skip to content

Instantly share code, notes, and snippets.

View frekw's full-sized avatar
🐼

Fredrik Wärnsberg frekw

🐼
  • https://soundtrack.io
  • Stockholm, Sweden
  • 13:38 (UTC +02:00)
View GitHub Profile
def comment do
gen all id <- positive_integer(),
author <- string(:alphanumeric, max_length: 64),
body <- string(:alphanumeric) do
%{id: id,
author: author,
body: body}
end
end
defmodule Forma do
# defmacro __using__([]) do
# quote do
# import Forma, only: [forma: 2]
# end
# end
# defmacro forma(name, module) do
# module = Macro.expand(module, __CALLER__)
# transform = Forma.compile_module(module)
type timerID;
[@bs.val] external setInterval: (unit => unit, int) => timerID = "setInterval";
[@bs.val] external clearInterval: timerID => unit = "clearInterval";
module Counter = {
let component = ReasonReact.component("Counter");
let make = (~initial = 0, _children) => {
...component,
render: _self => {
let (count, setCount) = ReactHooks.useState(initial);
# vi-like navigation setw -g mode-keys vi
# mouse control for panes
set -g mouse on
# don't rename windows automagically
set-option -g allow-rename off
# start windows numbering at 1 and rename on window close
setw -g pane-base-index 1
set -g base-index 1
defmodule Producer do
require Logger
use GenStage
def start_link([]) do
Logger.info("starting producer")
GenStage.start_link(__MODULE__, :ok, name: __MODULE__)
end
def init(:ok) do
function useAsync() {
const [fn, setFn] = useState(null);
const [state, setState] = useState({
loading: false,
data: null,
error: null
});
const lastCallId = useRef(0);
useEffect(() => {
@frekw
frekw / zio-intro.scala
Created October 8, 2020 09:29
ZIO Intro
package example
import zio._
import zio.console
import zio.random._
import zio.duration._
import zio.clock
import scala.concurrent.Future
// What _is_ ZIO?
package zio_grpc.examples.helloworld
import io.grpc.Status
import scalapb.zio_grpc.ServerMain
import scalapb.zio_grpc.ServiceList
import scalapb.zio_grpc.{RequestContext, ZTransform}
import zio._
import zio.console._
import zio.stream._
@frekw
frekw / Exector.scala
Last active April 6, 2021 10:51
Caliban remote schemas
package gql.remoteschema
import zio._
import zio.query._
import caliban._
import caliban.schema._
import caliban.introspection.adt._
import caliban.execution.Field
import gql.remoteschema.json._
def accessLogger[R, E](
next: Http[R, E, Request, HttpResponse[R, E]]
): HttpApp[R with clock.Clock with Logging, E] = {
Http.flatten {
Http.fromEffectFunction[Request] { req =>
val path = req.url.path
val method = req.method
clock.instant.flatMap(start => {
val logSuccess = (resp: HttpResponse[R, E]) => {