Skip to content

Instantly share code, notes, and snippets.

View xcooper's full-sized avatar

Cooper xcooper

  • Commscope
  • Taiwan
View GitHub Profile
@xcooper
xcooper / test-generator-javabean.groovy
Last active August 29, 2015 14:18
Generate JavaBean instance from Interfaces using CGLIB
/**
* Dynamically create a Javabean from Interfaces.
* It's ugly, but works ;)
*
*/
@Grapes(@Grab(group='cglib', module='cglib', version='3.1'))
import net.sf.cglib.beans.*
import net.sf.cglib.proxy.*
interface Test {
@xcooper
xcooper / WebServiceAspect.java
Last active December 27, 2015 01:19
Aspect that check outside web service
@Aspect
public class WebServiceAspect {
@Pointcut("execution(public * com.service..*Service.*(..))")
void allService() {}
@Around("allService()")
@SuppressWarnings({ "rawtypes", "unchecked" })
public Object depressException(ProceedingJoinPoint joinPoint) throws Throwable {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
@xcooper
xcooper / backbone-jqgrid-reader.js
Created August 23, 2013 05:01
new this function to 'datatype' of jqgrid options, this will sync between Backbone collection and jqGrid
var BackboneJqGridReader = function(colleciton, grid) {
return function(postdata) {
var submitData = _.extend({}, postdata);
Backbone.sync("read", colleciton, {
attrs: submitData,
cache: false,
contentType: "application/json",
processData: false,
type: "POST",
@xcooper
xcooper / install-guard-livereload.sh
Created August 20, 2013 02:53
install guard livereload on ubuntu 13.04
sudo apt-get install ruby-dev
sudo gem install rdoc
sudo gem install guard
sudo gem install guard-livereload
@xcooper
xcooper / grid-submit-json.js
Created August 12, 2013 09:55
overwrite jqGrid ajax mechanism, send json to backend instead of submitting a form. datatype should be "json" "xml" "script" postData is data you wanna send ajaxGridOptions is ajax configuration of jQuery serializeGridData is a function having only one argument which is postData you provided, it should return a Serialized data(e.g. String)
self.grid.jqGrid("setGridParam", {
serializeGridData: self.serializeData,
url: self.executionUrl,
datatype: "json",
ajaxGridOptions: {
cache: false,
contentType: "application/json",
processData: false,
type: "POST"
},
@xcooper
xcooper / AbstractDumpI18nAction.java
Created July 29, 2013 09:58
This class is intentional to be extend to get all i18n key-value pairs using Map
package com.gss.tds.dc.struts2.action;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;