Skip to content

Instantly share code, notes, and snippets.

View rotty3000's full-sized avatar

Raymond Augé rotty3000

View GitHub Profile
@rotty3000
rotty3000 / DDMJsResources.java
Last active October 24, 2023 05:25
resources example, serving any resources in your bundle
@Component(
property = {
"osgi.http.whiteboard.resource.pattern=/kaleo/resources/*",
"osgi.http.whiteboard.resource.prefix=/",
"osgi.http.whiteboard.servlet.pattern=/kaleo/resources/*" // temporary since this was the old property
},
service = Servlet.class
)
public class DDMJsResources extends HttpServlet {
}
@rotty3000
rotty3000 / Dockerfile
Created September 26, 2022 13:45
Add Azul Zulu Debian repo without warnings and using `signed-by` pattern.
RUN mkdir -p /etc/apt/keyrings && \
curl -fsSL 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xB1998361219BD9C9' | gpg --dearmor -o /etc/apt/keyrings/azul.gpg && \
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/azul.gpg] https://repos.azul.com/zulu/deb stable main" \
| tee /etc/apt/sources.list.d/zulu-openjdk.list > /dev/null && \
apt-get update && \
apt-get install -y zulu11-jdk && \
apt-get clean
@rotty3000
rotty3000 / validate-custom-element.sh
Last active March 11, 2022 19:25
Validate Web Component Custom Element name with bash and grep
#!/bin/bash
# Derived from https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
PCENCHAR=[-.0-9_a-z\\xB7\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\x{037D}\\x{037F}-\\x{1FFF}\\x{200C}-\\x{200D}\\x{203F}-\\x{2040}\\x{2070}-\\x{218F}\\x{2C00}-\\x{2F2F}\\x{3001}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFFD}\\x{10000}-\\x{EFFFF}]
CUSTOM_ELEMENT_NAME_REGEX=^[a-z]${PCENCHAR}*-${PCENCHAR}*$
if ! (echo "$1" | grep -q -P $CUSTOM_ELEMENT_NAME_REGEX); then
echo "invalid custom element name '$1'"
fi
@rotty3000
rotty3000 / example.java
Last active December 18, 2021 16:08
jdeps as ToolProvider exception on reuse
/*
The jdeps args used can be:
*/
jdeps0(
"--ignore-missing-deps",
"--no-recursive",
"--print-module-deps",
"--multi-release",
System.getProperty("java.specification.version"),
file.getAbsolutePath());
@rotty3000
rotty3000 / script.java
Created December 11, 2021 21:04
JShell Script SEBANG line
//usr/bin/env jshell <(for V in "$@";do A+="\"$V\",";done;echo "String[] args = {$A}") "$0"; exit $?
Stream.of(
args
).map(
"ARG: "::concat
).forEach(
System.out::println
);
@rotty3000
rotty3000 / command.bash
Last active November 22, 2021 16:57
jaxb-api jdeps
jdeps -verbose:class --multi-release 17 \
--module-path ~/.m2/repository/javax/activation/javax.activation-api/1.2.0/javax.activation-api-1.2.0.jar \
~/.m2/repository/javax/xml/bind/jaxb-api/2.4.0-b180830.0359/jaxb-api-2.4.0-b180830.0359.jar
@rotty3000
rotty3000 / portal_normal.ftl
Created October 12, 2011 16:57
adding javascript files from your theme
...
<head>
<title>${the_title} - ${company_name}</title>
${theme.include(top_head_include)}
<#--
-- <@liferay.js /> is a macro that should produce the correct output, timestamped to match that of the theme
-- Note main.js is already included automatically
-->
@rotty3000
rotty3000 / LoginPortletActionFilter.java
Last active December 3, 2019 01:34
Example of using OSGi-DS Component as a portlet filter in future versions of Liferay.
/**
* Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
@rotty3000
rotty3000 / filter.java
Created May 8, 2013 16:47
add a filter excluding images to a Liferay search
SearchContext searchContext = SearchContextFactory.getInstance(request);
// more context configuration on searchContext
BooleanQuery booleanQuery = BooleanQueryFactoryUtil.create(
searchContext);
booleanQuery.addExactTerm("extension", "bmp");
booleanQuery.addExactTerm("extension", "jpeg");
booleanQuery.addExactTerm("extension", "jpg");
@rotty3000
rotty3000 / MyAction.java
Created September 10, 2013 14:29
MyAction
package com.liferay.events;
import aQute.bnd.annotation.component.Activate;
import aQute.bnd.annotation.component.Component;
import aQute.bnd.annotation.component.Deactivate;
import com.liferay.portal.kernel.events.ActionException;
import com.liferay.portal.kernel.events.SimpleAction;
/**