Skip to content

Instantly share code, notes, and snippets.

View joakim-ribier's full-sized avatar

Joakim Ribier joakim-ribier

View GitHub Profile
@joakim-ribier
joakim-ribier / gist:97186018f63b3af7317f8b6c6ec258a4
Created November 21, 2023 07:53 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@joakim-ribier
joakim-ribier / mocking_style.scala
Created January 29, 2019 09:11
scalamock - Mocking_style
import scala.concurrent.Future
import org.scalatest.{MustMatchers, WordSpec}
import org.scalamock.scalatest.MockFactory
trait AdditionHttpService {
def add(arg0: Int, arg1: Int): Future[Int]
}
Tracking and contributing to the trunk of a Subversion-managed project:
# Clone a repo (like git clone):
git svn clone http://svn.example.com/project/trunk
# Enter the newly cloned directory:
cd trunk
# You should be on master branch, double-check with 'git branch'
git branch
# Do some work and commit locally to git:
git commit ...

Keybase proof

I hereby claim:

  • I am joakim-ribier on github.
  • I am joakimribier (https://keybase.io/joakimribier) on keybase.
  • I have a public key whose fingerprint is B18D 9DCF FB55 E139 6A40 AE4A 39A3 CD2C 624A EC94

To claim this, I am signing this object:

C'est un tips que je gardais pour un atelier scala avancé :), mais voilà un aperçu :
En gros quand on `.map` une collection, le compilateur scala cherche toujours un CanBuildFrom en implicite pour savoir comment reconstruire la collection derrière (On y fait généralement pas attention, mais il est bien dans la définition de la fonction `final def map[B, That](f: (A) ⇒ B)(implicit bf: CanBuildFrom[List[A], B, That]): That`). Une instance de CanBuildFrom sert à dire : comment passer de telle collection contenant tels éléments à tel type de collection.
Ca arrive régulièrement que la manière dont il la reconstruit n'est pas ce qu'on veut, typiquement dans ce cas :
```
val m = List(1, 2, 3)
.map { i => (i.toString -> i * i) } // De base il va faire une List[Tuple2[String, Int]]
.toMap // Mais ce qu'on veut en réalité c'est une Map[String, Int], on doit faire une transformation supplémentaire.
```
@joakim-ribier
joakim-ribier / @scala.annotation.tailrec
Last active April 28, 2016 12:23
@scala.annotation.tailrec
/**
* List days from interval {from - to}.
*
* @return a seq of LocalDate
*/
private def splitDayByDay(from: LocalDate, to: LocalDate): Seq[LocalDate] = {
@scala.annotation.tailrec
def splitDayByDayWithAccumulator(accumulator: Seq[LocalDate], from: LocalDate, to: LocalDate): Seq[LocalDate] = {
if (from.isEqual(to)) accumulator
else {
@joakim-ribier
joakim-ribier / transform.scala
Last active February 22, 2016 06:02
[scala] Generic method transforms string to Enum
private def transform[T <: Enumeration](values: Option[String], enum: T): Option[Seq[T#Value]] = {
values.map(_.split(",").toSeq.map(f => enum.withName(f)))
}
@joakim-ribier
joakim-ribier / .conkyrc
Last active February 22, 2016 06:04
Conkyrc configuration file
background yes
font Bitstream Vera Sans:size=9
xftfont Bitstream Vera Sans:size=9
use_xft yes
xftalpha 0.1
update_interval 0.50
total_run_times 0
@joakim-ribier
joakim-ribier / free-space-on-boot-disk.md
Created October 21, 2015 21:46 — forked from jbgo/free-space-on-boot-disk.md
Free up space on /boot disk (ubuntu)

Free disk space when /boot is full (Ubuntu)

TL;DR

dpkg -l linux-image*
uname -r
sudo apt-get remove linux-image-2.6.32-{21,37,38,39,40,41,42,43,44}-server
sudo apt-get autoremove