Get All Files in Directory and All Child Directories

PHP walk recursively with iterator over all directories and filesI was playing with PHP the other day and was trying to fetch and rename 1000s of files I have stored locally on my machine. Seemingly PHP isn’t the best language to that operation Python or even BASH could do the job though it was nice to give it a try. So this is what I came up, simple and straightforward.

Read more ›

Posted in PHP, Small Tips Tagged with: , , , , ,

Change default date for Jackson in Spring Boot application

Java date convert timestamp in iso8601 for json swagger jackson spring bootDates as a concept are seamingly simple and straight forward. Though in programming world those could be rather complex starting from format, representation, time zones, machine default configuration going through different calendars and date manipulations.

In this post I won’t to give a quick tip on handling dates in an application that I am building. It will be short post, I promise.

Read more ›

Posted in API, Java, Small Tips, Spring, Swagger Tagged with: , , , , , ,

Swagger and polymorphic type handling with Jackson

polimorphic types with jackson and swaggerPolymorphic type handling based on JSON property

Building an API that supports inheritance could be quite crucial. Imagine the case where you want to have an endpoint that stores a profile data for a given provider and that provider could be your main website or any 3rd party platform that can provide the data. We might have a base Profile class which in our case would be abstract class with firstName and lastName fields and an abstract method to provide the name of the actual profile provider getProfile().

You can do all of that quite easily with few Jackson annotations, for  polymorphic types, on the base class and on the children that extend the base class. No more words here is an example: Read more ›

Posted in API, Java, Spring, Swagger Tagged with: , , , , , ,

Spring Boot: Executing asynchronous method backed with a queue

Spring Boot - asynchronous execution of controller method with threading backed by a queueMany people go for different solutions and sometimes overcomplicate their applciation with message queues like ActiveMQ, RabbitMQ and other options out there. Though this is yet another part in the application architecture that would require maintenance and support and it’s also a possible failiure point.

There are good reasons to use this approach but in most cases you can get through with normal in-memmory queue with multi-threading. Read more ›

Posted in Java, Spring Tagged with: , , , ,

Best practices in Agile Retrospectives

agile scrum retrospective meeting best practices dos dontsOne of the core Agile practices is to inspect and adapt. We inspect the developed software in the business review or demo meeting to ensure that we are delivering the right product. And we inspect how the team performs and interacts in the retrospective meeting to make sure that we are working in the right way and that we keep improving.

We should work on maximizing the benefits of the retrospective meeting and adapt according to its outputs, or it will turn into a useless ritual.

In this article, I share some tips on things you can do to improve your retrospective meetings, and things you should avoid as well.
Read more ›

Posted in Project Management Tagged with: , , , ,

API Versioning – best practices

API Service versioning best practices URL headersWhat happens if you need to make changes to your API?

If you’re making additions to the API – e.g., adding services or adding fields to your services – you likely don’t need to do anything more to notify users than to tell them about the changes.

But what happens if you need to make a change that will affect users?

  • Adding authentication
  • Adding authorization rules
  • Removing a service
  • Removing or renaming fields inside services

Such changes as these impact your existing users. At times like these, you need to create a new version of your API.

But how do you do that? Read more ›

Posted in API, Small Tips Tagged with: , , ,

Load configurations from custom bundle in Symfony2

Symfony2 configuration file for custom bundleWhen I build apps or add new functionality to Symfony2 I build it into a separate bundle, thus trying to keep the structure modular which is generally a good practice as everyone knows. Keeping all parts of the bundle together makes it easy to maintain and also easy to change the configurations as they reside in same place as the code itself.

In this post I’ll show you how to make Symfony2 core discover your config.yml and services files defined in your custom bundle.

Create new bundle

First let’s create a new bundla that we’ll use as a demo. Run following command in the terminal: Read more ›

Posted in PHP, Small Tips, Symfony2 Tagged with: , , ,

Programatically render template area in Magnolia CMS

magnolia cms javaProblem

I am using Magnolia CMS 5.4 and I want to build a module that will render some content of a page and expose it over REST API. The task is simple but not sure how to approach it and/or where to start.

I want my module to generate partial template or an area of a template for a given reference, let’s say that is “header”. I need to render the header template/area get the HTML and return that as a response to another system.

Solution

First thing the rendering works based on different renderers and those could be JCR, plain text or Freemarker renderer. In Magnolia those are decided and used in RenderingEngine and the implementation: DefaultRenderingEngine. The rendering engine will allow you to render a whole page node which is one step closer to what I am trying to achieve. So let’s see how could this be done:
Read more ›

Posted in CMS, Java, Magnolia Tagged with: , , , ,

Running out of memory on Laravel 4 update

PECL out of memory with Composer and LaravelLaravel is great framework and I quite enjoy how it’s structured and how it works. In version 4 it was migrated from bundles to using Composer for dependency injection which is great and fits well in my daily routine on building apps also follows standards promoted by the PHP community in general.

In my application I was planning to add MongoDB support as first I’d like to improve the performance and second my data structure is perfect for this purpose, furthermore I want to improve my NoSQL skillset.

In this article I’ll describe the steps that I followed on installing the MongoDB provider, the problems that I’ve faced and final solutions and small tricks I used to make all work. Read more ›

Posted in BASH, Laravel, MongoDB, PHP, Unix Tagged with: , , , , ,

Pass parameters to Bash Alias command

pass console command parameters to bash alias command- like hammer bashes a nailI use BASH aliases extensively throughout my DEV environments and it saves me a lot of time. One specific I use is “cdv” that’s shorthand for CD to VirtualHosts which in most cases could be as simple as /var/www or in some cases could be very long path, especially on shared DEV environments like /var/www/dev/vhosts/mylongusername. Read more ›

Posted in BASH, Unix Tagged with: , , , , ,

Categories