java - Lambda reference to a field - Stack Overflow



java - Lambda reference to a field - Stack Overflow

It sounds like you're hoping that Java has a corresponding feature for field references as it does for method references. But this is not the case. Method references are shorthand for a certain category of lambda expressions, but there is no corresponding syntax for fields. Field literals were explored during the JSR-335 Expert Group deliberation (there is some reference to it here http://mail.openjdk.java.net/pipermail/lambda-dev/2011-November/004235.html) but were not included in Java SE 8.


Read full article from java - Lambda reference to a field - Stack Overflow


美国企业的装嫩问题



美国企业的装嫩问题

这些"新奇","年轻"的企业文化,似乎很容易吸引刚走出学校,未经世事的年轻人,然而在一个成熟的人看来,这些公司并没有显示出真正的活力,而是显示出愚蠢和虚伪。事实证明,缺乏隔离措施的所谓"开放空间"办公室,并不如传统的单间办公室或者隔离间(cubicle)。编程需要的是独立思考,思考需要集中注意力,很多人思考时甚至不喜欢别人能直接看见自己。没有隔离和隐私措施的办公室,使得员工之间随时都可以互相干扰,难以集中注意力,这对于写出优雅清晰的代码是很不利的。要是遇到那种成天高谈阔论的人在你旁边,那就更倒霉了,不得不成天戴着耳机工作。有些人时不时地发动 NERF 枪战,不但极大地干扰其他人的正常工作,而且制造一种浮躁虚假的氛围,你甚至可能因此受伤。至于 Agile,站会,试用新语言,采用结对编程,鼓吹 TDD,突发奇想的新管理方式,等等,都是 startup 的通病。很多新公司没有经验,不知道什么是真正好的技术和管理方式,再加上不小心招进来不懂装懂的管理者,所以走一步错一步,浪费大量的资源,一步步地走向失败。


Read full article from 美国企业的装嫩问题


java - Google's Json Parsing Gson library: What's the difference between JsonElement and JsonObject? - Stack Overflow



java - Google's Json Parsing Gson library: What's the difference between JsonElement and JsonObject? - Stack Overflow

JsonElement is the base type for all of the different specific types - it's a base class with common things that all nodes should implement. Logically, this makes a lot of sence.

The thing that all specific types inherits from JsonElement is a good thing for you, too. It allows you to test if an object is a Json node representation, simply by checking if it inherits from JsonElement.

The JsonElement class is available to you as a public class probably not because you'd want to subclass it, but because you'd want to test for its subclasses.


Read full article from java - Google's Json Parsing Gson library: What's the difference between JsonElement and JsonObject? - Stack Overflow


Kafka的消息可靠传递 · 乱世浮生



Kafka的消息可靠传递 · 乱世浮生

Kafka提供的基础保障可以用来构建可靠的系统, 却无法保证完全可靠. 需要在可靠性和吞吐之间做取舍.

  • Kafka在分区上提供了消息的顺序保证.
  • 生产的消息在写入到所有的同步分区上后被认为是已提交 (不需要刷到硬盘). 生产者可以选择在消息提交完成后接收broker的确认, 是写入leader之后, 或者所有的副本
  • 只要有一个副本存在, 提交的消息就不会丢失
  • 消费者只能读取到已提交的消息


Read full article from Kafka的消息可靠传递 · 乱世浮生


阿里Dubbo疯狂更新,关Spring Cloud什么事?



阿里Dubbo疯狂更新,关Spring Cloud什么事?

但它们两者的出发点是不一样的,Dubbo 关注于服务治理这块并且以后也会继续往这个方向去发展。


Spring Cloud 关注的是微服务治理的生态。因为微服务治理的方方面面都是它所关注的内容,服务治理也只是微服务生态的一部分而已。


因此可以大胆的断定,Dubbo 未来会在服务治理方面更为出色,而 Spring Cloud 在微服务治理上面无人能敌。


同时根据 Dubbo 最新的更新技术来看,Dubbo 也会积极的拥抱开源,拥抱新技术。


Dubbo 接下来的版本将会很快的支持 Spring Boot,方便我们享受高效开发的同时,也可以支持高效的服务调用。


Dubbo 被广泛应用于中国各互联网公司,如今阿里又重新重视起来并且发布了新版本和一系列的计划,对于正在使用 Dubbo 的公司来说是一个喜讯,对于中国广大的开发者来说更是一件非常喜悦的事情。


Read full article from 阿里Dubbo疯狂更新,关Spring Cloud什么事?


苹果在医疗健康领域的三个 Kit



苹果在医疗健康领域的三个 Kit

