Skip to content

Instantly share code, notes, and snippets.

View jamesnguyen101's full-sized avatar

Loi Nguyen jamesnguyen101

View GitHub Profile
package com.mycomp;
import ognl.OgnlRuntime;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.util.logging.Logger;
/**
@jamesnguyen101
jamesnguyen101 / QuestionLocalServiceImpl.java
Last active December 16, 2015 19:39
QuestionLocalServiceImpl.java class
/**
* Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
@jamesnguyen101
jamesnguyen101 / setenv.sh
Last active August 29, 2015 14:17 — forked from terrancesnyder/setenv.sh
$TOMCAT_HOME/bin/setenv.sh|bat
#! /bin/sh
# ==================================================================
#https://gist.github.com/terrancesnyder/986029
# Multi-instance Apache Tomcat installation with a focus
# on best-practices as defined by Apache, SpringSource, and MuleSoft
# and enterprise use with large-scale deployments.
# Credits:
# Google -> Couldn't survive without it
# Stackoverflow.com -> Community support
@jamesnguyen101
jamesnguyen101 / tomcat.sh
Last active August 29, 2015 14:17
tomcat service . /etc/init.d/tomcat.sh
#!/bin/sh
### BEGIN INIT INFO
# Provides: tomcat
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and stop Apache Tomcat
# Description: Enable Apache Tomcat service provided by daemon.
@jamesnguyen101
jamesnguyen101 / setenv.sh
Last active August 29, 2015 14:17
commons options for tomcat. add|edit $TOMCAT_HOME/bin/setenv.sh|bat
export CATALINA_OPTS="$CATALINA_OPTS -Dfile.encoding=UTF8 -Djava.net.preferIPv4Stack=true -Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false"
export CATALINA_PID=$CATALINA_HOME/bin/tomcat.pid
export JAVA_OPTS="$JAVA_OPTS -Xms128m -Xmx1024m -XX:PermSize=64m -XX:MaxPermSize=256m"
#!/bin/sh
TOMCAT_HOME="/opt/yosport/yosport_app/tomcat8"
TOMCAT_USER=root
#all app name that start with yo prefix
app_name="yo*"
# stop tomcat if it is running
TOMCAT_PID=`ps -ef | grep "$TOMCAT_HOME/" | grep 'Bootstrap start$' | awk '{print $2}'`
if [ ! -z $TOMCAT_PID ] ; then
echo "Tomcat still be running with PID $TOMCAT_PID."
/**
* Autowire Quartz Jobs with Spring context dependencies
* @see http://stackoverflow.com/questions/6990767/inject-bean-reference-into-a-quartz-job-in-spring/15211030#15211030
*/
public final class AutowiringSpringBeanJobFactory extends SpringBeanJobFactory implements ApplicationContextAware {
private transient AutowireCapableBeanFactory beanFactory;
public void setApplicationContext(final ApplicationContext context) {
beanFactory = context.getAutowireCapableBeanFactory();
}
@jamesnguyen101
jamesnguyen101 / laravel-redis-clear.php
Created July 21, 2015 08:01
Clear cache Item on redis server via laravel
/**
* remove cache items
* eg : $this->clearCache(array('clips'));
*/
public function clearCache(array $keyList) {
$redis = Cache::getRedis();
$cursor = 0;
while($data = $redis->scan($cursor))
{
$cursor = $data[0];
@jamesnguyen101
jamesnguyen101 / RedisClearCache.php
Created August 22, 2015 12:25
clear redis keys
/**
* remove cache items
* eg : $this->clearCache(array('clips'));
* link : http://stackoverflow.com/questions/14873506/deleting-from-laravel-cache-using-pattern-for-key\
oki voi redis 3.0 (die voi 3.0.3)
*/
/*
@jamesnguyen101
jamesnguyen101 / server.xml
Created August 23, 2015 17:10
$TOMCAT_HOME/conf/server.xml mapping root path (/) to my app context --> overidde default tomcat root root context
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
<!--
SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html
-->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->