Skip to content

Instantly share code, notes, and snippets.

@CoderInOne
CoderInOne / RootConfig.java
Created September 21, 2016 15:17
# basic spring configuration
/**
* basic configuration
*/
@Configuration
@ComponentScan(
basePackages = {"spitter"},
excludeFilters = {
@ComponentScan.Filter(type = FilterType.ANNOTATION, value = EnableWebMvc.class)
}
)
@CoderInOne
CoderInOne / Mock http test for Spring MVC
Created September 21, 2016 15:32
We don't need open browser to test SpringMVC project by using Spring test mock
## mock test for spring mvc
### Home Controller to test
@Controller
public class HomeController {
@RequestMapping(value = "/", method = GET)
public String home() {
return "home";
}
}
@CoderInOne
CoderInOne / request_path_through_springmvc
Created September 21, 2016 15:35
Like file name showing
1. Requets coming into Spring’s DispatcherServlet.
2. Consulting handler mappings to query request's controller.
3. DispatcherServlet send request to Spring MVC controller.
4. Send back request with model and view name to DS.
5. DispatcherServlet consulting view resolver
to map logical view name to a specified view implement.
6. view implement, like jsp
7. return response
/**
* web init
*/
public class MyWebAppInitializer extends
AbstractAnnotationConfigDispatcherServletInitializer {
protected Class<?>[] getRootConfigClasses() {
return new Class<?>[0];
}
protected Class<?>[] getServletConfigClasses() {
@CoderInOne
CoderInOne / sql_ddl_create
Created September 22, 2016 14:55
SQL DDL CREATE Table
## create table
## use key here
create table if not exists tig_users (
uid bigint unsigned NOT NULL auto_increment,
user_id varchar(2049) NOT NULL,
sha1_user_id char(128) NOT NULL,
user_pw varchar(255) default NULL,
acc_create_time timestamp DEFAULT CURRENT_TIMESTAMP,
last_login timestamp DEFAULT 0,
@CoderInOne
CoderInOne / jQuery_basic
Created September 23, 2016 12:10
jQuery basic
# jQuery:文档加载后激活函数
# jQuery:基本使用
<script>
$(document).ready(function() {
$("#target1").css("color", "red");
$("#target1").prop("disabled", true);
$("#target4").remove();
$("#target2").appendTo("#right-well");
$("#target5").clone().appendTo("#left-well");
@CoderInOne
CoderInOne / img_text
Created September 23, 2016 14:42
Align text to the right of an image
# Align text to the right of an image
img {
display: inline-block;
margin-left: 40px;
}
.desc {
display: inline-block;
vertical-align:top;
@CoderInOne
CoderInOne / record_collection.js
Created September 25, 2016 02:27
FCC Record Collection
// Setup
var collection = {
"2548": {
"album": "Slippery When Wet",
"artist": "Bon Jovi",
"tracks": [
"Let It Rock",
"You Give Love a Bad Name"
]
@CoderInOne
CoderInOne / profile_lookup.js
Created September 25, 2016 02:49
array&key-value lookup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
@CoderInOne
CoderInOne / file_search_cmd.md
Created September 28, 2016 01:14
File search command in Linux

locate

Search for entries in a mlocate database.mlocate.db indexes disk paths and providing quick file search result.

  1. find files with specified: locate Downloads/*.pdf
  2. find files with some key words: locate Downloads/eclipse | grep setup.log
  3. update database[with super user]: updatedb
  4. show statistis figures: locate -S