HealthKit 作为最早推出的开发套件,实际上也是苹果整个医疗健康产业的基石。试着去打开你手机上的「健康」应用,你可以看到各类健康相关的指标,从基本的健康数据,到生殖健康,再到化验结果、营养摄入……大大小小总共涵盖了数十种指标和体征数据。之所以说 HealthKit 是后面一系列事情的基石,正在于它定义了数据的类型和互相通信的标准。现在,你可以通过将各类第三方健康应用,如 Keep、乐动力、Runtastic,甚至微信运动,它们都可以通过 HealthKit 互相交换、读取、写入健康相关的数据。


Read full article from 苹果在医疗健康领域的三个 Kit


java - Jersey: Is there a clean way to specify allowed URL extensions? - Stack Overflow



java - Jersey: Is there a clean way to specify allowed URL extensions? - Stack Overflow

Jersey will select the appropriate media type based on the url extension. Note that Response is returned instead of String. I'm not sure how you're building your response and what your requirements are but Jersey can handle converting your Java beans into either XML or JSON (or even JSONP) without a problem.


Read full article from java - Jersey: Is there a clean way to specify allowed URL extensions? - Stack Overflow


coding style - Exception messages and event logging - which tense to use? - Software Engineering Stack Exchange



coding style - Exception messages and event logging - which tense to use? - Software Engineering Stack Exchange

I like to use present tense when the error/exception-generating code is the "root cause" of the problem, and past tense when I'm merely repackaging an error/exception from a lower layer of code.

For example, when our frontend makes a request to our backend, the backend may return an error message "Cannot connect to database", and the frontend will throw "Failed to retrieve your widgets because: Cannot connect to database".


In general, the only "best practices" in regards to exception/error wording are to make it as clear, unambiguous, non-misleading and consistent as possible. In my opinion the tense convention I just described fits those criteria the best, but there are probably other equally valid conventions.


Read full article from coding style - Exception messages and event logging - which tense to use? - Software Engineering Stack Exchange


The best Google deals of Black Friday 2017: Google Home Mini, Chromecast, Google Wifi - The Verge



The best Google deals of Black Friday 2017: Google Home Mini, Chromecast, Google Wifi - The Verge

Google's Black Friday and Cyber Monday sales this year will be all about the home. So if you're hoping to score a deal on the new Pixel 2 smartphones during this long weekend's shopping events, I have some bad news. In fact, it doesn't appear that any of the Pixel-branded devices announced back in October will be discounted, or at least the company hasn't announced anything yet and we're just 48 hours away from kickoff.


Read full article from The best Google deals of Black Friday 2017: Google Home Mini, Chromecast, Google Wifi - The Verge


cp - Strange behaviour in recursive copy - Unix & Linux Stack Exchange



cp - Strange behaviour in recursive copy - Unix & Linux Stack Exchange

For cp, the destination is the last argument on the command line. You have specified 2/g as the last argument.

