Skip to content

Instantly share code, notes, and snippets.

View Softsapiens's full-sized avatar

Daniel Pous Montardit Softsapiens

View GitHub Profile
@Softsapiens
Softsapiens / spacemacs-keybindings
Created September 26, 2018 08:53 — forked from adham90/spacemacs-keybindings
spacemacs keybindings that i need to learn
SPC s c remove highlight
**** Files manipulations key bindings
Files manipulation commands (start with ~f~):
| Key Binding | Description |
|-------------+----------------------------------------------------------------|
| ~SPC f c~ | copy current file to a different location |
| ~SPC f C d~ | convert file from unix to dos encoding |
| ~SPC f C u~ | convert file from dos to unix encoding |
@Softsapiens
Softsapiens / kafka-rebalancing.md
Created September 7, 2018 10:46 — forked from sahilsk/kafka-rebalancing.md
Kafka-rebalancing

Lets say i want to rebalance my-sample-topic topic on my kafka cluster

Create topcis.json

{
  "version": 1,
  "topics": [
 { "topic": "my-sample-topic" 
@Softsapiens
Softsapiens / builder.sh
Created July 27, 2018 09:17 — forked from jefdaj/builder.sh
Draft nix expression to wrap debian packages.
source $stdenv/setup
PATH=$dpkg/bin:$PATH
dpkg -x $src unpacked
cp -r unpacked/* $out/
@Softsapiens
Softsapiens / pause.scala
Created February 21, 2018 12:38 — forked from mpilquist/pause.scala
Pausing & resuming an FS2 stream
// Like interruptWhen / interrupt but allows resumption of the source stream.
def pauseWhen[F[_]: Async, A](controlSignal: Signal[F, Boolean]): Pipe[F, A, A] =
pause(controlSignal.discrete)
def pause[F[_]: Async, A](control: Stream[F, Boolean]): Pipe[F, A, A] = {
def unpaused(
controlFuture: ScopedFuture[F, Pull[F, Nothing, (NonEmptyChunk[Boolean], Handle[F, Boolean])]],
srcFuture: ScopedFuture[F, Pull[F, Nothing, (NonEmptyChunk[A], Handle[F, A])]]
): Pull[F, A, Nothing] = {
@Softsapiens
Softsapiens / switchMap.scala
Created February 21, 2018 12:37 — forked from mpilquist/switchMap.scala
FS2 version of switchMap
def switchMap[F[_]: Async, A, B](f: A => Stream[F, B]): Pipe[F, A, B] = {
def go(
outer: ScopedFuture[F, Pull[F, Nothing, (NonEmptyChunk[A], Handle[F, A])]],
inner: ScopedFuture[F, Pull[F, Nothing, (NonEmptyChunk[B], Handle[F, B])]]
): Pull[F, B, Nothing] = {
(outer race inner).pull.flatMap {
case Left(outer) =>
outer.optional.flatMap {
case None =>
inner.pull.flatMap(identity).flatMap { case (hd, tl) => Pull.output(hd) >> tl.echo }
package fs3
import cats.Monad
sealed abstract class Free[F[_], R] {
def flatMap[R2](f: R => Free[F, R2]): Free[F, R2] = Free.Bind(this, f)
}
object Free {
case class Pure[F[_], R](r: R) extends Free[F, R]
case class Eval[F[_], R](fr: F[R]) extends Free[F, R]
@Softsapiens
Softsapiens / Streams.hs
Created February 21, 2018 09:22 — forked from pchiusano/Streams.hs
Another effectful stream representation
{-# Language ExistentialQuantification #-}
{-# Language GADTs #-}
{-# Language RankNTypes #-}
{-# Language ScopedTypeVariables #-}
import Control.Monad
import Control.Applicative
import Data.List hiding (uncons)
import Data.Time
@Softsapiens
Softsapiens / half.scala
Created February 13, 2018 23:24 — forked from non/half.scala
Scala implementation of 16-bit floating point numbers. Also, a test prgoram.
package half
import scala.math.{pow, round, signum}
import scala.util.Random.nextInt
import java.lang.{Float => JFloat}
/**
* Float16 represents 16-bit floating-point values.
*
* This type does not actually support arithmetic directly. The
@Softsapiens
Softsapiens / IdeaVim OS X Key Repeat.markdown
Created January 24, 2018 13:01 — forked from lsd/IdeaVim OS X Key Repeat.markdown
Enable key-repeat for ALL applications or just for IdeaVim/specific JetBrains apps

Upgrading to Lion or Yosemite and WebStorm 9, I noticed key repeat was
turned off for the IdeaVim plugin h j k l keys.

System-wide key repeat

defaults write -g ApplePressAndHoldEnabled -bool false in a terminal will enable
key repeat for every app. This can alternatively be found in the accessibility settings in OS X' preferences.

App specific key repeat

package tinker.scalazEffect
import java.nio.ByteBuffer
import java.nio.channels.{AsynchronousChannel, AsynchronousFileChannel, CompletionHandler}
import java.nio.charset.{Charset, StandardCharsets}
import java.nio.file.{Path, Paths, StandardOpenOption}
import scalaz.data.Disjunction.{-\/, \/-}
import scalaz.effect.IO.IOTrampoline
import scalaz.effect.IO.IOTrampoline.{IOTDone, IOTMore}