Skip to content

Instantly share code, notes, and snippets.

@planetsizebrain
planetsizebrain / LiferayPDFBoxConverter.java
Created April 29, 2015 13:21
Custom LiferayPDFBoxConverter for PDFBox 2.0.0-SNAPSHOT
/**
* 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
@planetsizebrain
planetsizebrain / patching-tool.sh
Last active November 29, 2016 16:01
Liferay patching tool Bash autocomplete script
_patching-tool()
{
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "auto-discovery diff help index-info info install list-collisions list-customizations list-plugins revert server-status setup store support-info update-plugins version" -- $cur) )
}
complete -F _patching-tool patching-tool.sh
@planetsizebrain
planetsizebrain / view.jsp
Last active January 17, 2016 21:09
Overridden /html/portlet/dockbar/view.jsp that shows the cluster web server node ID.
<%--
/**
* 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
@planetsizebrain
planetsizebrain / view.jsp
Created March 3, 2016 20:08
Angular Hello World test with code from Gyle Fernandez
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="theme" %>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %>
<portlet:defineObjects />
<theme:defineObjects />
<div id="<portlet:namespace />app" class="co-app">
<table ng-controller="listCtrl" id="listCtrl">
<thead>
Overall cost: 520.0
Unique songs: 237
Cost per song: 2.1940928270042193
Records: 52 01/16/16 Consol Energy Center, Pittsburgh, PA , 01/19/16 United Center, Chicago, IL , 01/26/14 Bellville Velodrome, Cape Town, SA , 01/28/14 Bellville Velodrome, Cape Town, SA , 01/29/14 Bellville Velodrome, Cape Town, SA , 01/31/16 Prudential Center, Newark, NJ , 02/02/16 Air Canada Centre, Toronto, ON , 02/07/14 Perth Arena, Perth, AU , 02/08/14 Perth Arena, Perth, AU , 02/10/16 XL Center, Hartford, CT , 02/12/14 Adelaide Entertainment Center, Adelaide, AU , 02/15/14 AAMI Park, Melbourne, AU , 02/19/14 Allphones Arena, Sydney, AU , 02/21/16 KFC Yum! Center, Louisville, KY , 02/22/14 Hope Estate Winery, Hunter Valley, AU , 02/23/16 Quicken Loans Arena, Cleveland, OH , 02/26/14 Brisbane Entertainment Centre, Brisbane, AU , 02/27/16 Blue Cross Arena, Rochester, NY , 02/29/16 Xcel Energy Center, St Paul, MN , 03/02/14 Mount Smart Stadium, Auckland, NZ , 03/09/12 Apollo Theater, New York, NY , 03/10/16 Talking Stick Resor
@planetsizebrain
planetsizebrain / listDirectory.groovy
Last active September 4, 2016 14:50
Small Liferay Groovy script that lists the contents of a directory
import java.io.*;
try {
File directory = new File("/opt/liferay");
for (File f : directory.listFiles()) {
out.println(f.name + " " + f.size());
}
} catch (Exception e) {
out.println(e.getMessage());
}
@planetsizebrain
planetsizebrain / listFile.groovy
Created September 4, 2016 14:57
A Liferay Groovy script that lists the contents of a file
try {
java.io.File file = new java.io.File("/opt/liferay/portal-ext.properties");
String s = com.liferay.portal.kernel.util.FileUtil.read(file);
out.println(s);
} catch (Exception e) {
out.println(e.getMessage());
}
@planetsizebrain
planetsizebrain / executeCommand.groovy
Created September 4, 2016 15:10
A Liferay Groovy script that allows you to execute OS level commands and prints the output
def sout = new StringBuilder(), serr = new StringBuilder()
def proc = 'apt-get --just-print upgrade'.execute()
proc.consumeProcessOutput(sout, serr)
proc.waitForOrKill(10000)
println "out>"
println "$sout"
println "err>"
println "$serr"
@planetsizebrain
planetsizebrain / NotSoSimpleHTTPServer.py
Created October 23, 2016 17:34
A small extension of the default Python SimpleHTTPServer that ignores the first part of the URL
import BaseHTTPServer
import SimpleHTTPServer
class MyRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def translate_path(self, path):
index = path.find('/', 2)
return SimpleHTTPServer.SimpleHTTPRequestHandler.translate_path(self, path[index:])
httpd = BaseHTTPServer.HTTPServer(server_address, MyRequestHandler)
httpd.serve_forever()
@planetsizebrain
planetsizebrain / liferay-freemarker-datetime-tricks.ftl
Created January 25, 2017 20:20
A simple Liferay Freemarker template that shows how the build-in datetime formatting works together with processing settings for locale and timezone
<#setting time_zone=timeZone.ID>
<#setting locale=locale.toString()>
<#setting datetime_format="MMM d, HH':'mm">
<ul>
<#list entries as entry>
<li><li>${entry.title} - ${entry.modifiedDate?datetime}</li></li>
</#list>
</ul>