Skip to content

Instantly share code, notes, and snippets.

View naderghanbari's full-sized avatar

Nader Ghanbari naderghanbari

View GitHub Profile
@naderghanbari
naderghanbari / PostGISProfile.scala
Last active December 28, 2019 02:42
Scala, Slick, and PostGIS :: PostGISProfile.scala + SlickSchema.scala
package infra.slick
import com.github.tminglei.slickpg._
trait PostGISProfile extends ExPostgresProfile with PgPostGISSupport {
object ExtendedAPI extends API with PostGISImplicits
override val api = ExtendedAPI
}
object PostGISProfile extends PostGISProfile
@naderghanbari
naderghanbari / Building.scala
Created December 27, 2019 02:23
Scala, Slick, and PostGIS :: Building Domain object
package domain
import java.util.UUID
import org.locationtech.jts.geom.Point
case class Building(id: UUID, name: String, coordinate: Point)
@naderghanbari
naderghanbari / build.sbt
Last active December 28, 2019 02:39
Scala, Slick, and PostGIS :: build.sbt
resolvers += Resolver.jcenterRepo
libraryDependencies ++= Seq(
"org.postgresql" % "postgresql" % "42.2.9",
"com.typesafe.slick" %% "slick" % "3.3.2",
"com.typesafe.slick" %% "slick-hikaricp" % "3.3.2",
"io.github.nafg" %% "slick-migration-api" % "0.7.0",
"com.github.tminglei" %% "slick-pg_jts_lt" % "0.18.1" exclude ("org.postgresql", "postgresql"),
)
@naderghanbari
naderghanbari / pascal.scala
Created April 11, 2019 04:14
Pascal Triangle in Scala
def nextRow(r: Stream[Long]) =
(0L #:: r).sliding(2).map(_.sum).toStream :+ 1L
val pascal =
continually(empty).scanLeft(Stream(1L)) { (r, _) => nextRow(r) }
@naderghanbari
naderghanbari / gitlab_group_checkout_all.py
Last active November 16, 2018 01:52
Gitlab Python script to checkout all Projects belonging to a Group
#!/usr/bin/env python3
# Usage: ./gitlab_group_checkout_all.py -g group_name -d target_dir
# Assumes there is a default configuration and python-gitlab is installed
# https://python-gitlab.readthedocs.io/en/stable/cli.html#cli-configuration
# Work with GitLab API V4 (gitlab-python version 1.6.x)
import getopt, shlex, subprocess, sys, gitlab