Skip to main content

Posts

Showing posts from 2016

Start elasticsearch

If you installed elasticsearch using a package manager like  yum  or  apt-get  you should not start elasticsearch this way. Try to use the service: for instance  /etc/init.d/elasticsearch  or using the command  sudo service elasticsearch start You should also check if the logging.yml file is at the location mentioned in the stack trace: /usr/share/elasticsearch/config Using  sudo  to start elasticsearch is not good, you could do  sudo elasticsearch  to run as the elasticsearch user, but I prefer to use the service call as described in the second sentence.

JAVA_HOME vs java.home

What's the difference between JAVA_HOME and java.home? JAVA_HOME is the  JDK  install directory, e.g., C:\jdk5. It's meant to be set as an environment variable and referenced in Windows batch files or Unix scripts. I always have it in my Windows Control Panel and .tcsh files,along with other common environment variables. Some Java applications use the name jdk.home for this purpose, which I think is a better name. But JAVA_HOME has been used since the beginning and is now a convention. java.home is the  JRE  install directory, e.g.,  C:\jdk5\jre, or C:\Program Files\Java\jre1.5.0_06 . Unlike JAVA_HOME, I never seen java.home as an environment variable. java.home is a build-in Java system property, whose value is the  JRE  install directory. Since all Java system properties are also exposed as Ant build properties, you can also use ${java.home} in build files. Would jre.home be a better name? Maybe, but I don't think Sun will change it. Therefore, java.home is always there

MVSC architecture

http://stackoverflow.com/questions/5702391/mvcs-model-view-controller-service Service layer can be inerpreted a lot of ways, but it's usually where you have your core business processing logic, and sits below your MVC architecture, but above your data access architecture. For example you layer of a complete system may look like this: View Layer: Your MVC framework & code of choice Service Layer: Your Controller will call this layer's objects to get or update Models, or other requests. Data Access Objects: These are abstractions that your service layer will call to get/update the data it needs. This layer will generally either call a Database or some other system (eg: LDAP server, web service, or NoSql-type DB) The service layer would then be responsible for: Retreiving and creating your 'Model' from various data sources (or data access objects). Updating values across various repositories/resources. Performing application specific logic and manipulat

如何喝洋酒

一般鸡尾酒(highball, martini, margarita)都由一种烈性酒liquor和甜酒liqueur 及mix调制而成。 主要的烈性酒liquor:vodka(伏特加),gin(金酒),scotch(苏格兰威士忌whisky ,中文里最常见的牌子“芝华士”,就是 scotch),Irish(爱尔兰威士忌whisky), rye(加拿大威士忌whisky),bourbon(美国威士忌whisky,常见的牌子 jack daniels ),rum(莱姆酒,分三种颜色的莱姆酒:white,amble,dark,其中属amble rum 最贵 ,因为加工的工艺较其它复杂),tequila(墨西哥龙舌兰酒) 甜酒liqueur:甜酒的种类特别多,一般甜酒的名字就是酒的牌子(与liquor不同,比 如可有不同牌子的rye)。只列出几种:kahlua(墨西哥咖啡酒,这是最常见的牌子) ,Triple Sec(橘子味的甜酒),Amaretto(榛子味的甜酒,有不同的牌子) Baileys(爱尔兰奶酒,cream味的甜酒),Martini vermouth(苦艾酒,分红白两种) ,creme de cocao (奶油味甜酒),creme de menthe (薄荷味的甜酒,类似的甜酒但 是不同的牌子和名称:pepermint schnapps),peach schnapps(桃子味的甜酒), creme de banana (香蕉味的甜酒),blue curacao(兰色的甜酒,橘子味的) Melon liqueur(绿色的,哈密瓜味的甜酒),Grand Marnier(橘子味的带有白兰地味 的甜酒)…… 一般的liquor store有四五个区(liquor,liqueur,wine and champagne,beer, other)其实中国人买瓶洋酒就喝,就跟喝白酒似的,总是抱怨洋酒不好喝。实际上喝 的方法不对,洋酒一般是两种以上的酒(liquor加liqueur,或 liqueur和liqueur)互 相勾兑着喝,并且经常加相应的juice,soda等什么的。网上可能有很多recipe,学着 调调酒情调一下吧。

Frontend terminology

- node , 是javascript语言的环境和平台, - npm , bower 是一类,包管理, - webpack , browserify , 是一类,javascript预编译模块的方案, - requirejs , seajs , 是一类, 基于commonjs,amd,cmd,umd 之类的模块类包加载方案的框架, - grunt , gulp , 前端工具,合并、压缩、编译 sass/less,browser 自动载入资源, - react , angular , vue , backbone , 是一类,mvc , mvvm , mvp 之类的前端框架, - jquery , zepto , prototype , 是一类,前端 DOM , BOM 类库 , - ext , yui , kissy , dojo , 是一类,前端应用组件, - underscore , 函数式编程库。

Spring boot: configure it to find the webapp folder

