Skip to content

Instantly share code, notes, and snippets.

View fancellu's full-sized avatar

Dino Fancellu fancellu

View GitHub Profile
@canthony
canthony / CreateContainer.java
Created June 6, 2012 08:11
Reading an excel spreadsheet and creating a Vaadin container : Not complete
public class CreateContainer {
public static void main(String[] args) throws IOException {
FileInputStream in = new FileInputStream("C:/temp/SampleData.xls");
POIFSFileSystem fileSystem = new POIFSFileSystem(in);
HSSFWorkbook workBook = new HSSFWorkbook(fileSystem);
HSSFSheet sheet = workBook.getSheetAt(0);
List<String> propertyNames = Collections.emptyList();
IndexedContainer c = new IndexedContainer();
for (Row row : sheet) {
int rowIndex = row.getRowNum();
@heathermiller
heathermiller / EdnPickleFormat.scala
Created June 11, 2013 20:09
A sample simplified edn PickleFormat for Scala Pickling. That's right, transfer data to a Clojure app! (Edn stands for "extensible data notation" and is Clojure's data transfer format.)
import scala.pickling._
import scala.reflect.runtime.universe._
import scala.util.parsing.json._
import scala.collection.mutable.{StringBuilder, Stack}
package object edn {
implicit val pickleFormat: EdnPickleFormat = new EdnPickleFormat
}
@fancellu
fancellu / PostProcessScalaxb.scala
Last active December 23, 2015 07:29
Quick app to postprocess source files. Created because Scalaxb was converting '-' to u45 in class names.
package com.felstar.playpen.scalaxb
import java.io.File
object PostProcessScalaxb {
def allFiles(path:File):List[File]= {
val (dirs,files)=path.listFiles.toList.partition(_.isDirectory)
files ::: dirs.flatMap(allFiles)
}
@jboner
jboner / how-akka-maps-to-eai-patterns.txt
Last active October 9, 2022 21:57
How Akka maps to EAI Patterns
# How Akka maps to EAI Patterns
Might be up for debate or just plain wrong. Just some notes I scribbled down some time ago.
-----------------------------------------------------------------------------------------------------------------
EAI PATTERN AKKA PATTERN REFERENCE
-----------------------------------------------------------------------------------------------------------------
Point to Point Channel Regular Actor Communication http://www.eaipatterns.com/PointToPointChannel.html
Event-Driven Consumer Regular Actor Receive http://www.eaipatterns.com/EventDrivenConsumer.html
Message Selector Actor with Stash http://www.eaipatterns.com/MessageSelector.html
@jboner
jboner / PersistedGameOfPingPong.scala
Last active March 27, 2019 16:43
A game of ping pong using two Akka Actors, persisted using Event Sourcing through Akka Persistence
package demo
import akka.actor.{Props, ActorSystem}
import akka.persistence.PersistentActor
object PingPong extends App {
case object Ball // The Command
case object BallReceived // The Domain Event, represents a Fact, something that have already happened
class Ping extends PersistentActor {
@jboner
jboner / GameOfPingPong.scala
Last active March 27, 2019 16:43
A game of ping pong using Akka Actors. For a version that is persisted using Event-Sourcing see this gist: https://gist.github.com/jboner/9990435
package demo
import akka.actor.{Actor, Props, ActorSystem}
object PingPong extends App {
case object Ball
class Ping extends Actor {
var counter = 0
@milessabin
milessabin / gist:c51b6851548dae403abf
Created May 9, 2014 10:11
Type safe selectDynamic without macros
miles@frege:~$ scala
Welcome to Scala version 2.11.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_55).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import scala.language.dynamics
import scala.language.dynamics
scala> case class Assoc[K, V](value: V)
defined class Assoc
@kevinwright
kevinwright / scaladays2014.md
Last active March 8, 2018 20:25
Scaladays 2014 slides

As compiled by Kevin Wright a.k.a @thecoda

(executive producer of the movie, and I didn't even know it... clever huh?)

please, please, please - If you know of any slides/code/whatever not on here, then ping me on twitter or comment this Gist!

This gist will be updated as and when I find new information. So it's probably best not to fork it, or you'll miss the updates!

Monday June 16th

@fancellu
fancellu / TimestampMacro.scala
Created July 22, 2014 09:43
Simple Macro example, allows you to have a string which shows when last compiled. Remember that your main has to be in a different project to the macro (for the moment)
package com.felstar.macros.timestamp
import scala.reflect.macros.blackbox.Context
import scala.language.experimental.macros
object TimestampMacro {
def timestampString: String = macro timestampMacro
def timestampMacro(c: Context): c.Tree = {
import c.universe._
@ScalaWilliam
ScalaWilliam / initialise.scala
Last active August 29, 2015 14:04
Embedded Jetty + Scalatra with Webjars loading (loads META-INF/resources data from the classpath jars). Works without any configuration in Jetty, jetty-maven-plugin, but not so easily in embedded form. Make sure to create websresources/index.html in your src/main/resources/ directory. Examples provided in Scalatra documentation are strange - set…
def initialiseApp[T<:LifeCycle](port: Int) = {
val server = new Server(port)
val context = new WebAppContext()
context.setContextPath("/")
context.setResourceBase(new File(getClass.getResource("/webresources/index.html").getFile).getCanonicalFile.getParentFile.getCanonicalPath)
context.addEventListener(new ScalatraListener)
context.addServlet(classOf[DefaultServlet], "/")
context.setInitParameter(ScalatraListener.LifeCycleKey, classOf[ConfiguredBootstrap].getCanonicalName)
context.setAttribute(WebInfConfiguration.WEBINF_JAR_PATTERN, ".*\\.jar$")