Skip to content

Instantly share code, notes, and snippets.

View rightgenius's full-sized avatar

Zhihao Deng rightgenius

View GitHub Profile
package com.campusapp.community.controller.interceptor;
import com.alibaba.druid.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.MethodParameter;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.support.WebDataBinderFactory;
class Test{
public boolean handleMessage(Message msg) {
StatService.onEvent(MainActivity.this.getApplicationContext(),
"handleMessage", "msg.what", msg.what);
// 根据发送过来的结果进行不同的处理
Log.d(TAG, "Message.what:" + msg.what);
String message = Constant.UNKNOWN_STATUS_TEXT;
oper = Constant.Operation.ING;
switch (msg.what) {
case Constant.INIT:
// in html
//============================
seajs.config({
alias:{
'jquery': 'gallery/jquery/1.8.2/jquery',
'base': './assets/base/src/base',
'dust': './assets/dust/src/dust.js'
},
preload:['seajs/plugin-less', 'seajs/plugin-text', 'seajs/plugin-coffee',]
});
@rightgenius
rightgenius / gist:4181296
Created December 1, 2012 09:34
Something error in ie7
;this.seajs={_seajs:this.seajs};seajs.version="1.2.0-dev";seajs._data={config:{debug:"",preload:[]},memoizedMods:{},packageMods:[]};seajs._util={};seajs._fn={};
(function(a){var c=Object.prototype.toString,b=Array.prototype;a.isString=function(a){return"[object String]"===c.call(a)};a.isObject=function(a){return a===Object(a)};a.isFunction=function(a){return"[object Function]"===c.call(a)};a.isArray=Array.isArray||function(a){return"[object Array]"===c.call(a)};a.indexOf=b.indexOf?function(a,d){return a.indexOf(d)}:function(a,d){for(var h=0,c=a.length;h<c;h++)if(a[h]===d)return h;return-1};var e=a.forEach=b.forEach?function(a,d){a.forEach(d)}:function(a,
d){for(var c=0,b=a.length;c<b;c++)d(a[c],c,a)};a.map=b.map?function(a,d){return a.map(d)}:function(a,d){var c=[];e(a,function(a,b,f){c.push(d(a,b,f))});return c};a.filter=b.filter?function(a,c){return a.filter(c)}:function(a,c){var b=[];e(a,function(a,j,f){c(a,j,f)&&b.push(a)});return b};a.unique=function(a){var c=[],b={};e(a,function(a){b[a]=1});if(Object.ke
@rightgenius
rightgenius / CharsetUtil.java
Created August 2, 2012 08:20
To judge the Chinese Character's Charset.
import java.io.BufferedInputStream;
import java.io.InputStream;
public class CharsetUtil {
public static String charset(InputStream inputStream) {
String charset = "GBK";
byte[] first3Bytes = new byte[3];
try {
boolean checked = false;
@rightgenius
rightgenius / Benchmark for nio.java
Created July 18, 2012 09:14
banchmark codes for java.nio
new Tester("BufferedReader count lines") {
@Override
public void test() throws IOException {
BufferedReader br = new BufferedReader(
new InputStreamReader(new FileInputStream(path)));
int count = 0;
while (br.ready()) {
String l = br.readLine();
count += countLine(l);
@rightgenius
rightgenius / UsingBuffers.java
Created July 17, 2012 02:55
show the uses of the interfaces of ByteBuffer
//: io/UsingBuffers.java
import java.nio.*;
import static net.mindview.util.Print.*;
public class UsingBuffers {
private static void symmetricScramble(CharBuffer buffer){
while(buffer.hasRemaining()) {
buffer.mark();
char c1 = buffer.get();
char c2 = buffer.get();
@rightgenius
rightgenius / BufferToText.java
Created July 16, 2012 12:19
show examples of ByteBuffers
//: io/BufferToText.java
// Converting text to and from ByteBuffers
import java.nio.*;
import java.nio.channels.*;
import java.nio.charset.*;
import java.io.*;
public class BufferToText {
private static final int BSIZE = 1024;
public static void main(String[] args) throws Exception {
@rightgenius
rightgenius / GetChannel.java
Created July 16, 2012 11:58
Describe how to use channel in java.nio
//: io/GetChannel.java
// Getting channels from streams
import java.nio.*;
import java.nio.channels.*;
import java.io.*;
public class GetChannel {
private static final int BSIZE = 1024;
public static void main(String[] args) throws Exception {
// Write a file:
@rightgenius
rightgenius / Directory.java
Created July 16, 2012 07:40
util for traversing the dir
//: net/mindview/util/Directory.java
// Produce a sequence of File objects that match a
// regular expression in either a local directory,
// or by walking a directory tree.
package net.mindview.util;
import java.util.regex.*;
import java.io.*;
import java.util.*;