Skip to content

Instantly share code, notes, and snippets.

View ripla's full-sized avatar

Risto Yrjänä ripla

View GitHub Profile
@ripla
ripla / MongoExample1-1.scala
Created August 15, 2012 21:08
Scaladin registration example 1-1: basic application with a Mongo connection.
import vaadin.scala._
import com.mongodb.casbah.Imports._
import com.novus.salat.grater
import com.novus.salat.global._
import scala.util.Random
import scala.reflect.BeanProperty
class MongoExample extends Application("Mongo & Vaadin, tied together with Scala") {
val registrations: MongoCollection = MongoConnection()("vaadin-scala-mongo-example")("registrations")
@ripla
ripla / MongoExample1-2.scala
Created August 16, 2012 17:58
Scaladin registration example 1-2: table and form added
import vaadin.scala._
import com.mongodb.casbah.Imports._
import com.novus.salat.grater
import com.novus.salat.global._
import scala.util.Random
import scala.reflect.BeanProperty
class MongoExample extends Application("Mongo & Vaadin, tied together with Scala") {
val registrations: MongoCollection = MongoConnection()("vaadin-scala-mongo-example")("registrations")
@ripla
ripla / MongoExample1-3.scala
Created August 16, 2012 19:23
Scaladin registration example 1-3: added application logic
import vaadin.scala._
import com.mongodb.casbah.Imports._
import com.novus.salat.grater
import com.novus.salat.global._
import scala.util.Random
import scala.reflect.BeanProperty
class MongoExample extends Application("Mongo & Vaadin, tied together with Scala") {
val registrations: MongoCollection = MongoConnection()("vaadin-scala-mongo-example")("registrations")
@ripla
ripla / recoverAndZipTest.java
Created June 5, 2013 08:44
Test for combining different futures and handling exceptions along the way
public class FutureCombinationTest {
private final ActorSystem actorSystem = ActorSystem.create(
"test",
ConfigFactory.load().withValue("akka.actor.default-dispatcher.type",
ConfigValueFactory.fromAnyRef("akka.testkit.CallingThreadDispatcherConfigurator")));
private static class Result {
private final boolean isComplete;
@ripla
ripla / CakeMVPTest.scala
Created May 16, 2014 18:03
Quick draft of View-Presenter injection with the cake pattern
trait SomeView {
def render(): Unit
def init(): Unit
}
trait SomeViewComponent {
this: SomePresenterComponent =>
val someView: SomeView
@ripla
ripla / 0_reuse_code.js
Created July 4, 2014 09:47
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ripla
ripla / Version.java
Created July 8, 2014 09:54
Code required to read Maven WAR artifact version in java.
public final class Version {
private static Logger logger = LoggerFactory.getLogger(Version.class);
private static String appVersion;
private Version() {
}
public static String getVersionString() {
package com.vaadin.test;
import com.vaadin.addon.charts.Chart;
import com.vaadin.addon.charts.model.*;
import com.vaadin.annotations.Push;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Component;
@ripla
ripla / setup_docker_postgres.sh
Last active August 29, 2015 14:14
Install Homebrew, Docker and start a PostgreSQL container from scratch
#Install Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
#Install Cask
brew install caskroom/cask/brew-cask
#Install Virtualbox binary
brew cask install virtualbox
#Install Docker and OSX Docker helper
@ripla
ripla / InfiniteStreams.scala
Created July 7, 2015 12:29
Creating infinite streams from a function
//Get a new Stream that always calls the given function when a new value
//is needed.
def stream(): Source[Int, Unit] =
Source(() => Iterator.continually(createValue()))
//Just an example, could be anything
def createValue(): Int = Random.nextInt()