Bo Andersen
I am a back-end web developer with a passion for open source technologies. I have been a PHP developer for many years, and also have experience with Java and Spring Framework. I currently work full time as a lead developer. Apart from that, I also spend time on making online courses, so be sure to check those out!
Posts by Bo Andersen
Selecting Elements by Data Attribute in jQuery
Selecting elements by data attributes is very easy in jQuery. As with all other attributes, we can simply use the attribute selector. In fact, we do not need to handle the data attribute in any special way, as long as the data attribute is available in the DOM. Please consider the following example. var matches… read more
Selecting Element by Name in jQuery
Selecting elements based on their name attribute in jQuery is as easy as it should be. We can accomplish this by simply using the attribute selector as follows. For example, to select an input with the name username, use the following selector. var matches = $(‘input[name=”username”]’); Woah, that was easy, wasn’t it?
Generating a UUID in Java
Generating a UUID in Java is extremely easy. In fact, it can be done with a single line of code! To generate a type 4 UUID in Java, simply run the following line of code. String uuid = UUID.randomUUID().toString(); // Example: e03913fb-5951-4964-a88b-47371641fd17 Because you will likely generate UUIDs in many different contexts, here is a… read more
Validate Single Field with Hibernate Validator
Please note that the following code examples exclusively use Java’s validation API, so these examples are in no way limited to Hibernate Validator. Hibernate Validator is merely used as the implementation of the used interfaces, but other implementations can be used as well. Validating a single field with Hibernate Validator is easy. Suppose that you have… read more
Creating a Custom ZF2 Controller Plugin
Creating a custom controller plugin in Zend Framework 2 is easy! First, begin by creating a new class. I will put this in the Application\Controller\Plugin namespace. namespace Application\Controller\Plugin; use Zend\Mvc\Controller\Plugin\AbstractPlugin; class HelloWorld extends AbstractPlugin { public function __invoke() { return $this->hello(); } public function hello() { return ‘Hello World!’; } } As you can see,… read more
Enabling PHP Error Reporting in MAMP
While developing PHP applications with MAMP on OS X, it is very useful to be able to see errors being printed directly in the browser. By default, this is disabled with MAMP, but it is very easy to enable error reporting in MAMP. All you have to do is to follow the simple steps below.… read more
Getting Query Parameter from URL in JavaScript
To most people’s surprise, there is not a standard way of accessing query string parameters from JavaScript without first having to parse the query string. Some frameworks and libraries have implemented ways of doing this, but it is not always the case. For example, the ever so popular jQuery has not implemented this, but rather… read more
Multi-column Lists with CSS3
Before CSS3, it was quite a struggle to have an ordered or unordered list span multiple columns. In fact, people often resorted to either rendering the lists in columns from the server (if possible) or using CSS hacks. Luckily this is no longer necessary in CSS3, because you can easily accomplish this with a new… read more
Generate CRC32 Checksum in Java
Generating a CRC32 checksum in Java is – as you would expect – extremely simple. All it takes is a few lines of code. Below is an example on how to generate a CRC32 checksum from a string. public final class AppUtils { private AppUtils() { } public static long crc32(String input) { byte[] bytes… read more
Change Bootstrap Popover Position
If you have ever worked with Bootstrap’s popovers (popover.js), you may have had a hard time adjusting the position of a popover. As it turns out, it is a bit tricky to do so. The following example assumes that you want to adjust the position of a particular popover and therefore assigns a class to… read more