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-cheshe.md
Created December 22, 2017 10:26 — forked from robphoenix/spacemacs-cheshe.md
Spacemacs Cheat Sheet

Useful Spacemacs commands

  • SPC q q - quit
  • SPC w / - split window vertically
  • SPC w - - split window horizontally
  • SPC 1 - switch to window 1
  • SPC 2 - switch to window 2
  • SPC w c - delete current window
  • SPC TAB - switch to previous buffer
  • SPC b b - switch buffers
@Softsapiens
Softsapiens / install-multiple-jdk-on-macos-high-sierra.md
Created November 20, 2017 11:13 — forked from ntamvl/install-multiple-jdk-on-macos-high-sierra.md
Install Multiple Java Versions on macOS High Sierra

Install Multiple Java Versions on macOS High Sierra

Install Homebrew Cask

On Mac, Homebrew is the de-facto package manager, and Homebrew Cask is the app manager. I’m going to use Cask to install Java 7 and 8.

Install Homebrew Cask first if you haven’t:

brew update
brew tap caskroom/cask
@Softsapiens
Softsapiens / cps.scala
Created October 23, 2017 20:51 — forked from aaronlevin/cps.scala
Scala version of the blog post Resources, Laziness, and Continuation-Passing Style
object cps {
/**
*
* The code below translates this blog post
* http://blog.infinitenegativeutility.com/2016/8/resources--laziness--and-continuation-passing-style)
* into scala, and uses laziness where appropriate to highlight the issue.
*
* I also include a type for IO. This is mainly illustrative, but also ensures
* we "sequence" actions appropriately. Haskell's IO monad works in tandem with the
@Softsapiens
Softsapiens / ITraversal.scala
Created September 28, 2017 20:21 — forked from neutropolis/ITraversal.scala
Toying around with indexed traversals in Monocle
package monocle
import scalaz._, Scalaz._
import Indexable._
abstract class IPTraversal[I, S, T, A, B] {
def modifyF[
F[_]: Applicative,
@Softsapiens
Softsapiens / traverable-pimping-part2.scala
Created September 19, 2017 15:30 — forked from retronym/traverable-pimping-part2.scala
So close, yet so far, to a worthy pimp for the Traversables...
package scalaz
import collection.generic.CanBuildFrom
class TraversableW[Coll, A](val value: Coll)(implicit ev: Coll <:< Traversable[A]) {
def as[CC[X] <: Traversable[X]](implicit cbf1: CanBuildFrom[Coll, A, CC[A]] = null, cbfDefault: CanBuildFrom[Nothing, A, CC[A]]): CC[A] = {
Option(cbf1) match {
case Some(cbf) =>
// A direct builder exists from the source collection to the target
cbf(value).result
@Softsapiens
Softsapiens / SCombinator.scala
Created August 22, 2017 07:21 — forked from folone/SCombinator.scala
Y-Combinator in Scala
/**
* <b>Fixed Point Combinator is:</b>
* Y = λf.(λx.f (x x)) (λx.f (x x))
*
* <b>Proof of correctness:</b>
* Y g = (λf . (λx . f (x x)) (λx . f (x x))) g (by definition of Y)
* = (λx . g (x x)) (λx . g (x x)) (β-reduction of λf: applied main function to g)
* = (λy . g (y y)) (λx . g (x x)) (α-conversion: renamed bound variable)
* = g ((λx . g (x x)) (λx . g (x x))) (β-reduction of λy: applied left function to right function)
* = g (Y g) (by second equality) [1]
@Softsapiens
Softsapiens / gist:82602f73cd2aac490a1217d54f617bf9
Created July 25, 2017 10:58 — forked from milessabin/gist:1705644
Access to companion object of Foo via implicit resolution
trait Companion[T] {
type C
def apply() : C
}
object Companion {
implicit def companion[T](implicit comp : Companion[T]) = comp()
}
object TestCompanion {
@Softsapiens
Softsapiens / Open in iTerm.workflow
Created June 22, 2017 09:40 — forked from tkcranny/Open in iTerm.workflow
macOS Sierra Automater service to open iTerm2 from a finder window
-- Adapted from these sources:
-- http://peterdowns.com/posts/open-iterm-finder-service.html
-- https://gist.github.com/cowboy/905546
-- https://gist.github.com/ttimasdf/7bb02ed419db4b472b534e1a57008a3b
--
-- Modified to work with files as well, cd-ing to their container folder
on run {input, parameters}
tell application "Finder"
set my_file to first item of input
set is_folder to (do shell script "file -b " & quoted form of (POSIX path of my_file))
@Softsapiens
Softsapiens / cats-mtl.scala
Created May 23, 2017 11:08 — forked from aaronlevin/cats-mtl.scala
Does the cats-mtl design support for-comprehensions with multiple Monad constraints? Looks like it does!
package cats
import cats.data.{StateT, WriterT}
import cats.implicits._
/**
* TypeLevel is working on some alternative encodings of the Monad Transformer
* Library (MTL). The existing solution in cats was broken for a few reasons.
* One annoying issue made it imposisible to use for-comprehension with more
* than one Monad$FOO constraint owing to implicit resolution ambiguities.
@Softsapiens
Softsapiens / ST.scala
Created May 18, 2017 09:15 — forked from ariwaranosai/ST.scala
State Monad and STRef
/**
* Created by ariwaranosai on 16/8/28.
*
*/
import ST._
case class World[S]()
case class ST[S, A](f: World[S] => (World[S], A)) {