Skip to content

Instantly share code, notes, and snippets.

View thomashartm's full-sized avatar

Thomas Hartmann thomashartm

  • Netcentric
  • Germany
View GitHub Profile
@thomashartm
thomashartm / bash_profile_aliases
Last active August 29, 2015 14:03
Bash profile aliases for mac osx
alias cd..="cd .."
alias ls="ls -l"
alias dir="ls -l"
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
@thomashartm
thomashartm / filtered_crx_export
Created June 27, 2014 06:20
File vault snippted to export resources from crx using vlt
To execute a filtered export:
vlt co http://localhost:4502/crx/-/jcr:root foundation
Create a filter.xml before at META-INF/vault/filter.xml.
<?xml version="1.0" encoding="UTF-8"?>
<workspaceFilter version="1.0">
<filter root="/etc/designs/geometrixx" />
<filter root="/libs/foundation/components"/>
</workspaceFilter>
@thomashartm
thomashartm / parse xml sed script
Last active May 14, 2016 19:17
Parse xml elements from settings.xml into shell variables
username=$(grep -o '<username>.*</username>' ~/.m2/settings.xml | sed 's/\(<username>\)//g' | sed 's/\(<\/username>\)//g')
password=$(grep -o '<password>.*</password>' ~/.m2/settings.xml | sed 's/\(<password>\)//g' | sed 's/\(<\/password>\)//g')
@thomashartm
thomashartm / remove-vlt.sh
Created January 19, 2015 13:23
Removes .vlt files from the current directory and all subdirectories
#!/bin/bash
find ./ -name ".vlt" | xargs rm -Rf
@thomashartm
thomashartm / set-jdk
Last active August 29, 2015 14:23
Switch JDK version bash command for Mac OSX
#!/bin/bash
####################################
# Exports jdk environment exports
# call:
# set-jdk <jdk-version> e.g. set-jdk 1.8
# or to set default:
# set-jdk
####################################
@thomashartm
thomashartm / set-dev-env
Last active August 29, 2015 14:27
Set envrionment specific maven settings by symlinking prepared env specific settings.xml files.
#!/bin/bash
####################################
# Prepares dev environment settings
# call:
# set-dev-env <environment>
# or for help:
# set-dev-env
####################################
#!/bin/bash
# first argument: file
# second argument: searchstring
#
find "$1" -name "*.jar" -exec sh -c 'jar -tf {}|grep -H --label {} '$2'' \;
@thomashartm
thomashartm / MyJobConsumerTest.java
Created December 12, 2015 16:49
Example mock verification test snippet ... using Mockito in an AEM related unit test
package net.thartm.someservice.jobs;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.List;
@thomashartm
thomashartm / CQ5 XPath Queries (Content)
Last active May 17, 2016 21:39
A collection of CQ5 related JCR queries in the XPath query language. Some of these queries might be project specific but are a nice blueprint for similar requriements.
Nodes with a certain attribute
//element(*)[jcr:content/@includePageInTools='true']
News without PubDate
//*[@cq:template="/apps/sampleproject/templates/newspage" and not(@pubdate)]
Pages without UUID
/jcr:root/content//element(*,cq:PageContent)[not(@uuid)]
Find Pages with component
import org.apache.jackrabbit.oak.spi.commit.CommitInfo
import org.apache.jackrabbit.oak.spi.commit.EmptyHook
import org.apache.jackrabbit.oak.spi.state.NodeStore
import org.apache.jackrabbit.oak.commons.PathUtils
def details(def session, String path) {
println "Details about children of ${path}"
NodeStore ns = session.store
def nb = ns.root.builder()