This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestController | |
public class GreetingController { | |
@RequestMapping("/my/rest/exception") | |
public @ResponseBody ResponseEntity<String> myException() { | |
if (true) | |
throw new MyRestException("should see me"); | |
return new ResponseEntity<String>("don't see me", HttpStatus.OK); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Common Commands | |
ssb = status -sb | |
logo = log --oneline | |
c = commit -m | |
a = add | |
cob = checkout -b | |
st = status -s | |
co = checkout | |
stat = status | |
cl = clone |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.data.mongodb.gridfs.GridFsTemplate; | |
import org.springframework.http.HttpStatus; | |
import org.springframework.http.ResponseEntity; | |
import org.springframework.stereotype.Controller; | |
import org.springframework.web.bind.annotation.*; | |
import org.springframework.web.multipart.MultipartFile; | |
import java.io.IOException; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.gson.Gson; | |
import org.skyscreamer.jsonassert.JSONAssert; | |
import static org.junit.Assert.fail; | |
public final class JSONUtils { | |
private static final Gson gson = new Gson(); | |
public static void assertValidJson(String jsonInString) { | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.tmuxinator/basic.yml | |
name: basic | |
root: ~/ | |
windows: | |
- editor: | |
layout: main-vertical | |
panes: | |
- top |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring: | |
data: | |
mongodb: | |
host: ${MONGO_HOST} | |
port: ${MONGO_PORT} | |
database: ${MONGO_DB} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bson import json_util | |
# load as timestamp | |
print json_util.loads('{"$date": 1414516147000}') | |
# load as isodate | |
print json_util.loads('{"$date": "2014-10-28T17:09:07.000Z"}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.fasterxml.jackson.annotation.JsonView; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
class Views { | |
public static class Normal{} | |
public static class WithTitle extends Normal{} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.fasterxml.jackson.annotation.JsonProperty; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.http.HttpStatus; | |
import org.springframework.http.ResponseEntity; | |
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; | |
import org.springframework.web.bind.annotation.RequestMapping; | |
import org.springframework.web.bind.annotation.ResponseBody; | |
import org.springframework.web.bind.annotation.RestController; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.fasterxml.jackson.databind.ObjectMapper; | |
import org.springframework.http.*; | |
import org.springframework.web.client.RestTemplate; | |
class PostJacksonObjectViaRestTemplate { | |
public static void main(String[] args) throws Exception { | |
String url = "http://localhost:8080/example/"; | |
HttpHeaders headers = new HttpHeaders(); |
OlderNewer