Skip to content

Instantly share code, notes, and snippets.

View fancellu's full-sized avatar

Dino Fancellu fancellu

View GitHub Profile
@CliffordAnderson
CliffordAnderson / collect.cypher
Last active July 10, 2018 15:59
A Cypher examples to unwind and collect
match (a {name:"Daniel"}), (b {name:"Jerry"})
with a,b
match s = shortestPath(a-[]-b)
unwind nodes(s) as n
with collect(n) as m
return head(m)
@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();
@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

@ScalaWilliam
ScalaWilliam / WSWithoutPlayApp.scala
Last active June 1, 2017 16:16
Running Play WS standalone, without a Play App. Works with Maven builds nicely. The top way to make REST calls in Scala, in my opinion.
package com.scalawilliam.example.play
import play.api.libs.ws._
/**
* Play's Scala WS library is very very cool. Provides you with plenty niceties.
* See more: https://www.playframework.com/documentation/2.3.x/ScalaWS
*
* Unfortunately it by default requires a Play application context.
* But you do not necessarily always want that.
@lihaoyi
lihaoyi / trace.scala
Last active December 27, 2015 19:32
Downloading JSON and splatting it into some files in 4 lines of Scala with Ammonite http://lihaoyi.github.io/Ammonite/
haoyi-mbp:Ammonite haoyi$ ~/amm
Loading...
Welcome to the Ammonite Repl 0.5.2
(Scala 2.11.7 Java 1.8.0_25)
haoyi-Ammonite@ load.ivy("org.scalaj" %% "scalaj-http" % "2.2.0")
haoyi-Ammonite@ import ammonite.ops._, scalaj.http._
import ammonite.ops._, scalaj.http._
haoyi-Ammonite@ Http("https://api.github.com/repos/scala/scala").asString
res2: HttpResponse[String] = HttpResponse(
@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)
}
@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
}
myfine.domain.user.actor.handlers.BetterAnonymousClassApp$$anon$1(mutingStuff = let's see, otherStuff = List(works, too), stuff = works, moreLazyStuff = myfine.domain.user.actor.handlers.BetterAnonymousClassApp$$anon$1$$anon$2(extensionData = This is just some extension data))
Disconnected from the target VM, address: '127.0.0.1:55780', transport: 'socket'
{
"mutingStuff" : "let's see",
"otherStuff" : [ "works, too" ],
"stuff" : "works",
"moreLazyStuff" : {
"extensionData" : "This is just some extension data"
}
}
@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$")
@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._