Skip to content

Instantly share code, notes, and snippets.

@canhnt
canhnt / hippo.sh
Last active August 29, 2015 14:04
Bash script to compile, run Hippo CMS project
#!/bin/bash
PROFILE_FILENAME=".hippo"
backup() {
echo "Move repository from $1 to $2"
mv $1 $2
exit 0
}
get_profiles(){
# remove commented lines
<hst:link var="canonicalUrl" hippobean="${document}" canonical="true"/>
<hst:headContribution keyHint="canonical">
<link rel="canonical" href="${canonicalUrl}"/>
</hst:headContribution>
@canhnt
canhnt / hippo-mvn-gen.sh
Last active August 29, 2015 14:19
Generate Hippo essential project (10GA milestone1)
mvn archetype:generate \
-DarchetypeGroupId=org.onehippo.cms7 \
-DarchetypeArtifactId=hippo-project-archetype \
-DarchetypeVersion=2.01.02-milestone-1 \
-DarchetypeRepository=http://maven.onehippo.com/maven2
final InputStream pubKeyStream = getClass().getClassLoader().getResourceAsStream("pubkey.asc");
assertNotNull(pubKeyStream);
PGPPublicKeyRingCollection pubRingCollection = new PGPPublicKeyRingCollection(
PGPUtil.getDecoderStream(pubKeyStream),
new JcaKeyFingerprintCalculator());
final PGPPublicKeyRing pgpPublicKeyRing = pubRingCollection.getKeyRings().next();
assertNotNull(pgpPublicKeyRing);
final PGPPublicKey pgpPublicKey = pgpPublicKeyRing.getPublicKey();
@canhnt
canhnt / openshift-tomcat8-env.sh
Last active December 31, 2015 14:21
openshift-tomcat8-env
JAVA_HOME=$OPENSHIFT_DATA_DIR/bin/jre1.8.0_66
JAVA_ENDORSED_DIRS="$JAVA_HOME/endorsed"
CATALINA_HOME="$OPENSHIFT_DATA_DIR/bin/tomcat8/"
CATALINA_BASE="$OPENSHIFT_DATA_DIR/bin/tomcat8/"
CATALINA_PID="${CATALINA_BASE}/work/catalina.pid"
CLUSTER_ID="$(whoami)-$(hostname -f)"
MAX_HEAP=512
<Context>
<Manager pathname=”” />
<Parameter name=”repository-address” value=”rmi://127.11.6.129:15099/hipporepository” override=”false”/>
<Parameter name=”repository-directory” value=”${catalina.base}/../repository” override=”false”/>
<Parameter name=”start-remote-server” value=”false” override=”false”/>
<Parameter name=”check-username” value=”liveuser” override=”false”/>
<Resource name=”mail/Session” auth=”Container” type=”javax.mail.Session” mail.smtp.host=”localhost”/>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Repository
PUBLIC "-//The Apache Software Foundation//DTD Jackrabbit 2.6//EN"
"http://jackrabbit.apache.org/dtd/repository-2.6.dtd">
<Repository>
<DataSources>
<DataSource name="repositoryDS">
@canhnt
canhnt / .bashrc-git.sh
Created February 3, 2016 14:02
Show current git branch in the command prompt
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
NO_COLOR="\[\033[0m\]"
PS1="$GREEN\u@\h$NO_COLOR:\w$YELLOW\$(parse_git_branch)$NO_COLOR\$ "
git config --global alias.lol 'log --graph --decorate --pretty=oneline --abbrev-commit --all'
@canhnt
canhnt / rsync-ssh.md
Last active April 24, 2018 18:46
rsync

Upload:

rsync -avH -P /home/localuser/testfile1 -e ssh bob@example.com:/target/file/path

Download

rsync -P --rsh=ssh bob@example.com:/path/to/source /localpath/to/dest