Skip to content

Instantly share code, notes, and snippets.

@fdescamps
fdescamps / gitconfig.ini
Created April 12, 2016 12:28 — forked from tdd/gitconfig.ini
Nice, useful global Git configuration
# Put this in your ~/.gitconfig or ~/.config/git/config
# Windows users: "~" is your profile's home directory, e.g. C:\Users\<YourName>
[user]
name = Your Full Name
email = your@email.tld
[color]
# Enable colors in color-supporting terminals
ui = auto
[alias]
st = status

agnoster.zsh-theme

A ZSH theme optimized for people who use:

  • Solarized
  • Git
  • Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)

For Mac users, I highly recommend iTerm 2 + Solarized Dark

println( "High Order Functions" )
println( "http://danielwestheide.com/blog/2013/01/23/the-neophytes-guide-to-scala-part-10-staying-dry-with-higher-order-functions.html" )
println
case class Email(
subject: String,
text: String,
sender: String,
recipient: String
@fdescamps
fdescamps / testScalaPromise.scala
Created June 23, 2013 12:42
The Promise and Future are complementary concepts. The Future is a value which will be retrieved, well, sometime in the future and you can do stuff with it when that event happens. It is, therefore, the read or out endpoint of a computation - it is something that you retrieve a value from. A Promise is, by analogy, the writing side of the comput…
println( "Promise and Future" )
println( "http://danielwestheide.com/blog/2013/01/16/the-neophytes-guide-to-scala-part-9-promises-and-futures-in-practice.html" )
println
import concurrent._
import scala.util._
import scala.concurrent._
import scala.concurrent.ExecutionContext.Implicits.global
case class TaxCut(reduction: Int)
println( "Do you see the future ?")
println( "http://danielwestheide.com/blog/2013/01/09/the-neophytes-guide-to-scala-part-8-welcome-to-the-future.html")
// dummy implementations of the individual steps:
import scala.util._
import scala.concurrent._
import scala.concurrent.ExecutionContext.Implicits.global
@fdescamps
fdescamps / FizzBuzzTestScala.scala
Created June 18, 2013 11:04
// http://c2.com/cgi/wiki?FizzBuzzTest // "Write a program that prints the numbers from 1 to 100. // But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. // For numbers which are multiples of both three and five print “FizzBuzz”."
// Like a kata strophe
// http://c2.com/cgi/wiki?FizzBuzzTest
// "Write a program that prints the numbers from 1 to 100.
// But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”.
// For numbers which are multiples of both three and five print “FizzBuzz”."
println
println( "FizzBuzzTest - my 1rst Scala version" )
for( x <- 1 to 100 ){
x match {
case x if x%3==0 && x%5==0 => println( x + " FizzBuzz" )
// First Step with one value
/*trait User {
def name: String
}
class FreeUser(val name: String) extends User
class PremiumUser(val name: String) extends User
object FreeUser {
def unapply(user: FreeUser): Option[String] = Some(user.name)
@fdescamps
fdescamps / TestOption.scala
Last active December 18, 2015 12:49
Test Option Functions
// http://blog.tmorris.net/posts/scalaoption-cheat-sheet/
def carre( n:Int ) : Int = n*n
def someCarre( n:Int ) : Option[Int] = Some(n*n)
var option: Option[Int] = Some(5)
println( "flatMap" )
option match {
case None => None
case Some(x) => println("carre(x): " + carre(x) )
}