Sunday, September 30, 2012

MODx Revolution IncludePage

The original includepage inspired by Daniel
This version is currently supported in MODx 2.2.4-pl


Saturday, September 29, 2012

mongodb distinct and sort

Its alike javascript.
To sort the result, simply issue sort in the end

Monday, September 24, 2012

jquery form and tinymce

Jquery form doesnt work properly with tinymce,
one way work around is to trigger tinymce input saving before submitting the form

    beforeSerialize: function($form, options) {

Sunday, September 23, 2012

tinymce mceRemoveControl NS_ERROR_UNEXPECTED: Component returned failure code

Im not sure if its considered a bug, but this is annoying for me.
When i ran mceRemoveControl command to remove a already destroyed tinymce on a textarea,

After googling around with not much result, ive decided to dig into the source code ,
and finally found a solution.
Instead of calling directly mceRemoveControl, call this tinyMCE.remove(tinyMCE.getInstanceById()):

var oInstance = tinyMCE.getInstanceById("txtContent");
if (oInstance) {
  if (oInstance.isHidden()) tinyMCE.remove(oInstance);
  tinyMCE.execCommand('mceRemoveControl', true, "txtContent");
tinyMCE.execCommand('mceAddControl', true, "txtContent");



Wednesday, September 19, 2012

su root with sudo

There are times when we need to use su to do some root required tasks which are too tedious to use if we are required to type sudo for every command.
Here is how:
sudo su

Tuesday, September 18, 2012 and should be banned from spam filtering!

These two black list provider seems to ask for money to get de-listed from from their server.
Their so called "fine" doesn't seems to be appropriate when there are so many clients machine which may have faced infection from virus or malware.
The real fine should be done to the actual virus creator or malware!

Monday, September 17, 2012

csf and kloxo

Running server without some kind of protection, open up to bruteforce and dos attack.
Even with ssh port set to different port, or PermitRootLogin no, isnt good enough.

People can still guess a domain username based on the control panel being used,
especially plesk and cpanel.
Once they fire up their brute force attack, they can use it to attempt to get your clients password.

So its best to install some kind of detection and auto blocking system to prevent this from happening.
CSF is one of the best tool to use.

Once installed, here are some useful tips you might want to consider:

enable UI, but remember to set the username and password in the ui section below the ui enable line.
Email alert to yourself, incase if someone is attacking your server.

And on top of that, for kloxo purpose, you may want to ignore this list of processes, by adding these lines:


into /etc/csf/csf.pignore

Option options may be useful is set TESTING to 0.

add in port 7777 to

After thats done,
run this:
/etc/init.d/csf start
/etc/init.d/lfd start

For directadmin wise:
add these lines into /etc/csf/csf.pignore


to whitelist:
add ip into:

Other optional setting:

To set connection limit per ports:
CONNLIMIT = "22;5,80;10,110;5,25;5,587;5,21;5"
example above:
port 22: max 5 per ip,...

For more information:

Friday, September 14, 2012

eclipse wont run on mac os x 1.8.1

Took me sometime to investigate on this,
and finally i found the problem.

It seems to be unarchive bug on mac os tool,
which causes some files to not extract out.

the solution:
tar -xf eclipse....tar.gz

found the bug here:

sigh.. thats a real bug from apple

Monday, September 10, 2012

jquery fullcalendar reload events data


This might be useful to others:

      header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,agendaWeek'
      dayClick: function(date, allDay, jsEvent, view) {
        var sRawDate = date.getFullYear() + "-" + (date.getMonth()+1) + "-" + date.getDate();
        var sDate = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear();
        var sDay = date.getDay();
        sDay = sDay == 0 ? 7: sDay;
        if (allDay) {
          //jQuery("#frmClassAdd input[name=txtStartDate]").val(date);
          var sTime = date.getHours() + ":" + date.getMinutes();
        // change the day's background color just for fun
        //$(this).css('background-color', 'red');
        //todo trigger add data
      editable: true,
      firstDay: 1, //states monday as 1st day of week
      events: [
      eventSources: [
          url: "url_to_data.php", //
          data: {
            groupid: 5, //some param to pass in on top of start
      eventClick: function(calEvent, jsEvent, view) {
        //todo show an event