Skip to content

Instantly share code, notes, and snippets.

View Tvaroh's full-sized avatar
😻
Happy programming

Aliaksandr Siamionau Tvaroh

😻
Happy programming
View GitHub Profile
@catostrophe
catostrophe / shims.scala
Created May 24, 2021 15:01
Tofu-Trace4Cats integration
package tofu.trace4cats
import cats.Monad
import io.janstenpickle.trace4cats.base.context.{Lift => T4cLift, Local => T4cLocal, Provide => T4cProvide}
import io.janstenpickle.trace4cats.base.optics.{Getter, Lens}
import tofu.{WithLocal, WithRun}
import tofu.lift.{Lift => TofuLift}
import tofu.optics.{Contains, Extract}
object shims extends ShimsLowPriority {
@Odomontois
Odomontois / SourceLazyOps.scala
Created April 5, 2018 15:48
Source lazy concat
implicit class SourceLazyOps[E, M](val src: Source[E, M]) extends AnyVal {
def concatLazy[M1](src2: => Source[E, M1]): Source[E, NotUsed] =
Source(List(() => src, () => src2)).flatMapConcat(_ ())
}
@popravich
popravich / PostgreSQL_index_naming.rst
Last active March 25, 2024 12:42
PostgreSQL index naming convention to remember

The standard names for indexes in PostgreSQL are:

{tablename}_{columnname(s)}_{suffix}

where the suffix is one of the following:

  • pkey for a Primary Key constraint;
  • key for a Unique constraint;
  • excl for an Exclusion constraint;
  • idx for any other kind of index;
@CptLemming
CptLemming / app.jsx
Created April 14, 2015 13:12
Morearty & React Router example
/**
* This example shows using Morearty and React Router together in a single app.
*
* Both libraries expect to be the 'top-level-item' by default, which causes conflict.
* The `currentRoute` here is especially important, as this allows the components to re-render
* when the Route changes. Without this the `shouldComponentUpdate` of Morearty will
* return `false`, preventing routing.
*
* Morearty - https://github.com/moreartyjs/moreartyjs
* React Router - https://github.com/rackt/react-router
@ochrons
ochrons / gist:10681050
Last active March 26, 2018 15:21
Super thin Scala wrapper for common DataStax Cassandra Java driver functionality.
object CassandraWrapper {
import scala.language.implicitConversions
import scala.language.postfixOps
/**
* Converts a `ResultSetFuture` into a Scala `Future[ResultSet]`
* @param f ResultSetFuture to convert
* @return Converted Future
*/
implicit def resultSetFutureToScala(f: ResultSetFuture): Future[ResultSet] = {
val p = Promise[ResultSet]()