How to quickly add sorting, filtering and pagination (with Codeigniter) in a PHP application

happy macaque

A happy macaque that discovered Datatables.net and stopped worrying about filtering and pagination


I have recently came to a quite complex problem that needed to be solved pretty quickly: sorting and filtering on multiple columns and pagination that was synchronized with sorting and filtering. This was desired to be done with AJAX and I needed some tweak not to fire an event on each keyup, and wait until the user stopped typing so I can backend the post.

Since my ajax post requests were unexpectedly slow and I was quite frustrated about that, I started to look for a way to do this without to much hassle. After years of research… (joking of course :) ), I came across a great way to do this, that is also fitted for server-side processing, using input or select elements for multiple filtering and in a word, customizing it however you need it to be: DataTables.net jquery filtering sorting and pagination. Not to mention this also uses cache, is very fast, it doesn’t require to much knowledge and is very well documented.

I was more excited about this than even getting a new dress, so I even told my husband about the wonderful solution have came across with. He (as usually) was skeptical:
• Does it know how to use other html form elements then input like checkboxes or selects? Yes.
• Can you also use it with ASP.NET? Most likely, didn’t try it but since this is all about javascript it shouldn’t be a problem.
• So how does it work? Just take your whole data that yo want to grid (no settings for pagination or anything), set a few lines in a js file and voila, this was so easy that even a macaque could do it!

Share Button

I’m a developer, I have no life category…

I'm a developer I have no life...

I’m a developer I have no life…


This is a funny story. (At least I think it is)
I was listening today to Jim Morrison and below the youtube video there was a comment that kept my attention regarding the fact friends don’t know who Jim Morrison is:

I’m quoting:
“99% of your friends suck.”

My response? I am laughing right now. How stupid my comment was, how analytic and lacking any kind of emotional judgement:
“That means you have at least 100 friends to come to such conclusion :)

Haha! I’m a developer.. I have no life

Share Button

Get up.. or not get up. That is the question!

I can get up at 7AM every day!.. But I choose not to :)

I can get up at 7AM every day!.. But I choose not to :)

Share Button

Time management. How to manage time effectively and to focus on your work

time management

How to effectively manage your time


Yesterday I was at a “Time management course” that was intended to teach me something about how to effectively manage my time. However, when I got there, I was kind of surprised how little did the speaker new about how to manage your time properly. She said she was a HR specialist for 7 years or so, but really, this was not something that was helpful in convincing me she had a proper time management solution.

No offense, but people who have a nine to five job should not be taking this huge responsability and preach about time, unless they are super-druper knowledgeable in this matter on their skin, Or they are freelancers in their own time or run a business that keep them very busy. This was not the case. For instance, she had a crazy idea about how to manage your tasks for a day. Let’s call this lady Miss Closing-Time. Below are her advices, and my advices.
..And for the record I have : 6 years as a freelancer, 2 years as a 9-5 jober. I’m pretty sure I know my stuff.

MCT: “Start with your ugliest task. After you eat the “frog”, everything will seam much easier.”

Totally wrong. I wonder how many people out there took this advice and started eating frogs just before doing their tasks. If you start with your ugliest task, the procrastination will invariably appear at start.. And so the day will go, doing absolutely nothing. When you will start with “the ugly one”, chances are you will not finish it. You will become frustrated and things will go on like this throughout the day.

My advice: “Start with a medium-sized task. Not the toughest, not the easiest. The easy ones will not give you enough boost, but if you close the deal with a medium one, then you can go whatever you feel: one more easy one or start the dinosaur task. THEN you’ll have the mood to finish it”

But because I want to focus on some tips for time management, I will not overflow on this page with my bad experience at this “time management class”, and instead give a few more advices that I would totally wanted to hear in that session:

Failing to plan is planning to fail
Do your homework, and even if you are very busy, find some time to do your “to do” list or planning. The problem is that nobody can do this instead of you so you will have to give full attention to this detail before starting to work. It is very important to estimate things before, so you can measure the difference betweeen estimation and reality after. The more often you make this the more professional you’ll get in doing your estimations. For the matter, I always put 25-30% extra time when I estimate and give this time to the client. This way I am assuring myself that even if “problems” occur I will not be late. And believe me, problems will appear.

Time punching or Pomodoro
I found time punching to be an incredible tool. This technique is about changing your attitude in front of working. It’s also called “pomodoro” and I’m sure you’ll find it under many names. What you have to do is simple: put a deadline for your project or whatever you need to do. It sounds like the “estimation thing” but it’s not. You don’t have to finish the task, you just have to do your best in that specific amount of time that you set. For example take the next hour and do your best and after that hour is gone, stop. Treat yourself. Don’t work anymore, this is the rule. take a 10 minutes break and start again. You will see that you’ll be more focused, because you know that there will be a reward for you after that time is gone. All you have to do is do your best in that amount of time.

The cooling brain technique
This is the name I invented, so you won’t find this anywhere else :) However, many of you might practice it without even knowing it. I call it like that because it really has to do with resting your brain. If something doesn’t work and you keep trying and trying your brain enters in a cycle state and even the obvious solutions will not “come” to you unless you rest your brain. You know, just like when your computer is blocked and you have to push the restart button. Take a 5-10 minutes brake whenever things don’t get along, go in a quite place and drink hot liquids. Hot liquids have an important role in your body as they help blood irigate your brain more effectively. This is not happening with cold drinks.

This technique is most effective when resting is total. During the night, all our thoughts are recycled and ordered in our brain. Our body does amazing stuff while we sleep. If you think about 5-10 minutes on your “problem”, just before getting asleep, you might find a solution in the morning that you didn’t just “see” a day ago. And that’s because the brain reset works like a charm.

Do your todo list a day before
Not because it will be easier next day, but because having a night between the list and starting to work on that list, helps brain organize things better.

Share Button

My jquery 3 state radio button select

As I needed something between radio  inputs (which deselects the other element when an element is clicked) and checkbox (which can be deselected if none of the options are needed), I came with the idea of the 3 state radio button.

First, I almost went to the land of crazy because of using both “change” and “click” events. Do not make this mistake. As it will work ok with Firefox, the other browsers will not be satisfied with your choice. And here is why:

Unlike click, the change event for checkboxes and radio buttons doesn’t fire immediately. For this purpose, you should ALWAYS use either change or click, but not both.

Here is the code sample and the demo of how it should work.

CAT
DOG
Share Button