Skip to content

Instantly share code, notes, and snippets.

@knight1128
knight1128 / Java8Test
Created May 15, 2015
java 8 lamda sort vs java 7 sort
View Java8Test
package com.google.locationlab;
import com.google.common.collect.Lists;
import com.google.common.collect.Ordering;
import com.google.common.primitives.Ints;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.junit.Before;
import org.junit.Test;
@knight1128
knight1128 / PortalRestTemplateIntegrationTest
Created May 15, 2015
rest template with utf-8 text/html
View PortalRestTemplateIntegrationTest
package com.google.locationlab;
import com.google.common.collect.Lists;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Test;
import org.springframework.http.*;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.client.RestTemplate;
@knight1128
knight1128 / RestTemplateIntegrationTest
Created May 15, 2015
rest template with object mapping example code in utf8 communication
View RestTemplateIntegrationTest
package com.google.locationlab;
import com.google.common.collect.Lists;
import com.google.locationlab.model.LocationResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Test;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.*;
@knight1128
knight1128 / print-time-interval.rb
Created May 6, 2015
print time interval by ruby
View print-time-interval.rb
require 'date'
require 'time'
require 'optparse'
options = {:start_time => nil, :end_time => nil, :interval => nil}
parser = OptionParser.new do|opts|
opts.banner = "Usage: print-time-interval.rb --time [MIN | HOUR | DAY] --interval [5MIN | HOUR | DAY]"
opts.on('-s', '--start_time time', 'time') do |time|
options[:start_time] = time;
View gist:c151c8900061c4848591
package main
import "fmt"
func main() {
fmt.Println("test")
}
// $ go run test.go
// $ go build test.go