Skip to content

Instantly share code, notes, and snippets.

@note
note / EinsteinsRiddle.als
Created May 21, 2020 19:13
Alloy tutorial: Static modelling: Einstein's riddle
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 / npminstall.sh
Last active May 8, 2022 06:48
Automate creating nix-shell environments with node2nix
#!/bin/bash
# Exit on any failure
set -e
if [ "$#" -lt 1 ]; then
echo "Expected at least one parameter (npm package name)"
exit 1
fi
@note
note / Bicycle.als
Created May 21, 2020 19:12
Alloy tutorial: Static modelling
// 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 18:23
Code snippet for Alloy tutorial: Basics
// Signatures:
sig A {}
// Predicates and facts
pred show {}
// Assertions:
// Commands
run show for 3
### 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 April 23, 2020 12:55
Slightly modified version of https://github.com/defunkt/repl/blob/master/bin/repl script, adjusted for tlarepl
#!/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
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}
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 {
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
[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