Skip to content

Instantly share code, notes, and snippets.

View lvjian700's full-sized avatar

Jian Lyu lvjian700

View GitHub Profile
@lvjian700
lvjian700 / HibernateEchemaExport.java
Created September 5, 2012 02:26
Export Database Schema using hibernate tools
package dayang.tools.db;
import java.net.URL;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;
@lvjian700
lvjian700 / gist:3649896
Created September 6, 2012 02:06
Set IE Compatiable model
<meta http-equiv="X-UA-Compatible" content="IE=8" >
@lvjian700
lvjian700 / gist:3649890
Created September 6, 2012 02:06
Current OS is Win32 ?
def win32?
require 'Win32API'
return true
rescue LoadError
return false
end
@lvjian700
lvjian700 / gist:3649905
Created September 6, 2012 02:07
Get client ip, using java
public String getIpAddr(HttpServletRequest request) {
String ip = request.getHeader("x-forwarded-for");
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
@lvjian700
lvjian700 / DateConverter.java
Created September 6, 2012 07:25
DateConverter for Struts2/WebWork 2
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import lombok.extern.log4j.Log4j;
@lvjian700
lvjian700 / gist:3759339
Created September 21, 2012 01:46
My Ubuntu alias for Java Programmer
CATALINA_HOME=/home/lvjian/libs/tomcat6
#PATH=$CATALINA_HOME/bin:$PATH
# some alias about tomcat
alias tm='cd $CATALINA_HOME';
alias tmout='tail -f $CATALINA_HOME/logs/catalina.out';
alias tmstart='$CATALINA_HOME/bin/startup.sh';
alias tmstop='$CATALINA_HOME/bin/shutdown.sh';
alias tmconf='vim $CATALINA_HOME/conf/server.xml';
alias tmclear='rm -rf $CATALINA_HOME/work/*';
@lvjian700
lvjian700 / pom.xml
Created October 10, 2012 02:51
Using Maven create java web app with jetty plugin
mvn archetype:create -DgroupId=lv.site.wb -DartifactId=wb -DarchetypeArtifactId=maven-archetype-webapp
@lvjian700
lvjian700 / gist:3897512
Created October 16, 2012 06:22
Using DLog replace NSLog in Objective C
#ifdef DEBUG
# define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
# define DLog(...)
#endif
// ALog always displays output regardless of the DEBUG setting
#define ALog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
@lvjian700
lvjian700 / gist:3967479
Created October 28, 2012 04:14
How to install scss for textmate 2
# the scss: http://sass-lang.com/
# scss plugins: https://github.com/kuroir/SCSS.tmbundle
# dependences:
# mac os x & textmate 2
# git
mkdir -p ~/Library/Application\ Support/Avian/Bundles
cd ~/Library/Application\ Support/Avian/Bundles
git clone git://github.com/kuroir/SCSS.tmbundle.git "SCSS.tmbundle"
@lvjian700
lvjian700 / gist:4016381
Created November 5, 2012 09:52
Shell list for rails dev
# generate ctags for rails project
ctags -R --exclude=.git --exclude=log * --exclude=coverage