Sunday, February 26, 2012

jQuery Datatables plugin and Codeigniter


Just got an work around for the jQuery datatables wrapper [IgnitedDatatables] and made it working on a project to load huge data. As I din get any neat info I had to dig little deep both into datatables plugin and the wrapper and finally made a work around for me. Here in this post I am basically sharing my experience along with keeping records of what and how I did :)
The js I am using on the view to create the datatable and load using ajax is as follow [don try to run on jsFiddle 'cz it has lots of garbage- will clean it up :| ] :


Code on the controller:


And finally the model:


I will write in details on it - how I actually worked on later on this post.
Tips:
  1. For the callback function for the wrapper to work you need to create a helper file where you need to put all the callback functions.
  2. As the wrapper somewhat works as the model should work I have called and made use of it in my model class.
Reference:
  1. jQuery Datatables plugin api
  2. Server side data processing using Datatables plugin
  3. IgnitedDatatables function reference; and Method Chaining example
  4. Example usage code for the IgnitedDatatables library [independent of Codeigniter]
  5. Sample MySql Database [Sakila :)]

Sunday, February 12, 2012

Dynamically add a group of fields using jQuery

Its not a so tough thing, tough. Just wanted to keep a record and add a tip :) Following is the code I am using:

Note:
I was facing a problem, when the groups of fields grows  more then the view area for each click to create the window jumps to the top of the page; To resolve, to remain where I was creating the new fields I just added one line return false as the last line of the click even.
Instead of remaining the same place if you want to scroll to some where else you can use the following jQuery plugin:
scrollTo

Wednesday, February 8, 2012

Manipulating Auto Increment values in MySql



  1. Set the MySql variables auto_increment_increment and auto_increment_offset variables.
  2. Play with the Auto_Increment in Information schema.
To start with an AUTO_INCREMENT value other than 1, you can set that value with CREATE TABLE or ALTER TABLE, like this:
ALTER TABLE tbl AUTO_INCREMENT = 100;
Note:It is not possible to confine the effects of these two variables to a single table, and thus they do not take the place of the sequences offered by some other database management systems; these variables control the behavior of all AUTO_INCREMENT columns in all tables on the MySQL server. If the global value of either variable is set, its effects persist until the global value is changed or overridden by setting the session value, or until mysqld is restarted. If the local value is set, the new value affects AUTO_INCREMENT columns for all tables into which new rows are inserted by the current user for the duration of the session, unless the values are changed during that session.


Wednesday, December 21, 2011

Unload/Uninstall Trend Micro Office Scan client 10.5


Trend Micro.svg


I wonder why to block the everything instead of trying to grow the culture for trust and reliability and ownership ? I wonder why this freaking Trend Micro's Office Scan to narrow down the accesses ?! I was ok with it untill when they locked access to my external devices which is really essential for me to back all my things up. After couple of google here is the solution I got to Unload(disable) or Uninstall Trend Micro Client where a prompt comes up for a password.

  • Go to the ..\Trend Micro\OfficeScan Client directory. Usually, it would be: 

C:\Program files\Trend Micro\Officescan Client\

  • Locate and open the Ofcscan.ini[this is the file where all the configuration setting for the OfficeScan client is stored ] file using any text editor. You may use notepad to edit. 
  • Find [INI_CLIENT_SECTION] section. 
  • Change the value of the Uninstall_Pwd to 

!CRYPT!523F7DC2E525044E2800FCDEA7E5D78B70C0A4165387060525E3EE66D5D2D2F460EA361E712B5F871FD473C7A6C
  • Change the value of the Unload_Pwd to 
!CRYPT!523F7DC2E525044E2800FCDEA7E5D78B70C0A4165387060525E3EE66D5D2D2F460EA361E712B5F871FD473C7A6C
  • Save and close the file.
  • Right click on the Officescan client on your system tray then click on Unload Officescan
  • Once it prompts you for the password type trendmicro as the password.
You should be able to see your officescan client on the system disappear. Now you are free from all the blocking imposed by this tool. I can access my external devices... o la la :D


Note: 
  • If you can't save the Ofscan.ini file [windows 7] open the editor as administrator - right mouse on the editor program and click run as administrator.
  • If Client_Allow_Uninstall / Client_Allow_Unload set to 0 make it 1.
  • If UnloadProtect is set to 1 make it 0.



Wednesday, December 7, 2011

My Instant Continuous Integration environment for development


A simplest dev environment for continuous integration for a dev team [considering a php project with mysql db] :
1. Install Visual SVN server - its for windows and easy to install and manage SVN server.
2. Create a post commit hook for the repo; to do that - In the VisualSVN Server GUI Tool:
-Select your repository
-Right click Properties Select the Hooks tab
-Select the Post-commit hook
-Click the Edit button.
-Enter a line like this into the textbox:
c:\program files\visualsvn server\bin\svn.exe" export https://svn.yourserver.com:4433/svn/YourRepository/Websites/YourWebsite/ C:\inetpub\wwwroot\YourWebsite --quiet --non-interactive --force --username youruser --password yourpassword
-Click Ok.
3. Now for the DB Sync follow the steps in the following article : [However, you might need some modification to meet your need]
http://www.decodephp.com/2008/09/29/svn-and-mysql-schema-synchronization/

Surely, You can add more flavor to this environment, like you can add a script to run each day so that it grabs all the commit logs and emails to the test team and/or stack holders or may to the entire team - so that everybody remains better informed.

Hope this will help us a to remain synced in an Agile team.
Those who is not aware of the term Continuous Integration, you can check this wikipedia link

Sunday, November 13, 2011

Installing php driver for MongoDB

