Skip to content

Instantly share code, notes, and snippets.

Polymer outside click element
window.addEventListener((e) {
var target = event.target;
while(target != this && target != document.body) {
target = Polymer.dom(target).node.domHost.parentNode;
// might need some additional steps to get the parent from inside custom elements
// don't know by heart
}
public interface IConnect {
public void connect() throws CriticalException;
}
public class ReconnectProxy implements InvocationHandler {
public static final long RECONNECT_DELAY = 5000;
public static final String MESSAGE_CONNECT = "connect";
ExecutorService threadPool;
child.html
<div class="part">
<style>
h3 {
color: red !important;
}
</style>
<h3>Warning!</h3>
<p>This page is under construction</p>
@sz332
sz332 / shadowdom.html
Last active February 21, 2018 14:44
Shadow dom
<html>
<body>
<div id="wrapper">
</div>
<div>This has normal color.</div>
<script>
@sz332
sz332 / htmltemplate.html
Created February 21, 2018 14:45
HTML Templates
<html>
<body>
<template id="my-template">
<h1>Hello world from template!</h1>
</template>
<div id="parent">
</div>
@sz332
sz332 / customelement.html
Created February 21, 2018 14:45
Custom element
<html>
<head>
<script>
class HelloWorld extends HTMLElement {
constructor() {
super();
let shadowRoot = this.attachShadow({
mode: 'open'
List<Integer> l = Arrays.asList(new Integer[]{1,2,3});
Integer min = l.stream().min(Integer::compare).get();
@sz332
sz332 / index.js
Last active August 29, 2019 07:53
Working example of bull and external processor
// index.js
const path = require('path');
const Queue = require('bull');
let queue = new Queue('test queue', 'redis://192.168.99.100:6379');
queue.process(1, path.join(__dirname, './processor.js'))
queue.on('completed', function(job, result) {
console.log("Completed: " + job.id + ", result = " + JSON.stringify(result));
@sz332
sz332 / Dockerfile
Last active April 10, 2023 12:35
Greenmail and Thunderbird
FROM openjdk:8-jre-alpine AS base
ENV GREENMAIL_OPTS -Dgreenmail.setup.test.all -Dgreenmail.hostname=0.0.0.0 -Dgreenmail.smtp.hostname=localhost -Dgreenmail.verbose
RUN apk add --no-cache curl
RUN curl -O http://central.maven.org/maven2/com/icegreen/greenmail-standalone/1.5.9/greenmail-standalone-1.5.9.jar
FROM openjdk:8-jre-alpine AS final
import java.util.Stack;
public class XmlValidator {
public boolean isValid(String xml) {
Stack<String> stack = new Stack<>();
boolean opening = false;
boolean closing = false;