Skip to content

Instantly share code, notes, and snippets.

View einsty's full-sized avatar
💭
I may be slow to respond.

Orin Fink einsty

💭
I may be slow to respond.
View GitHub Profile
@einsty
einsty / GroupUtil-getCurrentAndChildGroups.java
Created July 14, 2017 16:57
Utility method that can traverse the Liferay Group hierarchy and build an array of long representing all child groups. Useful in scoping a searchContext for content in an org hierarchy.
public static long[] getCurrentAndChildGroupIds(Group currentGroup){
try {
List<Long> theseChildGroupIds = new ArrayList<>();
theseChildGroupIds.add(currentGroup.getGroupId());
for (Group childGroup : currentGroup.getChildren(true)
) {
theseChildGroupIds.add(childGroup.getGroupId());
if(childGroup.getChildren(true).size() > 0){
for (Group grandChildGroup : childGroup.getChildren(true)
@einsty
einsty / FriendlyJournalContentList.vm
Last active February 27, 2017 15:47
Simple Liferay, Velocity, ADT code to render Journal Article HTML using the articles' default Display Template.
#set ($journalArticleService = $serviceLocator.findService("com.liferay.portlet.journal.service.JournalArticleLocalService"))
#if (!$entries.isEmpty())
#foreach ($curEntry in $entries)
#set($renderer = $curEntry.getAssetRenderer() )
#set($className = $renderer.getClassName() )
#if( $className == "com.liferay.portlet.journal.model.JournalArticle" )
#set ($article = $journalArticleService.getLatestArticle($curEntry.getClassPK()))
@einsty
einsty / OfficeToPDF-For-Loop.md
Last active April 22, 2016 12:16
Loop over Directory of Excel Files and convert each one to PDF

#Convert Excel files to PDF

There are tons of solutions out there that will "automate" the conversion of Microsoft Office files to PDF. Unfortunately, many of them are bloated with spammy advertisements or will watermark your documents or any number of other unfriendly results.

If all that you really need to do is simply loop over a directory of say 30 or 300 or 3,000 Microsoft Office files and convert them each 1 by 1 into PDF's then a very lightweight solution can be found here.

Thanks to a conversation on Stack Overflow

@einsty
einsty / vhu-fail-missing-machine-uuid
Created June 16, 2013 05:32
vagrant-hostsupdater fails when a machine in cluster has not yet been created
[db01] VM not created. Moving on...
[db01] Removing hosts
/Users/orinq/.vagrant.d/gems/gems/vagrant-hostsupdater-0.0.7/lib/vagrant-hostsupdater/HostsUpdater.rb:68:in `quote': can't convert Nil
Class to String (TypeError)
from /Users/orinq/.vagrant.d/gems/gems/vagrant-hostsupdater-0.0.7/lib/vagrant-hostsupdater/HostsUpdater.rb:68:in `removeHostEn
tries'
from /Users/orinq/.vagrant.d/gems/gems/vagrant-hostsupdater-0.0.7/lib/vagrant-hostsupdater/Action/RemoveHosts.rb:17:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/action/warden.rb:34:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/action/builtin/call.rb:57:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/action/warden.rb:34:in `call'