Display facebook posts on your website

Recently I had to display Facebook page posts on website in favor of embedding simple widget. The problem of widget is that it’s not showing full posts and it has limited size. There is a bunch of tutorials on how to integrate Facebook feed with website. But here I want to share some general tips based on my latest experience.
  1. There is no anonymous API access, even for public posts. You have to register your website as an application on “developers.facebook.com”. Registration requires to verify your Facebook account by phone number or credit card! Playing with API on “Grap API Explorer” also requires login.
  2. One-time access token is not necessary to use API. You can use combination of “app id” and “app secret” as well. But remember to use it only on server side! E.g.:
    1. https://graph.facebook.com/endpoint?key=value&access_token=${app_id}|${app_secret}
  3. Create link to Facebook post/page by adding id at the end of the base URL:
    1. https://facebook.com/${id}

Programistok 2017: quick notes

Last Saturday I attended conference for programmers in my home town Białystok. Programistok“, because that how it’s called, is a one day event for about 400 people from different software development worlds: .NET, JavaScript, Python, Java and other. Here I would like to mention my top 3 presentations.
The first one from Andrzej Rusewicz was about productivity. He claimed that only delivering new features is productive. The rest like fixing bugs, refactoring has zero productivity. Another thought was about importance of the technical documentation. He said a very general idea, that “week of planning can protect us from months of zero productivity”. Can’t disagree, but of course it depends on project size, deadlines.
Next one from Mirosław Burnejko was kind of showtime. He was speaking with such tremendous confidence, that every meme on his slides makes everybody instantly laughing. Moreover he was smiling a lot and wore shirt with rolled up sleeves. He spoke about difference between AWS and Azure. The conclusion was that there is no real difference and the only reason to pick one of them is project technology. I appreciated the last thought that we should reuse existing services/tools instead of developing something from scratch. At the discussion panel he shares his productivity rule of “elimination-automation-delegation” of tasks.

And IMO the best presentation was delivered by Adam Sitnik. He talked about his story on contributing to open source. For instance, he told that merging Pull Request can took very long and you should prepare for tough questions from reviewers. He said that he never was below 5 fixes per PR or something like that. I experienced the same, so the next part of the story about what good happened to him was promising for me. The major benefits of contributing are learning the internal stuff (some advantage on debugging), collaborating with your programming idols/mentors. As a disadvantage he told that sitting overnight can damage health. Moreover it costs personal time, which is exceptionally valuable. His advice on what project to choose for contribution was the software you use everyday.

There was also great inspiring presentation from Sławek Sobótka, who I met at the after party and we talked about video games industry and Paleo diet, but I think it’s a material for another post 😉 As a last word, the conference was at very good level and I’m looking forward for the next year.





Slow Intellij 17.1 – Xmx for help

Yesterday I switched to 2017 version of Intellij from the good old 16.3. I didn’t read about all new features yet, but the first thing that hits me was new look of “Find in Path” window. It’s now completely redesigned and I couldn’t get used to it for the first couple hours. Now I don’t need to click to another tab to change search filters – it’s all in the results view already! Thanks JetBrains!

After running Intellij for the longer period of time without restarting, I noticed some lags. The Java editor was freezing for a second or two and it was really annoying! I couldn’t work 🙁 After looking for some “magic” tweaks in the internet, I found that maybe I should just double the Xmx setting. Original value was 750MB, so I have changed it to 1500MB. I enabled “Memory indicator” and after running some unit tests it exceeded the original value. Hope it helps in a long run!

Boiling frogs 2017 inspirations: teach (1)

It is longer than three weeks since I was attending that software craftsmanship conference in Wrocław. The seven-hour train journey was exhausting, but worth that amazing experience of meeting a lot of great people and learning something new about my job. Here I just want to share some thoughts with hope, that someone gets inspired.

Moore’s law of our times – Tomasz Kaczmarzyk (opening speak)

    • “The software craftsmanship manifest” was reminded. I think that every programmer aspiring to be a professional should recall it more often than on the conference. I would say at least once a month! The thing is to keep the focusing on “raising the bar”.
    • The next fun thing was a prediction of Uncle Bob, that “every 5 years the number of programmers doubles”. And here is my tweet about it:

    • There was nice explanation what “10x programmer” really means in the context of software craftsmanship: maybe 1 senior programmer cannot be as much productive as 10 junior programmers, but he can improve them by teaching and helping. So senior guys step up and don’t hesitate to be mentors! I believe that teaching is a natural way to become an expert.


[IntelliJ] Auto-filling Java call arguments like Eclipse did

After changing my IDE from Eclipse to IntelliJ, I suffered from lack of really helpful functionality of auto-completing method call arguments (topic on Stackoverflow).

The standard auto-completition wasn’t enough and “Ctrl+P” shortcut doesn’t satisfy me either.

Hopefully I found this issue: IDEABKL-5496 – Auto-filling the actual Java call arguments, where the last comment written just couple days ago has a great news for me!

Making long story short: some German developer made pretty cool plugin, that fix this problem!


Usage is very simple – you don’t need to know new shortcut, just press “Alt+Enter” and select “Fill …” from suggestions menu. It rocks!

[Guava] Preconditions

Preconditions should be ideal for situations, where there is no specific business exceptions for checking arguments and performance is not an issue.




    * Returns the positive square root of the given value.
    * @throws IllegalArgumentException if the value is negative
   public static double sqrt(double value) {
     Preconditions.checkArgument(value >= 0.0, "negative value: %s", value);
     // calculate the square root


Here is more about checking conditions:


Using Spock for testing code – getting started with syntax (1)

Getting started guide:

Interesting things:

  • cool way to verify throwing exceptions:
    EmptyStackException e = thrown() e.cause == null
  • instead of writing, “when-then”, just use “except”:
    Math.max(1, 2) == 2
  • to parameterize test with different data, use “where” syntax:
    def "computing the maximum of two numbers"() {
    Math.max(a, b) == c
    a << [5, 3]
    b << [1, 9]
    c << [5, 9]
  • in helper method use “assert” keyword:
    assert pc.vendor == "Sunny"

Spring security handle AJAX XHR request for logout users and response 401 instead of 302

I found this article with filter implementation:

Spring Security part VI : Session Timeout handling for Ajax calls

However in comment someone point that we can simply extend “LoginUrlAuthenticationEntryPoint”.

My solution sets only status 401 and doesn’t write anything to response body:

	static class AjaxAwareLoginUrlAuthenticationEntryPoint
			extends LoginUrlAuthenticationEntryPoint {

		public AjaxAwareLoginUrlAuthenticationEntryPoint(String loginFormUrl) {

		public void commence(HttpServletRequest request, HttpServletResponse response,
				AuthenticationException authException) throws IOException, ServletException {

			if (isAjaxRequest(request) && authException != null) {
			super.commence(request, response, authException);

		private static boolean isAjaxRequest(HttpServletRequest request) {
			return "XMLHttpRequest".equalsIgnoreCase(request.getHeader("X-Requested-With"));