Skip to content

Instantly share code, notes, and snippets.

View tmoreira2020's full-sized avatar

Thiago Leão Moreira tmoreira2020

View GitHub Profile
function parse_git_svn_revision {
ref1=$(__git_ps1 | sed -e "s/ (\(.*\))/(git: \1$(parse_git_dirty))/")
#ref1=$(parse_git_branch)
if [ "x$ref1" != "x" ]; then
ref2=$(git branch -a | grep git-svn)
if [ "x$ref2" != "x" ]; then
ref3=$(git svn info | grep Revision)
echo " ${ref1} (svn: r"${ref3#Revision: }") "
else
@tmoreira2020
tmoreira2020 / findClass.sh
Created April 17, 2011 15:06
Search for a class into a subdirectory tree and its jars/zips files.
#!/bin/bash
archives= find . -name '*.jar'
echo $archives
for i in `find . -name '*.jar'`; do
echo $i
jar tf $i | grep --color=always ${1}
#jar tf $i
echo
done
@tmoreira2020
tmoreira2020 / popup.js
Created June 29, 2011 16:55
Liferay Alloy popup async
AUI().use('aui-dialog', function(A) {
Liferay.YourPlugin = {
closePopup: function() {
var instance = this;
var popup = instance._getPopup()
if (popup) {
@tmoreira2020
tmoreira2020 / gist:1085242
Created July 15, 2011 18:33
Email notification using Freemaker and Kaleo
<state>
<name>approved</name>
<actions>
<notification>
<name>Application Approved Notification</name>
<description>Application Approved Notification</description>
<execution-type>onAssignment</execution-type>
<template>
<![CDATA[
<#assign context = serviceContext.getAttribute("context")>
@tmoreira2020
tmoreira2020 / gist:1098229
Created July 21, 2011 21:17
Changing MySQL password
use mysql;
update user set password = password ('root') where user = 'root';
flush privileges;
@tmoreira2020
tmoreira2020 / gist:1098233
Created July 21, 2011 21:18
Changing MySQL password from command line
mysqladmin -u root -p password 'root'
@tmoreira2020
tmoreira2020 / get-java-thread-memory-dump.sh
Created November 14, 2011 18:52
Gets a thread dump and memory photo of a Java application
#!/bin/bash
if [ -n "$1" ]; then
for (( ; ; ))
do
echo "infinite loops [ hit CTRL+C to stop]"
pid=`jps | grep $1 | awk '{print $1}'`
echo "Getting dump from process $pid"
jstat -gcutil $pid 250 3 >> dump-memory-$pid.txt
jstack -l $pid >> dump-thread-$pid.trc
@tmoreira2020
tmoreira2020 / gist:1379288
Created November 19, 2011 20:04
Script para executar um teste de cargar e coletar logs
if [ -d $1 ] && [ -n "$1" ]; then
service tomcat stop
sleep 20
tar -czvf /opt/liferay-portal-tomcat-6.0-ee-sp1/tomcat-6.0.32/logs/tomcat_logs.tgz /opt/liferay-portal-tomcat-6.0-ee-sp1/tomcat-6.0.32/logs/*
cp /opt/liferay-portal-tomcat-6.0-ee-sp1/tomcat-6.0.32/logs/tomcat_logs.tgz $1
rm -rf /opt/liferay-portal-tomcat-6.0-ee-sp1/tomcat-6.0.32/logs/*
mv /opt/liferay-portal-tomcat-6.0-ee-sp1/dump* $1
service tomcat start
/opt/liferay-portal-tomcat-6.0-ee-sp1/get-java-thread-memory-dump.sh Bootstrap
else
@tmoreira2020
tmoreira2020 / mysql-xfs-install-yum.sh
Created December 8, 2011 22:05
Install a MySQL server on a XFS partition using yum.
#!/bin/sh
VOLUME=$1
if [ -z $VOLUME ]; then
echo "You must specify the volume, like /dev/sdf"
exit 1;
fi
if [ ! -b $VOLUME ]; then
@tmoreira2020
tmoreira2020 / git-rollback.sh
Created June 14, 2012 15:15
Rollbacks a git commit
function gitrollback() { git diff -p -R "$1"^ "$1" > "$1".rollback ;}