Java8: Map()+Filter()+Collect() example

25 06 2018
package tool;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
*
* A simple Java Program to demonstrate how to use map and filter method Java 8.
* In this program, we'll convert a list of String into a list of Integer and
* then filter all even numbers.
*/
public class Hello {
   public static void main(String[] args) {
      List<String> numbers = Arrays.asList("1", "2", "3", "4", "5", "6");
      System.out.println("original list: " + numbers);
      List<Integer> even = numbers.stream()
                                        .map(s -> Integer.valueOf(s))
                                        .filter(number -> number % 2 == 0)
                                        .collect(Collectors.toList());
      System.out.println("processed list, only even numbers: " + even);
   }
}

Output
original list: [1, 2, 3, 4, 5, 6]
the processed list, only even numbers: [2, 4, 6]

souce: https://dzone.com/articles/how-to-use-map-filter-collect-of-stream-in-java-8

Advertisements




No more Toshiba laptops

6 06 2018

Toshiba to Close the Book on Its Laptop Unit

TOKYO—Toshiba Corp., which was the first in the world to commercialize laptop computers in 1985, is selling the business to Sharp Corp., a symbolic step marking Toshiba’s withdrawal from most consumer businesses.

Sharp is paying just ¥4 billion ($36 million) for an 80.1% stake in a business that once was at the forefront of the global move toward mobile computing. Osaka-based Sharp, controlled by Taiwan-based iPhone assembler Foxconn Technology Group, has been expanding its consumer goods lineup because Foxconn wants to establish itself in branded electronic products.

The deal, disclosed by the companies Tuesday, highlights a contrast between the two electronics makers, both of which faced multibillion-dollar losses and management turmoil several years ago. Sharp has managed to turn itself around quickly under foreign management while Toshiba, which received more support from the Japanese government during its restructuring, is still trying to streamline its unprofitable portfolio.

Source:

https://www.wsj.com/articles/toshiba-to-close-the-book-on-its-laptop-unit-1528175106





Roger James Hamilton on Tom Preston-Werner

5 06 2018

In 2008, Tom Preston-Werner turned down a $300K job with Microsoft to work on his startup, Github, which paid him all of $0. Today, Microsoft bought Github for $7.5 billion. That’s over 20,000x that salary that Tom turned down.

Tom began GitHub as a site to host and share open source code. Faced with skeptics and critics when he quit his job to follow his dream, what did Tom do?

He wrote a blog called “How I Turned Down $300,000 from Microsoft to go Full-Time on GitHub”.

Tom writes in the 2008 blog that while in a full-time job with a search engine company, Powerset, he launched GitHub with co-founders Chris Wanstrath and PJ Hyett:

“We publicly launched the site on April 10th. TechCrunch was not invited. At this point it was still just three 20-somethings without a single penny of outside investment.”

“I was still working full time at Powerset on July 1, 2008 when we learned that Powerset had just been acquired by Microsoft for around $100 million. This was interesting timing. With the acquisition, I was going to be faced with a choice sooner than I had anticipated. I could either sign on as a Microsoft employee or quit and go GitHub full time.”

“At 29 years old, I was the oldest of the three GitHubbers, and had accumulated a proportionally larger amount of debt and monthly expenditure. I was used to my six digit lifestyle.”

“Further confounding the issue was the imminent return of my wife, Theresa, from her PhD fieldwork in Costa Rica. I would soon be transitioning from make-believe bachelor back to married man.”

“To muddy the waters of decision even more, the Microsoft employment offer was juicy. Salary + $300k over three years juicy. That’s enough money to make anybody think twice about anything.”

“So I was faced with this: a safe job with lots of guaranteed money as a Microsoft man or a risky job with unknown amounts of money as an entrepreneur. It was do or die time. Either pick GitHub and go for it, or make the safe choice and quit GitHub to make wheelbarrows full of cash at Microsoft.”

“If you want a recipe for restless sleep, I can give you one. Add one part “what will my wife think” with 3,000 parts Benjamin Franklin; stir in a “beer anytime you damn well please” and top with a chance at financial independence.”

“I broke the news to my boss at Powerset on the day the employment offer was due. I told him I was quitting to go work full time on GitHub. Like any great boss, he was bummed, but understanding. He didn’t try to tempt me with a bigger bonus or anything. I think deep down he knew I was going to leave. I may have even received a larger incentive to stay than others, on account of my being a flight risk.”

“Those Microsoft managers are crafty, I tell you. They’ve got retention bonuses down to a science. Well, except when you throw an entrepreneur, the singularity of the business world, into the mix. Everything goes wacky when you’ve got one of those around.”

Tom wrote this blog while still earning $0 from GitHub. 10 years later, GitHub has grown to 28 million developers with 85 million code repositories, making it the largest host of source code in the world.

Today Microsoft announced it is buying GitHub for $7.5 billion.

At the end of his blog he writes –

“In the end, just as Indiana Jones could never turn down the opportunity to search for the Holy Grail, I could no less turn down the chance to work for myself on something I truly love, no matter how safe the alternative might be.”

“When I’m old and dying, I plan to look back on my life and say “wow, that was an adventure,” not “wow, I sure felt safe.””

You can read Tom’s blog at http://tom.preston-werner.com/2008/10/18/how-i-turned-down-300k.html

If you’re at the same stage in your journey that Tom was, do the same thing. Write a blog about why you’re committed to the path you’re taking. It’ll make great reading when you look back 10 years from now.

“Be willing to delay short-term gratification for long-term greatness.” ~ Mandy Hale

Source:

https://m.facebook.com/story.php?story_fbid=10160216034415411&id=834545410





[Gizmodo] Microsoft Buys GitHub, and Some People Are Pissed

4 06 2018

Microsoft is officially buying Github, the internet’s largest source code repository, for a cool $7.5 billion in stock, with Microsoft VP Nat Friedman assuming the role of GitHub’s CEO. The acquisition isn’t without its detractors, who say they are already ditching GitHub and looking elsewhere. Concern over GitHub’s management in the future, along with Microsoft’s checkered past with open source, might be the biggest hurdle the company has to overcome.

See the whole article here.





Running Docker in Production?

25 01 2018

James Higginbotham describes nine things to consider when you decide to run docker in production servers.

Developers need to remember that Docker is a tool, not a full-blown cloud native architecture solution. It offers some amazing capabilities, and I’m very happy to have Docker as part of my architecture. But it requires the same effort to maintain a production Docker deployment as any other cloud-based solution (and perhaps even more).

Read more here.





Functional Design vs Technical Design

7 10 2016

Functional design is the kind of design that is agreed between software architects and business customers. It describes what the system has to do in a way that both parties can understand and agree. It might describe user interface requirements, it might discuss database access, it might discuss web services or other forms of communication, it might discuss service level agreements or clustering and redundancy. The point is that it should be detailled enough to become the agreed definition of what the system will do.

Technical design, on the other hand, is the kind of design that is agreed between software architects and software developers. It describes how the system will be built to meet the functional design. It contains detail and terminology not appropriate to business customers but needed by developers. It might describe screen layouts, it might describe database table and column names, it might discuss WSDL or communication protocols and file formats, it might discuss server and operating system versions and dependencies. The point is that it should be detailled enough to enable unit tests, code, configurations, and technical documentation work to begin.

Frank Carver

Source: https://coderanch.com/t/100106/patterns/Functional-Design-Technical-Design





java; int to int[]

9 09 2016

int[] digits = Integer.toString(num).chars().map(c -> c-='0').toArray();