Before cp is executed, the command parameters are expanded. 1/* expands to 1/a 1/b 1/c. 2/* expands to 2/f 2/g. The final executed command is cp -r 1/a 1/b 1/c 2/f 2/g, which will copy all the arguments (except the last one) to 2/g.

If you are intending to copy things to 2, the second glob isn't necessary, making the command cp -r 1/* 2/. If you are intending to copy things to multiple destinations, you can't specify that with just cp; you can use a small loop, like the following:


Read full article from cp - Strange behaviour in recursive copy - Unix & Linux Stack Exchange


COPY command ignores USER, sets file ownership to root · Issue #13020 · moby/moby · GitHub



COPY command ignores USER, sets file ownership to root · Issue #13020 · moby/moby · GitHub

If you are reporting a new issue, PLEASE make sure that does not have any duplicates already open.

We would like to take this time to remind you of the information we need to debug the problem you are seeing. This is an automated response so if this ticket is not about a bug, do not fret.

If you fail to provide this information within 7 days, we will close this because we cannot debug your issue. We can reopen whenever the information is provided.


Read full article from COPY command ignores USER, sets file ownership to root · Issue #13020 · moby/moby · GitHub


Get a Competitive Rate on Homeowners Insurance - @Redfin



Get a Competitive Rate on Homeowners Insurance - @Redfin

You didn't get a dime for doing your homework in school, but it can pay off big time when it comes to buying homeowners insurance. Go online or call several reputable homeowners insurance companies to compare coverage and get quotes. Then evaluate policies side by side and "apples to apples." Keep in mind, your home is likely your most valuable asset; a radically inexpensive policy may not adequately protect your home.


Read full article from Get a Competitive Rate on Homeowners Insurance - @Redfin


Sysadmin 101: Troubleshooting - All things sysadmin



Sysadmin 101: Troubleshooting - All things sysadmin

I typically keep this blog strictly technical, keeping observations, opinions and the like to a minimum. But this, and the next few posts will be about basics and fundamentals for starting out in system administration/SRE/system engineer/sysops/devops-ops (whatever you want to call yourself) roles more generally.

Read full article from Sysadmin 101: Troubleshooting - All things sysadmin


What is the difference between a mortgage interest rate and an APR?



What is the difference between a mortgage interest rate and an APR?

The interest rate is the cost you will pay each year to borrow the money, expressed as a percentage rate. It does not reflect fees or any other charges you may have to pay for the loan.

An annual percentage rate (APR) is a broader measure of the cost to you of borrowing money, also expressed as a percentage rate. In general, the APR reflects not only the interest rate but also any points, mortgage broker fees, and other charges that you pay to get the loan. For that reason, your APR is usually higher than your interest rate.


Read full article from What is the difference between a mortgage interest rate and an APR?


Reveal file in sidebar - features - Atom Discussion



Reveal file in sidebar - features - Atom Discussion

The tree-view package now supports this feature through the autoReveal option.


Read full article from Reveal file in sidebar - features - Atom Discussion


java - @RunWith(MockitoJUnitRunner.class) vs MockitoAnnotations.initMocks(this) - Stack Overflow



java - @RunWith(MockitoJUnitRunner.class) vs MockitoAnnotations.initMocks(this) - Stack Overflow

So I would recommend the use of the MockitoJUnitRunner wherever possible. However, as Tomasz Nurkiewicz has correctly pointed out, you can't use it if you need another JUnit runner, such as the Spring one.

My recommendation has now changed. The Mockito team have added a new feature since I first wrote this answer. It's a JUnit rule, which performs exactly the same function as the MockitoJUnitRunner. But it's better, because it doesn't preclude the use of other runners.


Read full article from java - @RunWith(MockitoJUnitRunner.class) vs MockitoAnnotations.initMocks(this) - Stack Overflow


java - @RunWith(MockitoJUnitRunner.class) vs MockitoAnnotations.initMocks(this) - Stack Overflow



java - @RunWith(MockitoJUnitRunner.class) vs MockitoAnnotations.initMocks(this) - Stack Overflow

MockitoJUnitRunner gives you automatic validation of framework usage, as well as an automatic initMocks().

The automatic validation of framework usage is actually worth having. It gives you better reporting if you make one of these mistakes.

  • You call the static when method, but don't complete the stubbing with a matching thenReturn, thenThrow or then. (Error 1 in the code below)

  • You call verify on a mock, but forget to provide the method call that you are trying to verify. (Error 2 in the code below)

  • You call the when method after doReturn, doThrow or doAnswer and pass a mock, but forget to provide the method that you are trying to stub. (Error 3 in the code below)

If you don't have validation of framework usage, these mistakes are not reported until the following call to a Mockito method. This might be

  • in the same test method (like error 1 below),
  • in the next test method (like error 2 below),
  • in the next test class.


Read full article from java - @RunWith(MockitoJUnitRunner.class) vs MockitoAnnotations.initMocks(this) - Stack Overflow


java - MockitoJUnitRunner is deprecated - Stack Overflow



java - MockitoJUnitRunner is deprecated - Stack Overflow

org.mockito.runners.MockitoJUnitRunner is now indeed deprecated, you are supposed to use org.mockito.junit.MockitoJUnitRunner instead. As you can see only the package name change, the simple name of the class is still MockitoJUnitRunner.


Read full article from java - MockitoJUnitRunner is deprecated - Stack Overflow


ClassFormatError when trying to mock certain interfaces · Issue #1215 · mockito/mockito · GitHub



ClassFormatError when trying to mock certain interfaces · Issue #1215 · mockito/mockito · GitHub

I stumbled over some strange behaviour when trying to update from a 1.x version of Mockito to 2.x. One of my interfaces would no longer want to be mocked, throwing a MockitoException, with an error message of Mockito cannot mock this class: interface <MyInterfaceName>, ultimately triggered by a java.lang.ClassFormatError: Duplicate field name&signature in class file <MyInterfaceName>$MockitoMock$1318839329


Read full article from ClassFormatError when trying to mock certain interfaces · Issue #1215 · mockito/mockito · GitHub


You Can't Plug iPhone 7 Headphones Into a New Macbook Pro



You Can't Plug iPhone 7 Headphones Into a New Macbook Pro

Fortunately, Apple makes a dongle that lets you plug normal headphones into a Lightning port. Unfortunately, Apple does not make its reverse: an adapter that lets you plug Lightning headphones into a headphone port. Until someone whips one up, you'll have to either go Bluetooth, use a dongle to use old headphones on your iPhone 7, or keep an extra pair of headphones at your desk.

Most Popular
Why Aircraft Carriers Have an Angled Runway
The Pentagon Is Working on a New Air-to-Air Missile
What We Really Learned From the Newest Star Wars: The Last Jedi Trailer

To be fair, plugging iPhone 7 pack-in headphones into a new Macbook Pro is a pretty specific use case, small enough that you can see why Apple wouldn't add an extra port to the Macbook Pro just for that. Then again, this means even Apple's very newest devices don't play nice together, and the dongle that would let them doesn't even exist yet. We've reached out to Apple to see if they plan on a new dongle.


Read full article from You Can't Plug iPhone 7 Headphones Into a New Macbook Pro


ssh - How to restart sshd in OSX Lion? - Ask Different



ssh - How to restart sshd in OSX Lion? - Ask Different

You probably know this already, but I'll say to be complete: if you kill sshd processes you'll terminate active SSH sessions to the machine. The sshd daemon provides ssh access to your machine. It handles incoming ssh connections. Not outbound connections.


Read full article from ssh - How to restart sshd in OSX Lion? - Ask Different


[JDK-8165852] (fs) Mount point not found for a file which is present in overlayfs - Java Bug System



[JDK-8165852] (fs) Mount point not found for a file which is present in overlayfs - Java Bug System

The problem as it manifests in btrfs is essentially the same situation as observed for overlayfs in docker: the parent of a path component has a different device ID than that of the current path component and so the loop of the upwards traversal towards the root is broken out of but there is no entry for the current path component in /proc/mounts. This was observed to occur specifically for the case of a file contained in a btrfs sub-volume which is not itself explicitly mounted. If the sub-volume is mounted via `mount` it shows up in /proc/mounts and the error does not occur. This failure might be due to the nature of btrfs sub-volumes and unrelated to Docker per se.
Show
bpb Brian Burkhalter added a comment - - edited The problem as it manifests in btrfs is essentially the same situation as observed for overlayfs in docker: the parent of a path component has a different device ID than that of the current path component and so the loop of the upwards traversal towards the root is broken out of but there is no entry for the current path component in /proc/mounts. This was observed to occur specifically for the case of a file contained in a btrfs sub-volume which is not itself explicitly mounted. If the sub-volume is mounted via `mount` it shows up in /proc/mounts and the error does not occur. This failure might be due to the nature of btrfs sub-volumes and unrelated to Docker per se.


    Read full article from [JDK-8165852] (fs) Mount point not found for a file which is present in overlayfs - Java Bug System


    Labels

    Algorithm (219) Lucene (130) LeetCode (97) Database (36) Data Structure (33) text mining (28) Solr (27) java (27) Mathematical Algorithm (26) Difficult Algorithm (25) Logic Thinking (23) Puzzles (23) Bit Algorithms (22) Math (21) List (20) Dynamic Programming (19) Linux (19) Tree (18) Machine Learning (15) EPI (11) Queue (11) Smart Algorithm (11) Operating System (9) Java Basic (8) Recursive Algorithm (8) Stack (8) Eclipse (7) Scala (7) Tika (7) J2EE (6) Monitoring (6) Trie (6) Concurrency (5) Geometry Algorithm (5) Greedy Algorithm (5) Mahout (5) MySQL (5) xpost (5) C (4) Interview (4) Vi (4) regular expression (4) to-do (4) C++ (3) Chrome (3) Divide and Conquer (3) Graph Algorithm (3) Permutation (3) Powershell (3) Random (3) Segment Tree (3) UIMA (3) Union-Find (3) Video (3) Virtualization (3) Windows (3) XML (3) Advanced Data Structure (2) Android (2) Bash (2) Classic Algorithm (2) Debugging (2) Design Pattern (2) Google (2) Hadoop (2) Java Collections (2) Markov Chains (2) Probabilities (2) Shell (2) Site (2) Web Development (2) Workplace (2) angularjs (2) .Net (1) Amazon Interview (1) Android Studio (1) Array (1) Boilerpipe (1) Book Notes (1) ChromeOS (1) Chromebook (1) Codility (1) Desgin (1) Design (1) Divide and Conqure (1) GAE (1) Google Interview (1) Great Stuff (1) Hash (1) High Tech Companies (1) Improving (1) LifeTips (1) Maven (1) Network (1) Performance (1) Programming (1) Resources (1) Sampling (1) Sed (1) Smart Thinking (1) Sort (1) Spark (1) Stanford NLP (1) System Design (1) Trove (1) VIP (1) tools (1)

    Popular Posts