PHP      &   mongoDB


This is the post where I will configure php to work with mongoDB. On my previous post I have put the teps I followed to install mongoDB on my Ubuntu [TurnKey Linux] running on VirtualBox.
1.Run:
sudo pecl install mongo
2.Open your php.ini file and add to it:
extension=mongo.so
It is recommended to add this to the section with the other "extensions", but it will work from anywhere within the php.ini file.
3.Restart your web server (Apache, nginx, etc.) for the change to take effect.
Note:
pecl requires that pear be installed. For those using apt-get, you may need to run the following:
sudo apt-get install php5-dev php5-cli php-pear
However, you can download the source for the driver and can compile it manually :
shell> tar -xzvf mongo-1.2.6.tar.gz
shell> cd mongo-1.2.6
shell> phpize
shell> ./configure
shell> make
shell> make install
Check with the phpinfo

Starting MongoDB and php on Ubuntu

Installing MongoDB on Ubuntu:
1. Add 10gen package to source.list 
The 10gen package contains the latest mongoDB version, append below line to the end of the file “/etc/apt/sources.list”
deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen
For example, you can vim the “source.list” and append the 10gen package like this :
$ sudo vim /etc/apt/sources.list
File : /etc/apt/sources.list
#...content omitted ...
## This software is not part of Ubuntu, but is offered by third-party
## developers who want to ship their latest software.
deb http://extras.ubuntu.com/ubuntu natty main
deb-src http://extras.ubuntu.com/ubuntu natty main
 #mongo repo ##########
deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen

 2. Update package
Update the modified “/etc/apt/sources.list” :
sudo apt-get update
Now, a new “mongodb-10gen – An object/document-oriented database” is available for install.
  3. Add GPG Key
10gen package required GPG key, import it :
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
   4. Install mongodb-10gen
Everything is ready, now you can Install the mongoDB package :
sudo apt-get install mongodb-10gen
    5. Post-InstallationVerification
Now, mongoDB is installed, started, and auto start mongoDB script is generated to “/etc/init/mongo” and “/etc/init.d/mongo“. In addition, all mongoDB files are copied to “/usr/bin” folder.

The main configuration file “mongodb.conf” is located at “/etc/mongodb.conf“, change the values to customize your mongoDB server.

File : mongodb.conf
# mongodb.conf
# Where to store the data.
# Note: if you run mongodb as a non-root user (recommended) you may
# need to create and set permissions for this directory manually,
# e.g., if the parent directory isn't mutable by the mongodb user.
dbpath=/var/lib/mongodb
#where to log
logpath=/var/log/mongodb/mongodb.log logappend=true
#port = 27017
#......
   6. Verification
To verify it, just connect it with “mongo”
$ mongo
MongoDB shell version: 1.8.1 connecting to: test
>
on my next post I will try to connect php with this mongoDB.

Friday, November 4, 2011

Parsing Email with PHP

I was working for a Email Advertisement tool,recently. And the first thing I was put to work with is to develop a parser that parses and incoming email and decides whether it is a bounced back email. After couple of googling I got some fare enough solution that I wanted to use for the solution. The steps I followed for the solution are adopted from the following :
HOWTO: Email Bounce handling with PHP, Exim & CPanel, Catch bounces from non-deliverable emails

And the very basic parser I wrote can be downloaded from the following location:
Download the email parser for bounce management
[Bascially It's a codeIgniter controller, but you can use it as you wanna use it]

However, I had to go some more details parsing, later to decide the type of bounce or the reason for the bounce.First I tried parsing the log file for the exim [exim_mainlog file] and then parsing the entire body of the bounced back emails. I will share two more posts on them in this series.

Monday, October 3, 2011

Hack a Blackberry 9700 Bold to access internet without BlackBerry data service

[I kept this post for long as Draft; thought I shud l publish; ]
Playing with the Blackberry 9700 from Sujoy who was not using it because it cost a lot to enable Blackberry service with the Operators who are offering BB services.
So I picked it up just to see why should such a device left unused just because some kinda service is not available or bcz its expensive. Following are the things what I am currently doing with it :
Setting the Internet connection without the Blackberry data service :
First of all you have to set up your tcp settings. In your BlackBerry menu go to => Options - Advanced Options - TCP and enter your APN information for your GSM Service.You can ask your customer care for the APN information.When you finish the settings you need a browser to surf the net. The best one is Opera Mini Browser. You download the Opera Browser to your BlackBerry and in the Opera Browser menu you go through automatic network setup. Once the Opera Browser finds out your settings you are ready to surf the net from you BlackBerry for free. (Excluding standart connection charges- for the GPRS/Edge from your GSM service provider)
Happy, browsing then without paying the BB service :P.

Saturday, July 2, 2011

Node.js : Simple push from server to browser

Here you go a test that a tasted while playing with Nodejs.I must say that it is a great fun playing with Nodejs.I always love to create real time environment for the web. Here is a little example of it. With this piece of code you'll be able to monitor any changes in a file in real time directly from your browser. Nothing too efficient but still a very good start. 




My flavor : On this video you will see Pedro is using a log file. Instead, I used a simple text file and updated the file manually.

Issue I faced : Din work for me on google chrome but was good on firefox. After investigation here seems a little convincing reason :
http://stackoverflow.com/questions/6068820/node-js-problems-with-response-write

For getting started with  Node.js,  You'll get a complete set of video tutorials at the following location :
http://nodetuts.com/ [the video I have shared here is the second episode from the series]

Happy Techifying the world :)    
Update: just got another example of similar push server ; utilizing socket.io.
http://www.gianlucaguarini.com/blog/?p=272