See the docs:  http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-web-applications.html#boot-features-spring-mvc-static-content The static resources are loaded from  /static ,  /public ,  /resources ,  /META-INF/resources Using  src/main/webapp  is not recommended. You can customize that by overriding the  addResourceHandlers  method in  WebMvcConfigurerAdapter @Configuration public class MvcConfig extends WebMvcConfigurerAdapter { @Override public void addResourceHandlers ( ResourceHandlerRegistry registry ){ registry . addResourceHandler ( "/**" ) . addResourceLocations ( "/" ) . setCachePeriod ( 0 ); } } http://stackoverflow.com/questions/28725635/spring-boot-configure-it-to-find-the-webapp-folder

Spring annotation

In Spring 2.0 and later, the @Repository annotation is a marker for any class that fulfills the role or stereotype (also known as Data Access Object or DAO) of a repository. Among the uses of this marker is the automatic translation of exceptions. Spring 2.5 introduces further stereotype annotations: @Component, @Service, and @Controller. @Component is a generic stereotype for any Spring-managed component. @Repository, @Service, and @Controller are specializations of @Component for more specific use cases, for example, in the persistence, service, and presentation layers, respectively. Therefore, you can annotate your component classes with @Component, but by annotating them with @Repository, @Service, or @Controller instead, your classes are more properly suited for processing by tools or associating with aspects. For example, these stereotype annotations make ideal targets for pointcuts. Thus, if you are choosing between using @Component or @Service for your service layer, @S

System design (转)

我的面试也结束了 因为知道FLAG这类公司都会问到System Design的问题 所以这次面 试着重准备了一下 在这里分享给大家 如果有不对或者需要补充的地方 大家可以留言 这里说的System Design和OO Design不同 System Design在FLAG以及很多大公司中主要 是design scalable distributed systems 这里只讨论如何准备这种题目 == 入门 == 对于0基础的同学们 下面的资料可以按顺序开始看 1. http://www.hiredintech.com/app#system-design 这是一个专门准备面试的网站 你只用关心system design部分 有很多的link后面会重 复提到 建议看完至少一遍 2. https://www.youtube.com/watch?v=-W9F__D3oY4 非常非常好的入门资料 建议看3遍以上! 这是1里面提到的资料 是Harvard web app课的最后一节 讲scalability 里面会讲到很 多基础概念比如Vertical scaling, Horizontal scaling, Caching, Load balancing, Database replication, Database partitioning 还会提到很多基本思想比如avoid  single point of failure 再强调一遍 非常好的资料! 3. http://www.lecloud.net/post/7295452622/scalability-for-dummies-part-1-clones 1里面提到的 Scalability for Dummies 还算不错 可以看一遍 知道基本思想 结束语:当你结束这一部分的学习的时候 你已经比50%的candidate知道的多了(因为很 多人都不准备 或者不知道怎么准备system design) 恭喜:) == 进阶 == 这一部分的资料更加零散 每个看的可能不一样 但是你每多看一篇文章或者一个视频  你就比别人强一点 这部分你会遇到很多新名词 我的建议是每当你遇到一个不懂的概念时 多google一下  看看这个概念或者技术是什么意思 优点和缺点各是什么 什么时候用 这些你都知道以 后 你就可以把他运用到面试中 让

Java资源大全

推荐!国外程序员整理的Java资源大全 by  唐尤华 构建 这里搜集了用来构建应用程序的工具。 Apache Maven :Maven使用声明进行构建并进行依赖管理,偏向于使用约定而不是配置进行构建。Maven优于Apache Ant。后者采用了一种过程化的方式进行配置,所以维护起来相当困难。 Gradle :Gradle采用增量构建。Gradle通过Groovy编程而不是传统的XML声明进行配置。Gradle可以很好地配合Maven进行依赖管理,并且把Ant脚本当作头等公民。 字节码操作 编程操作Java字节码的函数库。 ASM :通用底层字节码操作及分析。 Javassist :尝试简化字节码编辑。 Byte Buddy :使用“流式API”进一步简化字节码生成。 代码分析 软件度量和质量评估工具。 Checkstyle :对编程规范和标准进行静态分析。 FindBugs :通过字节码静态分析找出潜在Bug。 PMD :对源代码中不良编程习惯进行分析。 SonarQube :通过插件集成其它分析组件,提供评估最终结果报告。 编译器 创建分析器、解释器和编译器的框架。 ANTLR :功能完备的自顶向下分析复杂框架。 JavaCC :相对ANTLR更具体,上手略为简单。支持语法语法超前预测(syntactic lookahead)。 持续集成 支持持续集成、测试和应用发布的工具。 Bamboo :Atlassian的持续集成(CI)解决方案,包含很多其它产品。 CircleCI :提供托管服务,可免费试用。 Codeship :提供托管服务,提供有限免费计划。 Go :ThoughtWork开源持续集成解决方案。 Jenkins :提供基于服务器的部署服务。 TeamCity :JetBrain持续集成方案,提供免费版。 Travis :提供托管服务,常用于开源项目。 数据库 简化数据库交互的工具、库。 Flyway :使用Java API轻松完成数据库迁移。 H2 :小型SQL数据库,以内存操作著称。 JDBI :便捷的JDBC抽象。 jOOQ :基于SQL schema生成类型安全代码。 Presto :针对大数据的分布式SQL查询