Skip to content

Instantly share code, notes, and snippets.

Jan Christopher Vogt cvogt

Block or report user

Report or block cvogt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
cvogt / gist:0b681c6edfce504ca3553b336ca55ef7
Created Jan 9, 2019 — forked from jfeilbach/gist:fd109c7dbc9798ce6e47358b82d0be76
DNS over TLS (knot resolver) setup using on macOS
View gist:0b681c6edfce504ca3553b336ca55ef7
# Configuring DNS-over-TLS on macOS
# Worked on macOS 10.13.4
brew -v update
brew -v doctor
# Next two commands are optional
sudo chown -R $(whoami) $(brew --prefix)/*
echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.bash_profile
# Install DNS client
brew install knot-resolver
# Should be installed to something like: /usr/local/Cellar/knot-resolver/2.3.0/sbin/kresd
cvogt /
Last active Dec 26, 2018 — forked from alexeygrigorev/
Downloading segmented video from vimeo
#!/usr/bin/env python2.7
# based on
# also see
import requests
import base64
import sys
from tqdm import tqdm
cvogt / foo.scala
Created Feb 1, 2018
versioned serializers in scala
View foo.scala
case class Foo( bar: Bar )
case class Bar( bar: Baz )
case class Baz( bar: Booyah )
case class Booyah( i: Int, s: String )
object V1Serializers{
implicit def FormatFoo[Foo] = ...
implicit def FormatBar[Bar] = ...
implicit def FormatBaz[Baz] = ...
implicit def FormatBooyah[Booyah] = ...
cvogt / defaults-and-copy-ideas.scala
Last active Feb 22, 2017
Scala language proposals for defaults, .copy and overrides
View defaults-and-copy-ideas.scala
def foo(str: String = "test") = ???
assert( foo.str == "test" ) // new: named access to default values
case class Bar(str: String = "test")
assert( Bar.apply.str == "test" ) // same for case classes via .apply method
// REPETIION-FREE .copy (aka lenses light)
View MigrationCommands.scala
package com.pretend.myforklift
import com.liyaos.forklift.slick.{ SlickCodegen, SlickMigrationCommandLineTool, SlickMigrationCommands, SlickMigrationManager }
trait MyMigrationCommands extends SlickMigrationCommands
with MyMigrationFilesHandler {
this: SlickMigrationManager with SlickCodegen =>
View AnsiFilterStream.scala
package tut
import{ OutputStream, FilterOutputStream }
// FilterOutputStream that removes ANSI escapes. This should be fairly efficient, I guess, since
// it's all case switches on constants. Can inline more if needed but it seems fine. For the
// record, the format is ESC '[' digits (';' digits)* terminal
case class AnsiFilterStream(os: OutputStream) extends FilterOutputStream(os) {
case class State(apply: Int => State)

Getting Started in Scala

This is my attempt to give Scala newcomers a quick-and-easy rundown to the prerequisite steps they need to a) try Scala, and b) get a standard project up and running on their machine. I'm not going to talk about the language at all; there are plenty of better resources a google search away. This is just focused on the prerequisite tooling and machine setup. I will not be assuming you have any background in JVM languages. So if you're coming from Python, Ruby, JavaScript, Haskell, or anywhere…  I hope to present the information you need without assuming anything.

Disclaimer It has been over a decade since I was new to Scala, and when I was new to Scala, I was coming from a Java and Ruby background. This has probably caused me to unknowingly make some assumptions. Please feel free to call me out in comments/tweets!

One assumption I'm knowingly making is that you're on a Unix-like platform. Sorry, Windows users.

Getting the JVM

View PartiallyDynamicConfig.scala
object PartiallyDynamicConfig{
def main(args: Array[String]): Unit = {
sys.props.get("") getOrElse "",
View DynamicConfig.scala
object DynamicConfig{
def main(args: Array[String]): Unit = {
View SwitchableConfig.scala
object SwitchableConfig{
def main(args: Array[String]): Unit = {
val config = System.getProperty("config") match {
case "test" => Config("",10000)
case "production" => Config("",12345)
case _ => throw new Exception("unknown config: "+config)
} config )
You can’t perform that action at this time.