Skip to content

Instantly share code, notes, and snippets.

View ripla's full-sized avatar

Risto Yrjänä ripla

View GitHub Profile
@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
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()
@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")
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="seed-element.html">
<dom-module id="outer-element">
<template>
<seed-element id="seed" on-seed-element-lasers="underAttack"></seed-element>
</template>
<script>
Polymer({
@ripla
ripla / SortingTableWithHiddenProperty.java
Created November 19, 2015 14:07
Quick test to demonstrate sorting one column based on another, hidden column
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);
IndexedContainer mainContainer = new IndexedContainer();
mainContainer.addContainerProperty("prop1", Integer.class, "");
mainContainer.addContainerProperty("prop2", Integer.class, "");
mainContainer.addContainerProperty("prop3", Integer.class, "");
Item item = mainContainer.addItem(1);