Skip to content

Instantly share code, notes, and snippets.

View andypetrella's full-sized avatar

Andy Petrella andypetrella

View GitHub Profile

What is Scala?


Créé par Martin en 2003 -- Son nom vient de l'anglais Scalable language Scala intègre les paradigmes de programmation orientée objet et de programmation fonctionnelle, avec un typage statique


  1. Fonctionnel basique

a) Immutability

@andypetrella
andypetrella / sample-dsl.scala
Last active December 11, 2015 04:18
Un exemple de DSL très simple avec Scala
case class Banque(nom:String) {banque =>
def accepte(m:Montant) =
CompteBuilder(banque, m)
}
implicit def stringToBanque(s:String) = Banque(s)
implicit def intWithDevise(i:Int) = new {
@Thell
Thell / Exmple.Rmd
Created June 20, 2013 23:59
R markdown to illustrate creation of in-document referencing for chunks, sections, pages, and such.
```{r setup, echo=FALSE, results='hide'}
chunkref <- local({
function(chunklabel) {
sprintf('[%s](#%s)', chunklabel, chunklabel )
}
})
secref <- local({
function(seclabel) {
sprintf('[%s](#%s)', seclabel, seclabel )
@helena
helena / ProvisioningActor.scala
Last active December 21, 2015 04:39
Rough, initial cut of a trait to mixin when an Actor requires initalization, where the initialization is long and arduous (for example, data initialization related). This strategy allows the implementing actor to delegate the work to another Actor, on a separate, dedicated Dispatcher, and not block any other related Actors in load-time.
import scala.collection.immutable
import scala.collection.immutable.Queue
import akka.actor._
/**
* Rough, initial cut of a trait to mixin when an Actor requires
* initalization, where the initialization is long and arduous (for
* example, data initialization related). This strategy allows the
* implementing actor to delegate the work to another Actor, on a
* separate, dedicated Dispatcher, and not block any other related
@etrepum
etrepum / Bob.hs
Created August 27, 2013 02:09
One pass Bob parser
module Bob (responseFor) where
import Data.Char (isSpace, isLower, isAlpha)
import Control.Applicative ((<$>), (<*>), (<|>))
data Prompt = Silence | Yell | Question | Other
deriving (Show, Eq)
data P a = P { pCanParse :: Char -> Bool
, pParse :: Char -> Either (P a) (Maybe a)
, pParseEOF :: Maybe a
}
@cjmatta
cjmatta / spark-notebook_mapr.md
Last active December 22, 2015 02:06
Building and using Spark Notebook for MapR

##Building and using Spark Notebook for MapR

The spark-notebook is a useful browser-based REPL that can be used to explore data and build visualizations. This guide will illustrate the MapR-specific requirements for building, and using the spark notebook on MapR clusters.

###Building Checkout the source:

$ git clone https://github.com/andypetrella/spark-notebook.git
@pchiusano
pchiusano / partask.scala
Created February 12, 2014 22:10
Applicative for scalaz.concurrent.Task that 'automatically' parallelizes the applicative operations
import scalaz.Applicative
import scalaz.concurrent.Task
/**
* This `Applicative[Task]` runs tasks in parallel, by defining
* `ap` and `apply2` in terms of `mapBoth`. This differs from the
* default `Applicative[Task]`, where effects are sequenced
* deterministically, in left to right order.
*/
val T = new Applicative[Task] {
@ayosec
ayosec / CORSDirectives.scala
Created December 18, 2012 03:28
CORS with Spray
package foo.bar
import spray.routing._
import spray.http._
import spray.http.StatusCodes.Forbidden
// See https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS
case class Origin(origin: String) extends HttpHeader {
@wilhelmberg
wilhelmberg / install-sublime-text-ubuntu.md
Last active November 21, 2021 11:14
install and run **LINUX** sublime text 3 on Windows 10 Linux Subsystem "Ubuntu bash"
sudo add-apt-repository ppa:webupd8team/sublime-text-3
sudo apt-get update
sudo apt-get install sublime-text-installer

run /opt/sublime_text/sublime_text or sudo ln -s /opt/sublime_text/sublime_text /usr/local/bin/subl

with ubuntu bash on Windows 10 and Xming:

@debasishg
debasishg / gist:8172796
Last active March 15, 2024 15:05
A collection of links for streaming algorithms and data structures

General Background and Overview

  1. Probabilistic Data Structures for Web Analytics and Data Mining : A great overview of the space of probabilistic data structures and how they are used in approximation algorithm implementation.
  2. Models and Issues in Data Stream Systems
  3. Philippe Flajolet’s contribution to streaming algorithms : A presentation by Jérémie Lumbroso that visits some of the hostorical perspectives and how it all began with Flajolet
  4. Approximate Frequency Counts over Data Streams by Gurmeet Singh Manku & Rajeev Motwani : One of the early papers on the subject.
  5. [Methods for Finding Frequent Items in Data Streams](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.187.9800&amp;rep=rep1&amp;t