Skip to content

Instantly share code, notes, and snippets.

View tmoreira2020's full-sized avatar

Thiago Leão Moreira tmoreira2020

View GitHub Profile
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.Statement;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
public class LiferayShardingMigrationTool {
@tmoreira2020
tmoreira2020 / jboss-7.1.1-newrelic-3.4.2-deadlock
Created February 18, 2014 14:54
It show the deadlock when you have jboss-7.1.1 + newrelic-3.4.2
Found one Java-level deadlock:
=============================
"MSC service thread 1-16":
waiting to lock monitor 0x00007fb71c003ef8 (object 0x0000000601fb0f48, a org.jboss.modules.ModuleClassLoader),
which is held by "MSC service thread 1-1"
"MSC service thread 1-1":
waiting to lock monitor 0x00007fb71c003e50 (object 0x000000060016ce60, a com.newrelic.agent.instrumentation.weaver.Verifier),
which is held by "MSC service thread 1-11"
"MSC service thread 1-11":
waiting to lock monitor 0x00007fb71c003ef8 (object 0x0000000601fb0f48, a org.jboss.modules.ModuleClassLoader)
<%
int listTypeId = ParamUtil.getInteger(request, name, BeanParamUtil.getInteger(bean, request, listTypeFieldName));
List<ListType> listTypeModels = ListTypeServiceUtil.getListTypes(listType);
for (ListType listTypeModel : listTypeModels) {
%>
<aui:option selected="<%= listTypeId == listTypeModel.getListTypeId() %>" value="<%= listTypeModel.getListTypeId() %>"><liferay-ui:message key="<%= listTypeModel.getName() %>" /></aui:option>
import java.sql.Connection;
import com.mchange.v2.c3p0.ComboPooledDataSource;
public class MainC3P0 {
/**
* @param args
*/
public static void main(String[] args) throws Exception {
@tmoreira2020
tmoreira2020 / gist:2967517
Created June 21, 2012 18:16
Fix a binary conflict on git
#at the branch you want to rebase into "master > mybranch"
git rebase -s recursive -X theirs master
#then a binary conflict will happen so now you must checkout the version of the binary you want
git co --theirs -- my-binary-file.bin
git co --ours -- my-binary-file.bin
#now you must stage the file
git add my-binary-file.bin
@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 ;}
@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 / 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 / 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:1098233
Created July 21, 2011 21:18
Changing MySQL password from command line
mysqladmin -u root -p password 'root'