Skip to content

Instantly share code, notes, and snippets.

View bmvakili's full-sized avatar

Bijan Vakili bmvakili

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / GitCodeReviewUtility.java
Last active August 29, 2015 14:26
A utility for some code reviews
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.security.AllPermission;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
@bmvakili
bmvakili / getallliferayportalbeans.bsh
Created June 14, 2015 14:37
get all liferay Portal beans
import com.liferay.portal.bean.BeanLocatorImpl;
import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
import com.liferay.portal.kernel.bean.PortletBeanLocatorUtil;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
String[] vals = PortalBeanLocatorUtil.getBeanLocator().getNames();
for (String val : vals) {
out.println( val );
@bmvakili
bmvakili / convert.sh
Created May 14, 2015 20:08
Problem import dump from Win to linux
#!/bin/bash
# Problem import dump from Win to linux
# Win mysql tables lowercase; and case insensitive as the default
# LInux mysql tables have case; and are case sensitive as the default
# So dumping from Win to Linux breaks things
# This script needs reference schema with case; it will use that to convert the dump file
# I have tested this with Liferay 6.2; ubuntu version 14.04
# This file is based on answer by l0co on StackOverflow
@bmvakili
bmvakili / listall.ftl
Last active January 3, 2016 16:18
dump all freemarker vairables
<br />
.main: <br />
<#list .main?keys as var>
<br/>Key : <strong>${var} </strong>
<br/>Val :
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<#if .main[var]?is_sequence>
<#list .main[var] as varkey>
<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ${varkey}
</#list>
@bmvakili
bmvakili / liferay kaleo variables
Created March 28, 2015 20:18
Liferay 6.2GA3 Kaleo Beanshell Variables for Task in Action element
this = 'this' reference (XThis) to Bsh object: NameSpace: global (bsh.NameSpace@2bc198b5)
this.variables = [Ljava.lang.String;@3310a984
taskComments
taskName
workflowTaskAssignees
serviceContext
entryType
groupId
userId
entryClassPK