Skip to content

Instantly share code, notes, and snippets.

View bmvakili's full-sized avatar

Bijan Vakili bmvakili

View GitHub Profile
@bmvakili
bmvakili / proxy.php
Created January 31, 2012 02:54
this PHP script lets your apache server act as a proxy
<?
// limitation is that this script only works for http right now; also, login forms may/not work
// this PHP script lets your apache server act as a proxy
// 1. simply add a .htaccess directive as follows
// ErrorDocument 404 /proxy.php
// 2. set the proxy_url and actual_url parameters belom
// proxy_url is the address to your PHP server, e.g. www.example.com
// actual_url is the address to your other server, e.g. 10.10.10.10
error_reporting(E_ALL);
@bmvakili
bmvakili / gist:1819230
Created February 13, 2012 19:14
"Fast Forward" the fork! Merges any changes from orginal repository into forked repository .
git checkout -b upstream/master
git remote add upstream git://github.com/documentcloud/underscore.git
git pull upstream master
git checkout master // [my master branch]
git merge upstream/master
git push origin master
## Source : https://github.com/blog/266-fast-forward-your-fork
@bmvakili
bmvakili / 20120914p1g1.gist
Created September 14, 2012 12:49
20120914p1g1
export JAVA_HOME=/usr/java/jdk1.6.0_21
export LIFERAY_HOME=/usr/liferay/liferay-portal-6.0.5/tomcat-6.0.26
export PATH=$JAVA_HOME/bin:$LIFERAY_HOME/bin:$PATH
// ## CHANGE THESE ##
var mainPath = "http://localdev.aha.org:8080";
var largestLayoutId = 99999;
// ## get all layouts containing custom portlets (that is, ones whose ID is not numeric) and print their URLs
var layouts = Packages.com.liferay.portal.service.LayoutLocalServiceUtil.getLayouts(0,largestLayoutId);
number = layouts.size();
var friendlyUrlArray = new Packages.java.util.ArrayList();
var names = "";
var output = "";
@bmvakili
bmvakili / liferay-script-check-perms-1
Created October 10, 2012 19:54
Liferay scripts - check every page permission in a group to see which roles have VIEW access
// ## CHANGE THESE ##
var largestLayoutId = 99999;
var groupName = "[group name]";
var showPublic = false;
var companyId = 10153;
var siteMemberRoleId= 10169;
var className = "com.liferay.portal.model.Layout";
//var groupId = Packages.com.liferay.portal.service.GroupLocalServiceUtil.getGroup(companyId, groupName).getGroupId();
var groupId = 10179;
@bmvakili
bmvakili / liferay-script-check-perms-2
Created October 10, 2012 20:54
Liferay scripts - check every page permission in default Group to see which roles have VIEW access
// Description: Liferay scripts - check every page permission in default Group to see which roles have VIEW access. It can also give the VIEW action permission to the Site Member role.
// Usage: Modify settings under "##CHANGE THESE##" section. Paste this script in the Control Panel->Server Administration->Script console and click "Execute"
//
// ## CHANGE THESE ##
var groupName = "Guest"; // this is the main group name
var showPublic = false; // set to true if public pages should be listed too. default behavior is that only private pages are considered when looking for VIEW action permission for Site Member role
var givePermission = false; // set to true to give VIEW action permission for Site Member role to all pages. Optionally apply this permission to a subset of pages by providing regular experssion to filter pages. See givePermissionRegex property below.
var givePermissionRegex = ".*"; // provide regular expression to filter Page Names
// ## No need to change below ##
// ### Javascript Sample ###
folder = Packages.com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil.fetchDLFolder(14083);
resource = Packages.com.liferay.portal.service.ResourceLocalServiceUtil.getResource(folder.getCompanyId(), "com.liferay.portlet.documentlibrary.model.DLFolder", Packages.com.liferay.portal.model.ResourceConstants.SCOPE_INDIVIDUAL, folder.getPrimaryKey());
folderExpandoBridge = folder.getExpandoBridge().hasAttribute("hiddenFolderProperties");
resourceActions = Packages.com.liferay.portal.security.permission.ResourceActionsUtil.getResourceActions("20", "com.liferay.portlet.documentlibrary.model.DLFolder");
administrator = Packages.com.liferay.portal.service.RoleLocalServiceUtil.getRole(folder.getCompanyId(), Packages.com.liferay.portal.model.RoleConstants.ADMINISTRATOR);
roleTypes = []
@bmvakili
bmvakili / liferay-script-check-perms-3
Created November 2, 2012 17:23
Liferay scripts - check permissions on CalEvent
// ### Javascript Sample ###
companyId = 10153;
model = "com.liferay.portlet.calendar.model.CalEvent";
portletId = "8";
folder = Packages.com.liferay.portlet.calendar.service.CalEventLocalServiceUtil.getEvent(137535);
resource = Packages.com.liferay.portal.service.ResourceLocalServiceUtil.getResource(companyId, model, Packages.com.liferay.portal.model.ResourceConstants.SCOPE_INDIVIDUAL, folder.getPrimaryKey());
resourceActions = Packages.com.liferay.portal.security.permission.ResourceActionsUtil.getResourceActions(portletId, model);
administrator = Packages.com.liferay.portal.service.RoleLocalServiceUtil.getRole(folder.getCompanyId(), Packages.com.liferay.portal.model.RoleConstants.ADMINISTRATOR);
roleTypes = []
@bmvakili
bmvakili / gist:4656884
Created January 28, 2013 16:18
Liferay Calendar - timezones, recurrence, and start/end times
ev0 = Packages.com.liferay.portlet.calendar.service.CalEventLocalServiceUtil.getEvent(66582);
recur0 = Packages.com.liferay.portlet.calendar.service.ICalUtil.toICalRecurrence(ev0.getRecurrenceObj())
dt0 = new Packages.net.fortuna.ical4j.model.Date(ev0.getStartDate());
sc0 = new Packages.net.fortuna.ical4j.model.Date(Packages.java.util.Calendar.getInstance().getTime());
no = recur0.getNextDate( dt0, sc0);
out.println("no: " + no);
///
out.println("-----")
tz = Packages.com.liferay.portal.kernel.util.TimeZoneUtil.getDefault();
ev = Packages.com.liferay.portlet.calendar.service.CalEventLocalServiceUtil.getEvent(66567);
@bmvakili
bmvakili / gist:5295400
Created April 2, 2013 19:26
Liferay Groovy Script Get all roles; list User Groups associated with each role.
import com.liferay.portlet.usergroupsadmin.search.*;
import java.util.*;
import com.liferay.portal.service.*;
import com.liferay.portal.model.*;
import com.liferay.portal.model.UserGroup;
List<Role> roles = RoleLocalServiceUtil.getRoles(0,999999999);
for (Role role : roles) {
long roleId = role.getRoleId();
List<Group> roleGroups = GroupLocalServiceUtil.getRoleGroups(roleId);
for (Group roleGroup : roleGroups) {