Skip to content

Instantly share code, notes, and snippets.

View cvogt's full-sized avatar

Jan Christopher Vogt cvogt

  • Symbiont.io
View GitHub Profile
@umpirsky
umpirsky / A.markdown
Last active August 3, 2023 18:14 — forked from olivierlacan/An_example.markdown
Sublime Text Monokai Sidebar Theme.
@gcatlin
gcatlin / gist:1847248
Created February 16, 2012 19:43
Install specific version of Homebrew formula
brew update
brew versions FORMULA
cd `brew --prefix`
git checkout HASH Library/Formula/FORMULA.rb # use output of "brew versions"
brew install FORMULA
brew switch FORMULA VERSION
git checkout -- Library/Formula/FORMULA.rb # reset formula
## Example: Using Subversion 1.6.17
#
import java.io.{File, FileInputStream, FileOutputStream}
import monix.eval.Task
import monix.execution.Ack
import monix.execution.Ack.{Continue, Stop}
import monix.reactive.{Consumer, Observable, Observer}
import scala.util.control.NonFatal
def copyFile(input: File, destination: File, chunkSize: Int): Task[Unit] =
Task.defer {
val in = new FileInputStream(input)
@dks77
dks77 / 99-login-german-fon
Last active October 10, 2021 00:12 — forked from cusspvz/99-login-fon
Telekom_FON Hotspot: auto-login bash script wget germany wispr client openwrt
#!/bin/sh
# place this file at: /etc/hotplug.d/iface/99-login-telekom_fon
# based on source: https://gist.github.com/cusspvz/3ab1ea9110f4ef87f0d2e1cd134aca67
#
# loginscript for german telekom_FON hotspot (NOT the general Telekom Hotspot)
# technic: uses HTTP POST formular; extract URLs from WIPSr
#
# Preparations
@cvogt
cvogt / gist:9239494
Last active September 9, 2019 01:30
Slick app architecture cheat sheet
// Please comment in case of typos or bugs
import scala.slick.driver.H2Driver._
val db = Database.for...(...)
case class Record( ... )
class Records(tag: Tag) extends Table[Record](tag,"RECORDS"){
...
def * = ... <> (Record.tupled,Record.unapply)
// place additional methods here which return values of type Column
@adriaanm
adriaanm / nightly.sbt
Created December 11, 2016 19:13
How to use the latest Scala nightly build from your sbt build by @SethTisue
// originally by @SethTisue, see http://stackoverflow.com/questions/40622878/how-do-i-tell-sbt-to-use-a-nightly-build-of-scala-2-11-or-2-12/40622879#40622879
resolvers += "nightlies" at "https://scala-ci.typesafe.com/artifactory/scala-release-temp/"
scalaVersion := {
val propsUrl = new URL("https://scala-ci.typesafe.com/job/scala-2.12.x-integrate-bootstrap/lastSuccessfulBuild/artifact/jenkins.properties/*view*/")
val props = new java.util.Properties
props.load(propsUrl.openStream)
props.getProperty("version")
}
scalaBinaryVersion := "2.12"
@aloiscochard
aloiscochard / Stream.scala
Created November 2, 2011 16:06
Scala [In]finite Stream Constructor
import Stream._
/** A possibly finite stream that repeatedly applies a given function to a start value.
*
* @param start the start value of the stream
* @param f the function that's repeatedly applied
* @return the stream returning the possibly finite sequence of values `start, f(start), f(f(start)), ...`
*/
def iterate[A](f: A => A, a: A): Stream[A] = unfold((x: A) => Some((x, f(x))), a)
// optionally filter on a column with a supplied predicate
case class MaybeFilter[X, Y](val query: scala.slick.lifted.Query[X, Y]) {
def filter[T](data: Option[T])(f: T => X => scala.slick.lifted.Column[Boolean]) = {
data.map(v => MaybeFilter(query.filter(f(v)))).getOrElse(this)
}
}
// example use case
def find(id: Option[Int], createdMin: Option[Date], createdMax: Option[Date], modifiedMin: Option[Date], modifiedMax: Option[Date]) = {
@etorreborre
etorreborre / implicits.scala
Created May 25, 2016 06:35
Show applied implicits in the REPL
scala> import cats.implicits._
import cats.implicits._
scala> (1 -> 2) === (1 -> 3)
res0: Boolean = true
scala> import scala.reflect.runtime.universe._
import scala.reflect.runtime.universe._
scala> showCode(reify { (1 -> 2) === (1 -> 3) }.tree)
@pedrofurla
pedrofurla / git-branches-by-commit-date.sh
Created November 4, 2016 18:59 — forked from jasonrudolph/git-branches-by-commit-date.sh
List remote Git branches and the last commit date for each branch. Sort by most recent commit date.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r