Skip to content

Instantly share code, notes, and snippets.

View hezamu's full-sized avatar

Henri Muurimaa hezamu

View GitHub Profile
@hezamu
hezamu / Java varargs from Scala
Last active August 26, 2019 18:38
How to call a Java method with varargs from Scala.
I ran into the "ambiguous reference to overloaded definition" error while trying to create a Vaadin ShortcutAction from Scala like this:
val upAction = new ShortcutAction("up", ShortcutAction.KeyCode.ARROW_UP, null)
ShortcutAction has a few constructors with repeating parameters (varargs), but specifying null as the last parameter clears things up in Java. Scala on the other hand seems unable to figure out which constructor I'm trying to call.
Now, Scala has a special syntax to tell the compiler to pass a Seq as varargs, ": _*". So, I figured out this would work:
val upAction = new ShortcutAction("up", ShortcutAction.KeyCode.ARROW_UP, Array(): _*)
#!/usr/bin/python
# Expects the AWS_ enviornment variables to be set for boto to know how to connect to AWS/S3 - they are:
# AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
#
# Change the bucket name from mbafford-static for your own uses.
#
# Obvious enhancements would be to add the necessary tags for displaying artwork for the show in podcast software.
import re
@hezamu
hezamu / CanvastestUI.java
Last active December 22, 2016 11:50
Demonstrate how to use the various features with the Vaadin 7 version of the Canvas add-on.
import org.vaadin.hezamu.canvas.Canvas;
import org.vaadin.hezamu.canvas.Canvas.CanvasImageLoadListener;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.MouseEventDetails;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;