Skip to content

Instantly share code, notes, and snippets.

View ripla's full-sized avatar

Risto Yrjänä ripla

View GitHub Profile
import {
Writer,
Connection,
AVRO_SERIALIZER,
STRING_SERIALIZER,
} from "k6/x/kafka";
const brokers = ["kafka:29092"];
const writer = new Writer({
@ripla
ripla / test-design.html
Created November 21, 2018 17:16
Simple data in a vaadin-combo-box
<link rel="import" href="bower_components/polymer/polymer.html">
<link rel="import" href="bower_components/vaadin-combo-box/src/vaadin-combo-box.html">
<dom-module id="test-design">
<template>
<vaadin-combo-box id="myCombo"></vaadin-combo-box>
</template>
<script>
class TestDesign extends Polymer.Element {
@ripla
ripla / SimpleFormExample.html
Created April 27, 2017 14:52
Super simple Vaadin form using VerticalLayout, HorizontalLayout and FormLayout
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="design-properties" content="{&quot;RULERS_VISIBLE&quot;:true,&quot;GUIDELINES_VISIBLE&quot;:false,&quot;SNAP_TO_OBJECTS&quot;:true,&quot;SNAP_TO_GRID&quot;:true,&quot;SNAPPING_DISTANCE&quot;:10,&quot;GENERATE_GETTERS&quot;:false,&quot;JAVA_SOURCES_ROOT&quot;:&quot;src/main/java&quot;,&quot;THEME&quot;:&quot;valo&quot;}">
<meta name="vaadin-version" content="8.0.5">
</head>
<body>
<vaadin-vertical-layout spacing="false">
<vaadin-horizontal-layout width-full>
@ripla
ripla / UrlChecker.java
Created December 22, 2016 08:04
Simple URL connection checker for proxied connections
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;
import java.util.stream.Collectors;
public class UrlChecker {
public static void main(String[] args) {
@ripla
ripla / RestConfiguration.java
Last active May 31, 2021 06:39
The different ways of accessing a REST HATEOAS resource created with Spring Data. Using a Spring RestTemplate.
import java.util.Arrays;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.hal.Jackson2HalModule;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.client.RestTemplate;
@ripla
ripla / gerrit-reviewable.js
Last active May 6, 2016 12:30
+2, +1 style reviews for Reviewable.io
// Approval by username.
// +2, lgtm_strong or +1 +1 -> Reviewed and tested
// +1 or lgtm -> Reviewed
// -2 or -1 -> Remove previous review approval
// Review only valid if for the current version
// +1 and thumbsup are equal
var approvals = {};
var tested = {};
// Timestamp of the currently latest revision.
@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);
<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 / 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 / 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