Skip to content

Instantly share code, notes, and snippets.

View xiaodongw's full-sized avatar

Xiaodong Wang xiaodongw

  • Box
  • Redwood City
View GitHub Profile
@xiaodongw
xiaodongw / gist:becbeaf579e9abdb49da
Created May 18, 2015 22:05
Salat ClassAnalyzer
/*
* Copyright (c) 2010 - 2012 Novus Partners, Inc. (http://www.novus.com)
*
* Module: salat-util
* Class: ClassAnalyzer.scala
* Last modified: 2012-06-28 15:37:35 EDT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@xiaodongw
xiaodongw / gist:fad9cd5f961e9e749d17
Created May 18, 2015 21:01
Get Enumeration information by reflection
trait EnumInflater extends Transformer with Logging {
self: Transformer =>
val clazz = getClassNamed_!(path)
val companion: Any = clazz.companionObject
val withName: Method = clazz.getDeclaredMethods.filter(_.getName == "withName").head
val applyInt: Method = clazz.getDeclaredMethods.filter(_.getName == "apply").head
override def transform(value: Any)(implicit ctx: Context): Any = {
val strategy = {
@xiaodongw
xiaodongw / gist:14d0aad7555cdbcd3c50
Created March 11, 2015 18:40
moment-timezone in HTML
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="">
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment.js"></script>
<script src="http://momentjs.com/downloads/moment-timezone-with-data-2010-2020.js"></script>
<script type="text/javascript">
//moment().format();
// create moment from string or now
@xiaodongw
xiaodongw / gist:deff30ff4905ffcebf12
Created December 5, 2014 17:14
Gradle - publish snapshot & release to different places
apply plugin: 'maven-publish'
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
repositories {
maven {
@xiaodongw
xiaodongw / HexString.java
Last active December 15, 2015 03:28
Convert byte to hex string
package test.hex;
import java.sql.Date;
public class HexTest {
/**
* @param args
*/
public static void main(String[] args) {
package com.orientdb.test;
import static org.junit.Assert.*;
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
package com.test.thrift;
import java.util.HashMap;
import java.util.Map;
import org.apache.thrift.TException;
public class MyServiceImpl implements MyService.Iface {
@Override
package com.test.thrift;
import org.apache.thrift.transport.TServerSocket;
import org.apache.thrift.protocol.TCompactProtocol;
import org.apache.thrift.protocol.TCompactProtocol.Factory;
import org.apache.thrift.server.TServer;
import org.apache.thrift.server.TThreadPoolServer;
import org.apache.thrift.server.TThreadPoolServer.Args;
public class MyServer {
package com.test.thrift;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TCompactProtocol;
import org.apache.thrift.protocol.TProtocol;
package test.solr;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Collection;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;