Skip to content

Instantly share code, notes, and snippets.

View bmvakili's full-sized avatar

Bijan Vakili bmvakili

View GitHub Profile
@bmvakili
bmvakili / liferay_forum_response_20150815.java
Created August 15, 2015 21:41
Liferay Portlet Configuration Edit Scope Action Update Scope Method
ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(
WebKeys.THEME_DISPLAY);
String oldScopeName = getOldScopeName(actionRequest, portlet);
PortletPreferences portletPreferences = actionRequest.getPreferences();
String scopeType = ParamUtil.getString(actionRequest, "scopeType");
@bmvakili
bmvakili / parse_uinque_visitors_from_apache.sh
Last active August 29, 2015 14:27
Parse Unique Visitors from Apache
APACHE_LOG_FILE=/var/log/apache2/jenkinsrow-access_log
LINES_TO_SCAN=100000
EXCLUDED_ENTITIES="(router.asus.com|NewRelicPinger|Googlebot|slurp|spider|bingbot)"
tail $APACHE_LOG_FILE -n $LINES_TO_SCAN | egrep -v "$EXCLUDED_ENTITIES" | sed -r 's!^[^ ]* ([^ ]*) .*!\1!g' | uniq -c
@bmvakili
bmvakili / script_to_get_assignments_of_a_workflow_definition.groovy
Created August 18, 2015 01:55
Groovy script to get Assignments element of a Kaleo Workflow definition
import com.liferay.portal.util.*;
import com.liferay.portal.service.*;
import com.liferay.portal.model.*;
import com.liferay.portal.kernel.util.*;
import com.liferay.portal.kernel.workflow.*;
import javax.xml.parsers.*;
import javax.xml.xpath.*;
import java.io.*;
import org.xml.sax.*;
import org.w3c.dom.*;
@bmvakili
bmvakili / liferay_dump.ftl
Last active February 14, 2018 09:00 — forked from jamesfalkner/liferay_dump.ftl
Dump Liferay 7 GA4 variables in Freemarker - adapted from James Falkner's original
<#attempt>
<#assign black_list = ["class", "request", "getreader", "getinputstream", "writer"] />
<#macro dump key data>
<#if data?is_enumerable>
<p><b>${key}</b>
<@printList data,[] />
<#elseif data?is_hash_ex>
<p><b>${key}</b>
@bmvakili
bmvakili / liferay-7-wcm-adt-dump.ftl
Created November 25, 2015 01:32 — forked from jamesfalkner/liferay-7-wcm-adt-dump.ftl
A simple utility template to dump all available Liferay 7 WCM/ADT variables and their values.
<#-- dump.ftl
--
-- Generates tree representations of data model items.
--
-- Usage:
-- <#import "dump.ftl" as dumper>
--
-- <#assign foo = something.in["your"].data[0].model />
--
-- <@dumper.dump foo />
@bmvakili
bmvakili / get-ddl-records-for-a-userid.groovy
Created November 28, 2015 14:32
Get Liferay DDL Records for a user
import java.io.PrintStream;
import java.util.List;
import com.liferay.portal.kernel.dao.orm.Criterion;
import com.liferay.portal.kernel.dao.orm.DynamicQuery;
import com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portlet.dynamicdatalists.model.DDLRecord;
import com.liferay.portlet.dynamicdatalists.service.DDLRecordLocalServiceUtil;
@bmvakili
bmvakili / liferay_forum_message_72030046.java
Created March 26, 2016 01:28
Dynamic Query on JournalArticle for Liferay using `between date` criteria
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import com.liferay.portal.kernel.dao.orm.DynamicQuery;
import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
import com.liferay.portal.kernel.dao.orm.OrderFactoryUtil;
import com.liferay.portal.kernel.dao.orm.Property;
import com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil;
import com.liferay.portlet.journal.model.JournalArticle;
@bmvakili
bmvakili / list-selectors-across-stylesheets.js
Last active May 22, 2017 02:21
List all selectors across DOM stylesheets
function logSortedCSSSelectorsOnStylesheets(stylesheets) {
var ruleset = new Set();
for (var stylesheet in stylesheets) {
var rules = stylesheets[stylesheet].rules;
for (var rule in rules) {
var stylesheetRule = rules[rule];
if (stylesheetRule.selectorText) {
ruleset.add(stylesheetRule.selectorText);
}
All Liferay Variables
See the bottom for the request variable expansion
saxReaderUtil = com.liferay.portal.xml.SAXReaderImpl@aed8447
Callable methods:
| createXPath | getClass | isProxyClass | createText | hashCode | readURL | class | read | getProxyClass | newProxyInstance | createElement | sort | getInvocationHandler | createDocument | createEntity | selectNodes | createNamespace | createAttribute | equals | createProcessingInstruction | toString | createQName
getterUtil = com.liferay.portal.kernel.util.GetterUtil_IW@68bfc4e8
Callable methods:
| getClass | getShortStrict | getDouble | getBooleanValues | getInteger | getFloat | getNumber | hashCode | get | getBoolean | getDate | getIntegerStrict | class | getStringValues | getLongStrict | getDateValues | getLongValues | getObject | getFloatValues | getShort | getString | getDoubleValues | getNumberValues | getShortValues | getLong | getIntegerValues | equals | toString | getInstance
@bmvakili
bmvakili / Jenkinsfile
Created May 14, 2018 02:46
Liferay example Jenkinsfile
pipeline {
agent any
options {
buildDiscarder(logRotator(numToKeepStr: '21', artifactNumToKeepStr: '50'))
timestamps()
timeout(time: 5, unit: 'MINUTES')
}
parameters{
string(name: 'JAVA_HOME', defaultValue: '/var/jenkins_home/tools/hudson.model.JDK/JDK_7u80/', description: 'JDK', )
}