Skip to content

Instantly share code, notes, and snippets.

Avatar

Michal Sitko note

View GitHub Profile
@note
note / EinsteinsRiddle.als
Created May 21, 2020
Alloy tutorial: Static modelling: Einstein's riddle
View EinsteinsRiddle.als
open util/ordering[House]
enum Color {Red, White, Blue, Green, Yellow}
enum Pet {Birds, Cats, Dogs, Fish, Horses}
enum Cigar {Blend, BlueMaster, Dunhill, PallMall, Prince}
enum Beverage {Beer, Coffee, Milk, Tea, Water}
@note
note / Bicycle.als
Created May 21, 2020
Alloy tutorial: Static modelling
View Bicycle.als
// Wheel: {Wheel0, Wheel1, Wheel2}
sig Wheel {}
// Bicycle: {Bicycle0, Bicycle1, Bicycle2}
sig Bicycle {
// Bicycle.front: {
// Bicycle0 -> Wheel2,
// Bicycle1 -> Wheel2,
// Bicycle2 -> Wheel1
// }
@note
note / Basic.als
Created May 21, 2020
Code snippet for Alloy tutorial: Basics
View Basic.als
// Signatures:
sig A {}
// Predicates and facts
pred show {}
// Assertions:
// Commands
run show for 3
View gist:196380c1624c43d46ca258f5747ef404
### Keybase proof
I hereby claim:
* I am note on github.
* I am msitko (https://keybase.io/msitko) on keybase.
* I have a public key ASCjqjpF5Qgj4F5eybqjeMlFPqA9MUOgs-Y6Igprkgn1uAo
To claim this, I am signing this object:
@note
note / repl
Created Apr 23, 2020
Slightly modified version of https://github.com/defunkt/repl/blob/master/bin/repl script, adjusted for tlarepl
View repl
#!/usr/bin/env ruby
# repl(1) -- sometimes you need a repl
#
# repl is an interactive program which tenderly wraps another,
# non-interactive program.
#
# For example:
#
# $ repl redis-cli
@note
note / npminstall.sh
Last active Apr 21, 2020
Automate creating nix-shell environments with node2nix
View npminstall.sh
#!/bin/bash
# Exit on any failure
set -e
if [ "$#" -lt 1 ]; then
echo "Expected at least one parameter (npm package name)"
exit 1
fi
View gist:bd4cc47830f3972f6f606859a4930131
import akka.NotUsed
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.Http.HostConnectionPool
import akka.http.scaladsl.model.{HttpRequest, HttpResponse}
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.{Flow, Sink, Source}
import scala.util.{Failure, Success, Try}
View gist:b7071b4555549919adf6cdf26c61cce8
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.Http.HostConnectionPool
import akka.http.scaladsl.model.{HttpRequest, HttpResponse}
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.{Flow, Sink, Source}
import scala.util.{Failure, Success, Try}
object Main {
View akka-http.scala
package com.example
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model._
import akka.http.scaladsl.server.Directives._
import akka.stream.{ActorMaterializer, Materializer}
import akka.stream.scaladsl.{Sink, Source, StreamConverters}
import akka.util.ByteString
View gist:1726714adf7dffd856a9715b338812a5
[ERROR] [02/16/2017 16:27:50.411] [my-system-akka.actor.default-dispatcher-4] [akka://my-system/user/StreamSupervisor-0/flow-1-0-unknown-operation] Error in stage [akka.http.impl.engine.rendering.HttpResponseRendererFactory$HttpResponseRenderer$@dad2916]: java.util.concurrent.TimeoutException: Futures timed out after [5 seconds]
java.io.IOException: java.util.concurrent.TimeoutException: Futures timed out after [5 seconds]
at akka.stream.impl.io.OutputStreamAdapter$$anonfun$sendMessage$1.apply$mcV$sp(OutputStreamSourceStage.scala:198)
at akka.stream.impl.io.OutputStreamAdapter.send(OutputStreamSourceStage.scala:169)
at akka.stream.impl.io.OutputStreamAdapter.sendMessage(OutputStreamSourceStage.scala:188)
at akka.stream.impl.io.OutputStreamAdapter.close(OutputStreamSourceStage.scala:216)
at com.example.WebServer$$anonfun$2$$anonfun$apply$3$$anonfun$3.apply(WebServer.scala:36)
at com.example.WebServer$$anonfun$2$$anonfun$apply$3$$anonfun$3.apply(WebServer.scala:34)
at akka.stream.impl.MaterializerSession
You can’t perform that action at this time.