Skip to content

Instantly share code, notes, and snippets.

@bishabosha
bishabosha / loops.scala
Last active November 15, 2023 03:56
Scala break/continue zero-cost loop abstraction
//> using scala "3.3.0"
import scala.util.boundary, boundary.break
object Loops:
type ExitToken = Unit { type Exit }
type ContinueToken = Unit { type Continue }
type Exit = boundary.Label[ExitToken]
@BjRo
BjRo / unions.scala
Created February 10, 2017 16:56
union types in sangria
object ProfileRef {
val inactiveDefinition = ObjectType(
"InactiveProfileRef",
"An inactive profile",
fields = fields[UserContext, JsObject](
Field("id", IntType, None, resolve = ctx => (ctx.value \ "id").as[Int])
)
)
val activeDefinition = ObjectType(
@0xjac
0xjac / private_fork.md
Last active July 3, 2024 05:19
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare git@github.com:usi-systems/easytrace.git

@caiguanhao
caiguanhao / split-nginx-logs.md
Last active August 2, 2017 04:01
Split nginx logs

Suppose you have these logs:

access.log
api.access.log
api.error.log
frontend.access.log
frontend.error.log
services.access.log
@cvogt
cvogt / pre-commit-hook-install.sh
Created June 16, 2015 19:27
git pre-commit hook for Scala compile and format checking (put both in your git project root, needs to be installed in each clone)
#!/bin/sh
cd "$(dirname "$0")"
touch .git/hooks/pre-commit
rm .git/hooks/pre-commit
ln -s ../../pre-commit-hook.sh .git/hooks/pre-commit