Skip to content

Instantly share code, notes, and snippets.

View sammso's full-sized avatar

Sampsa Sohlman sammso

View GitHub Profile

Liferay setenv.sh

This is to be replaced developer machine for DXP.

CATALINA_OPTS="$CATALINA_OPTS -Dfile.encoding=UTF8"
CATALINA_OPTS="$CATALINA_OPTS -Djava.net.preferIPv4Stack=true"
CATALINA_OPTS="$CATALINA_OPTS -Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false"
CATALINA_OPTS="$CATALINA_OPTS -Duser.timezone=GMT"
CATALINA_OPTS="$CATALINA_OPTS -Xmx2g"

From Liferay Scripting console.

isMaster = com.liferay.portal.kernel.cluster.ClusterMasterExecutorUtil.isMaster() ;
out.println(isMaster);

Huge github push

Below the master is the branch and change that to correct one.

max=$(git log --oneline|wc -l); for i in $(seq $max -500 1); do echo $i; g=$(git log --reverse --oneline --skip $i -n1|perl -alne'print $F[0]'); git push origin $g:refs/heads/master; done
@sammso
sammso / extract-files-from-web.md
Last active December 12, 2017 16:23
Script to extract all the files from the website.

Fetching all the "log" files from website

Usage:

Create empty file names as extract-files-from-web.sh on unix/mac/linux or windows Git bash / Cygwin.

Usage

[me@myserver myfolder]$ ./extract-files-from-web.sh http://my.server.loc/hello/world/
@sammso
sammso / jstackseries.md
Last active January 18, 2018 22:06
jstackseries.sh

Script collect threaddumps from the Java process

Usage: "Usage: jstackSeries <process identfier> [ <count> [ <delay> [ <sample count> [ <file prefix> [ <folder> ] ] ] ] ]

Where:

  • process identfier is prosess id or if it is not a number then script is trying to find pid by ps -ef|grep java| grep <process identifier>
  • count how many times we take samples, use -1 if no limit.
  • delay wait between samples
  • sample count how many threadump samples we take on row
  • file prefix what is the file prefix, this can be example server name
@sammso
sammso / Consulting 2017-11-20.md
Last active November 22, 2017 06:35
Consulting 2017-11-20

Hooking the ActionCommand at Liferay

@Component(
		immediate = true,
		property = {
			"javax.portlet.name=" + GradebookPortletKeys.PORTLET_NAME,
			"mvc.command.name=/gradebook/assignment/add",
			"service.ranking:Integer=100" 
	},

Add following to portal properties

ehcache.multi.vm.config.location=/liferay-multi-vm-clustered-eternal.xml

Create new confguration file at <liferay-home>/tomcat-xx/webapps/ROOT/WEB-INF/classes/liferay-multi-vm-clustered-eternal.xml with content

<ehcache
	dynamicConfig="true"
@sammso
sammso / liferay-training-leiden-2017-10-24.md
Last active October 24, 2017 15:01
Liferay Fundamentals training at Leiden 2017-10-24

Snippets and tips for the course

Using Java 8 when having Java 9 with Mac

Edit your ~/.bash_profile file and add following line there after installing Java 8, where jdk1.8.0_112.jdk is your JDK installation version.

alias use-java8='export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home"'