Skip to content

Instantly share code, notes, and snippets.

View aloiscochard's full-sized avatar
🪄

Aloïs Cochard aloiscochard

🪄
View GitHub Profile
@aloiscochard
aloiscochard / gist:8c45fbf8c967880b80b33c2b77d66e88
Last active October 17, 2023 07:25
PinePhone Pro Survival
# Install
- Mobian latest weekly
- https://images.mobian.org/pinephonepro/weekly/
- Disable software updates
- Set timezone
- sudo apt install openssh-server
- Enable flatpak: flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
- Install flatpauk apps: Cinny, Pomodoro, Chromatic
- Sync: Nextcloud
@aloiscochard
aloiscochard / fun-deps.scala
Last active September 11, 2016 16:39
Fun with fun-deps in scala.
/*
object Test0 {
import scalaz.meta.Foo._
val s: String = 1024.bar
val i: Int = "test".bar
println(s) // bar
println(i) // 42
}
*/
@aloiscochard
aloiscochard / scala-kinds.md
Created January 17, 2016 11:06
Scala - Identifying Kinds

Identification scheme for Scala kind annotations.

The number of parameters is followed by an optional list of of modifiers, starting with a letter to indicate the parameter rank and optionally swapping the case from the previous letter in case the type at this position is also higher kinded.

Examples:

  • [_]
    • 1
  • [_, _]
  • 2
@aloiscochard
aloiscochard / oplog.hs
Created January 18, 2015 11:35
Tailing MongoDB OpLog in Haskell
{-# LANGUAGE OverloadedStrings #-}
module Mongolito where
import Control.Exception
import Control.Monad.IO.Class (liftIO)
import Database.MongoDB
import System.Log.Logger
localDb :: Database
localDb = "local"
@aloiscochard
aloiscochard / 0-common.Module.scala
Last active September 11, 2016 16:02
Dependency Injection in Scala without Cake Pattern
package com.acme
import com.typesafe.config.Config
trait Module {
implicit def config: Config
}
package com.timeout
import scala.language.higherKinds
import scalaz._
trait Transfigure[A, B, T] {
def apply(x: A, f: B): T
}
@aloiscochard
aloiscochard / gist:10062325
Created April 7, 2014 21:34
Golden Rules

"A designer knows he has achieved perfection not when there is nothing left to add,but when there is nothing left to take away." - Antoine de Saint-Exupéry

"One person's syntax is another person's semantics." -- Joseph Goguen

"Ugly programs are like ugly suspension bridges: they're much more liable to collapse than pretty ones, because the way humans (especially engineer-humans) perceive beauty is intimately related to our ability to process and understand complexity. A language that makes it hard to write elegant code makes it hard to write good code." - Eric S. Raymond

"It is better to have 100 functions operate on one data structure than to have 10 functions operate on 10 data structures." - Alan J. Perlis

"Simple things should be simple and complex things should be possible." - Alan Kay

@aloiscochard
aloiscochard / Compute.scala
Created December 9, 2013 11:35
Compute: A very simple language for addition/substraction.
import scala.util.parsing.combinator._
import scala.util.matching._
object Compute {
sealed trait Expression
object Expression {
case class Literal(value: Int) extends Expression
case class Apply(operator: Operator, lhs: Expression, rhs: Expression) extends Expression
@aloiscochard
aloiscochard / Action.scala
Created December 1, 2013 10:39
Slick monadic Actions
package slick
/**
* This is some code extracted from TimeOut codebase, demonstrating:
* - Use of tag typed to avoid mixing session of different DB
* - The use of the Reader Monad to compose Actions together and defer the choice of async/sync computation
*
* I remove the part where we can say if our operation are read only or not (to use different connection), in order to
* make things easier.
**/
@aloiscochard
aloiscochard / qsbt.sh
Last active March 5, 2018 21:34
QuickSBT - Launch SBT with support for generating /tmp/sbt.quickfix file for Vim
#!/usr/bin/env bash
############
# QuickSBT #
############
# Launch SBT with support for generating /tmp/sbt.quickfix file for Vim
# http://github.com/aloiscochard / https://gist.github.com/4698501
# Error format for SBT, and shortcut to open SBT quickfix file :