Skip to content

Instantly share code, notes, and snippets.

View strobe's full-sized avatar

strobe strobe

View GitHub Profile
@julianlam
julianlam / expose-directory-on-host-to-lxc-container.md
Last active March 22, 2025 08:11
Exposing a directory on the host machine to an LXC container #blog

Exposing a directory on the host machine to an LXC container

  1. Log into the container and create an empty directory, this will be the mount point
  2. Log out and stop the container.
  3. Open to your container's config file
    • For regular LXC containers: /var/lib/lxc/mycontainer/config
    • For unprivileged LXC containers: $HOME/.local/share/lxc/mycontainer/config
  4. Add a new line above the lxc.mount directive, that follows the format below. Substitute proper paths as necessary:
    • lxc.mount.entry = /path/to/folder/on/host /path/to/mount/point none bind 0 0
  • Both of these paths are relative to the host machine.
@marioosh
marioosh / ChatRoom.scala
Last active March 1, 2020 08:11
websocket based on akka-http
class ChatRoom(roomId: Int, actorSystem: ActorSystem) {
private[this] val chatRoomActor = actorSystem.actorOf(Props(classOf[ChatRoomActor], roomId))
def websocketFlow(user: String): Flow[Message, Message, _] = ???
def sendMessage(message: ChatMessage): Unit = chatRoomActor ! message
}
@cb372
cb372 / jargon.md
Last active May 14, 2024 03:45
Category theory jargon cheat sheet

Category theory jargon cheat sheet

A primer/refresher on the category theory concepts that most commonly crop up in conversations about Scala or FP. (Because it's embarassing when I forget this stuff!)

I'll be assuming Scalaz imports in code samples, and some of the code may be pseudo-Scala.

Functor

A functor is something that supports map.

@knshiro
knshiro / build.sbt
Created August 5, 2015 08:35
Publish a deb with sbt and sbt-native-packager to bintray
import _root_.bintray.Bintray
enablePlugins(JavaAppPackaging, JDebPackaging)
name := "my-project"
maintainer := "My name <[email protected]>"
packageSummary := "Super package"
@EncodePanda
EncodePanda / Scala and Emacs with Ensime. Guide for frustrated IDEA users.md
Last active June 13, 2018 08:04
Scala and Emacs with Ensime. Guide for frustrated IDEA users.
@ba0f3
ba0f3 / compile-emacs.sh
Last active July 19, 2017 02:00
Compile emacs 25.1 on CentOS 6.x
yum install gcc make ncurses-devel giflib-devel libjpeg-devel libtiff-devel
wget http://ftp.twaren.net/Unix/GNU/gnu/emacs/emacs-25.1.tar.xz
tar xJf emacs-*
cd emacs-*
./configure --without-x --without-selinux
make && make install
@pvoznenko
pvoznenko / circe-loop-json-object-example.md
Last active May 11, 2018 19:25
How to loop through json object and change values with circe, scala

How to go through json object and change values with Circe in Scala

Small gist with some demo trait that shows an example on how to loop through json object and change values with circe in Scala.

Code example you can find below at circe-loop-json-object-example.scala.

The input JSON for test is kinda in in DynamoDB dump format:

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
sealed trait Task[A] {
import Task._
final def flatMap[B](f: A => Task[B]): Task[B] = Suspend(this, f)
final def map[B](f: A => B): Task[B] = this match {
case Suspend(inner, suspension) =>
Suspend(inner, suspension andThen { _ map f })
case Async(body) =>
@notxcain
notxcain / cofree.scala
Created December 13, 2016 08:32
Streams for (Co)free
import cats.data.Kleisli
import cats.implicits._
import cats.{Applicative, FlatMap, Functor, Monad, Monoid, ~>}
final case class Cofree[F[_], A](head: A, tail: F[Cofree[F, A]]) {
def map[B](f: A => B)(implicit F: Functor[F]): Cofree[F, B] =
Cofree(f(head), F.map(tail)(_.map(f)))
def zip[B](other: Cofree[F, B])(implicit F: Applicative[F]): Cofree[F, (A, B)] =
Cofree((head, other.head), (tail |@| other.tail).map(_ zip _))