Skip to content

Instantly share code, notes, and snippets.

package org.flywaydb.core;
import com.simba.googlebigquery.jdbc42.DataSource;
import org.flywaydb.core.Flyway;
import java.net.URISyntaxException;
import java.sql.SQLException;
public class BQTest {
// https://github.com/mikedunker/JSMapr
// License: MIT
// Version: 0.0.1
(function () {
var sep = "/";
var mapCommands = [];
var logFunc = null;
function log() {
@planetsizebrain
planetsizebrain / four-digit-year.ftl
Created April 11, 2017 10:06
Liferay Freemarker datetime format with 4-digit year
<#setting time_zone=timeZone.ID>
<#setting locale=locale.toString()>
<#setting datetime_format="MM/dd/yyyy">
<ul>
<#list entries as entry>
<li><li>${entry.title} - ${entry.modifiedDate?datetime}</li></li>
</#list>
</ul>
@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>
@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 / 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 / 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 / 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());
}
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 / 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>