Skip to content

Instantly share code, notes, and snippets.

@topolik
topolik / create-user.js
Created April 7, 2016 12:51
Liferay bookmarks
javascript: (xaf = prompt('nickname (will be also passwd)', 'test2')) && Liferay.Service('/user/add-user', { companyId: Liferay.ThemeDisplay.getCompanyId(), autoPassword: false, password1: xaf, password2: xaf, autoScreenName: false, screenName: xaf, emailAddress: xaf + '@liferay.com', facebookId: 0, openId: '', locale: '', firstName: xaf, middleName: '', lastName: xaf, prefixId: 0, suffixId: 0, male: true, birthdayMonth: 0, birthdayDay: 1, birthdayYear: 1970, jobTitle: '', groupIds: null, organizationIds: null, roleIds: null, userGroupIds: null, sendEmail: false}, function(obj) {alert(JSON.stringify(obj));if (typeof(obj) == 'object') { location.href='/c/portal/logout?referer=' + encodeURIComponent('/c/portal/login?login='+xaf+'@liferay.com&password='+xaf);}});
@topolik
topolik / idea.sh
Created February 25, 2016 09:01
Bash script for IntelliJ IDEA setup of Liferay Portal modules
#!/bin/bash
#
# Bash script to create Liferay modules structure in IntelliJ IDEA
#
# The script is provided as-is under GNU GPL v3 license, use at your own risk.
#
# Prerequisites:
# ==============
# 1, There is only one module "portal-master" that references all portal
# sources - portal-impl, portal-service, portal-web, util-*
@topolik
topolik / all_permissions_to_batman.groovy
Last active February 22, 2016 16:22
This script grants all available permissions to Batman role
import com.liferay.portal.kernel.model.*;
import com.liferay.portal.kernel.service.*;
import com.liferay.portal.kernel.security.permission.*;
import com.liferay.portal.kernel.util.*;
long companyId = PortalUtil.getDefaultCompanyId();
Role batman = RoleLocalServiceUtil.getRole(companyId, "Batman");
List<String> models = ResourceActionsUtil.getModelNames();
@topolik
topolik / httpd.conf
Created February 9, 2016 10:32
remoteip module config
Listen 443
<VirtualHost *:443>
ProxyRequests On
ProxyPass / ajp://localhost:8009/
ProxyPassReverse / ajp://localhost:8009/
LoadModule remoteip_module modules/mod_remoteip.so
RemoteIPHeader X-Forwarded-For
RemoteIPTrustedProxy 192.168.1.10
</VirtualHost>
@topolik
topolik / access-log-filter.sh
Created February 9, 2016 07:46
sed filter for apache/nginx access log
#!/bin/bash
#
# 10.0.0.111 - - [01/Feb/2016:04:44:11 -0800] "GET /o/js_bundle_config?t=29 HTTP/1.1" 200 30370 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36"
#
# sed 's/\(.\+\) \(\[.\+\]\) \(".\+"\).* \([0-9]\+\) \([0-9\-]\+\) \(".\+"\) \(".\+"\)//'
#
# backreferences:
# \1 ... IP + client + user
# \2 ... date+time
# \3 ... request line
@topolik
topolik / liferay-permissioned-models.sh
Created February 8, 2016 17:41
Finds all Liferay models that are configured to use permissions
find -name 'resource-actions' | grep -v 'classes\|bin\|build' | xargs find | grep xml | xargs grep model-name | sed 's/<[^>]\+>//g' | cut -d ':' -f 2 | sed 's/[[:space:]]//g' | grep '[A-Z]'
@topolik
topolik / .git {slash} config
Created November 26, 2015 14:57
liferay portal master .git/config
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = [email protected]:topolik/liferay-portal.git
[remote "upstream"]
url = [email protected]:liferay/liferay-portal.git
pushurl = [email protected]:topolik/liferay-portal.git
fetch = +refs/heads/*:refs/remotes/upstream/*
[branch "master"]
remote = upstream
merge = refs/heads/master
@topolik
topolik / keybase.md
Created June 1, 2015 10:06
keybase.md

Keybase proof

I hereby claim:

  • I am topolik on github.
  • I am topolik (https://keybase.io/topolik) on keybase.
  • I have a public key whose fingerprint is 450D 4A0C 19F7 6C48 7434 8CFF 389A 31E7 0B9F 3561

To claim this, I am signing this object:

@topolik
topolik / adt.ftl
Created January 30, 2014 08:11
ADT
<ul>
<#if entries?has_content>
<#list entries as curEntry>
<li>${htmlUtil.escape(curEntry.getTitle(locale))}: ${curEntry.getClassName()}, ${curEntry.getMimeType()}</li>
</#list>
</#if>
</ul>
@topolik
topolik / Portlet.java�'"
Last active December 30, 2015 09:38
Reading layout's query string: category=[name]
public class Portlet extends GenericPortlet {
@Override
protected void doView(RenderRequest renderRequest, RenderResponse response) throws PortletException, IOException {
String category = PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(renderRequest)).getParameter("category");
response.getWriter().println("Category: " + category);
}
}