Skip to content

Instantly share code, notes, and snippets.

View bmvakili's full-sized avatar

Bijan Vakili bmvakili

View GitHub Profile
@bmvakili
bmvakili / MyAction.java
Created July 24, 2019 08:43 — forked from rotty3000/MyAction.java
MyAction
package com.liferay.events;
import aQute.bnd.annotation.component.Activate;
import aQute.bnd.annotation.component.Component;
import aQute.bnd.annotation.component.Deactivate;
import com.liferay.portal.kernel.events.ActionException;
import com.liferay.portal.kernel.events.SimpleAction;
/**
@bmvakili
bmvakili / Dockerfile
Last active July 13, 2019 07:51
liferay frontend development via docker container
FROM ubuntu
RUN apt-get update && \
apt-get -y install curl software-properties-common && \
curl -sL https://deb.nodesource.com/setup_12.x | bash - && \
apt-get update && \
apt-get -y install nodejs && \
useradd -m -s $(which bash) liferay && \
chown -R liferay:liferay /usr/lib/node_modules
@bmvakili
bmvakili / README.md
Created March 31, 2019 15:07 — forked from kui/README.md
Eclipse Shortcut for Ubuntu

Eclipse Shortcut for Ubuntu Unity

a shortcut to run Eclipse on Ubuntu Unity and to register Eclipse with the left Launcher

Installation

@bmvakili
bmvakili / crontab
Created February 25, 2019 03:49
Crontab entry to check for bad actors attempting 100+ incorrect password attempts in a day from a given IP address and ban that IP address from trying to connect to the server
# Continuously check for bad actors and ban them!
0 */2 * * * zgrep "Failed password for root from" /var/log/auth.log | sed "s_.*Failed password for root from \([0-9][^ ]*\).*_\1_" | sort | uniq -c | sort -n | while read x ; do export IP=`echo $x | sed 's_^[ ]*[0-9]* \([0-9].*\)_\1_'`; export TEST=`echo $x | sed 's_^[ ]*\([0-9]*\) [0-9].*_\1_'`; test $TEST -gt 100 && (grep -qxF "ALL: $IP" /etc/hosts.deny || sudo bash -c "echo 'ALL: $IP' >> /etc/hosts.deny ") ; done
@bmvakili
bmvakili / java-logging-args.sh
Created May 28, 2018 16:49
Some apache log settings
-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
-Dorg.apache.commons.logging.simplelog.showdatetime=true
-Dorg.apache.commons.logging.simplelog.log.org.apache.http=ERROR
-Dorg.apache.commons.logging.simplelog.log.org.apache.http.wire=ERROR
@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', )
}
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 / 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);
}
@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 / 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;