Recently, while working on one of the projects at Onevest. I needed a dropdown list of years between 2015 and 1980. Instead of tryping each year out, I decided to create a tiny angular filter that iterates between two numbers.
If you want to convert HEX decimal color to RGB here is a little handy function.
While I was working on the jQuery prettySocial. One of the biggest hurdles I encountered was dynamically binding touch events to the DOM element. The problem was not actually the binding, but the fact that event was being called when user scrolling the page with their finger. There is an in depth article about this by Brian G.
Here is a useful PHP function that truncates a block of text without breaking a word. This is useful when creating an excerpt text and making sure that words are not cut off.
Recently, I had to build a Wordpress Admin widget area which enables a user to select, change order and save a list of posts. Selected post IDs are stored in an
array() which can be found in the options table. It looks something like this:
So when it comes to rending the posts in the array, I just create a new
WP_Query(), like so:
Wordpress automatically queries posts in a reverse chronological order (newest post first), or if set - by
orderby value. However, what if I need to keep the queried posts in specific order listed in my
$post_list array? This sort of condtion cannot be passed into
WP_Query() as an argument, but it can be done after query is completed. After some messing around by creating loops and filtering the object, the best solution was to use the usort() PHP function.
And that’s it.
Here is a little snippet If you’re trying to check wether element contains a class, without using jQuery.
This accounts for the fact that element might contain multiple class names separated by space.
You can also assign this function to element prototype.
And trigger it like this (very similar to jQuery’s