Selecting Elements by Data Attribute in jQuery

October 13, 2015 by

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

October 13, 2015 by

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

October 13, 2015 by

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

Creating a Custom ZF2 Controller Plugin

October 12, 2015 by

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

October 12, 2015 by

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

September 28, 2015 by

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

September 26, 2015 by

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

September 26, 2015 by

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