Posts

Showing posts from 2013

Basic CRUD operations using php, mongodb and knockoutjs with validation

Image
1) I used knockout simplegrid for table data with DELETE, EDIT action and pagination support 2) THE CRUD operations are using XHR/AJAX 3) I used Twitter Booststarp Framework. You can Download/Fork from the github.com  basics_of_php_mongodb_knockoutjs Before trying this we need to install PHP, Apache webserver/Any HTTP server and MongoDB second download mongodb.dll file (php mongodb driver) and keep this file extension if you are using windows OS. These are JavaScript files required <!-- Just for debugging purposes. Don't actually copy this line! --> <!--[if lt IE 9]><script src="js/ie8-responsive-file-warning.js"></script><![endif]--> <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]>  <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>  <script src="https://oss.maxcdn.com/li

Htaccess File Tutorial and Tips

Image
Htaccess File Tutorial and Tips. [THIS DOCUMENT COPIED FROM  http://www.9lessons.info/2013/11/htaccess-file-tutorial-and-tips.html  ] Using  .htaccess  file  we can easily configure and redirect Apache Web Server file system. This post will explain you how to create friendly URLs, sub domain directory re-directions and many more. Note:   .htaccess  file will be in hidden format, please change your folder and file settings to view this file.  How to Create a .htaccess File? Open any text editor application and file save as with  .htaccess  name and enable mod_rewrite  extension in  php.ini  file in Apache Web Server configurations.  Default directory Listing Disable directory Listing If you want to disable folder files listing, include following code.  # Disable Directory Browsing Options  All  -Indexes Error Pages Here error page is redirecting to  error.html .  errorDocument  400  http://www.youwebsite.com/error.html errorDocument  401  http://www.youwebsi

Create localhost webserver simple http server

Using PYTHON $ python -m SimpleHTTPServer 8000 This will start a webserver listening on port 8000 and serving files from the current directory. Using PYTHON 3 python -m http.server Using PHP $ php -S localhost:8000 Using Ruby with Rack $ rackup -b "run Rack::Directory.new('.')"

Determine which service using port 80 in Windows

1) How to determine what software is using port 80 in WINDOWS netstat -aon | findstr 0.0:80 It will list all services which is using port 80 with PID (Process ID), The last one PID TCP    0.0.0.0:445             0.0.0.0:0              LISTENING       4 TCP    0.0.0.0:49152          0.0.0.0:0              LISTENING       524 TCP    0.0.0.0:49153          0.0.0.0:0              LISTENING       1012 2)  Port 80 is being used by SYSTEM (PID 4), How to stop IIS Services Open command prompt and type these command Taskkill /PID 4 /F If this will result like this  ERROR: The process with PID 4 could not be terminated. Reason: Access is denied. Then Type this command iisreset /stop now run this command   netstat -aon | findstr 0.0:80

How to Run Various Linux Commands On Windows Using GIT Bash

Image
First way is :--> Install GIT  latest stable version. After install open GIT-->Bash and now you can execute Linux commands. If you want check which commands can execute just go to this PATH  C:\Program Files\Git\bin and check the file names. And one more thing you can use GIT as Version Controller like SVN Second way is :-->   How to run various Linux Commands on Windows using GOW (GNU on Windows)

Simple Jquery iframe popup like fancybox

A simple jquery iframe popup like fancybox, set a rel attribute for anchor tag to load iframae as popup otherwise do not add rel attribute so it can redirect to source page. CODE: source DEMO <!--[if lt IE 9]> <![endif] Facebook Mahesh Bokkisam Google -->

Run javascript/jQuery function when user finishes typing instead of on key up.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script> <script>!window.jQuery && document.write(unescape('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script>              <script> jQuery(window).load(function() { //setup before functions var typingTimer;                //timer identifier var doneTypingInterval = 500;  //time in ms //on keyup, start the countdown jQuery('.UI-SEARCH').keyup(function(){    clearTimeout(typingTimer);    if (jQuery('.UI-SEARCH').val) {   typingTimer = setTimeout(doneTyping, doneTypingInterval);    } }); //user is "finished typing," do something function doneTyping () {    alert('hi'); } }); </script> <body> <input type="text" maxlength="128" value="" name="q" au

How to Create Multiple Virtual Hosts in Ubuntu with LAMP/Apache

I also assume that you have the Apache mod_rewrite module enabled.  You can enable this by typing the following command in the terminal sudo a2enmod rewrite Create Multiple Directories. mkdir /var/www/mylocalsite1 mkdir /var/www/mylocalsite2 mkdir /var/www/mylocalsite3 Add your sites to the hosts file: sudo nano /etc/hosts OR sudo vim /etc/hosts It will look like this 127.0.0.1 localhost 127.0.1.1 mahesh-thinkpad # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters Now add your virtual host names after  127.0.1.1 mahesh-thinkpad Like 127.0.01 www.mylocalsite1.com 127.0.01 www.mylocalsite2.com 127.0.01 www.mylocalsite3.com Configure Apache Open new file sudo vim /etc/apache2/sites-available/mylocalsites and add like this <VirtualHost *:80> ServerAdmin webmaster@localhost

Find Nth Highest value in array without sorting in PHP

Find  Nth/ N th highest value from given array without using any sorting in PHP $ar = array (23,56,87,12,98,85,24,54,99,100,1,4,5,2,76,37,92); $n =       count ($ar);  //5; for ($i = 0; $i < $n; $i++){ echo $a = max ($ar);                          // Get the max value from array // get the Nth value from last loop //echo " "; print_r($ar); $ar = array_flip ($ar);                        // Flip the array //print_r($ar);  unset ($ar[$a]);                                 // Unset the max value from array //print_r($ar); $ar = array_flip ($ar);                        // Flip the array echo " "; echo " "; }

Get repeated rows in based on child table from Parent table

SELECT   *   FROM   `parents`   WHERE   id IN   ( SELECT   parent_id FROM   `tbl_parent_child`   GROUP   BY   parent_id HAVING   COUNT (   parent_id   )   = 2 )

Mysql InnoDB optimization

query_cache_size = 512M query_cache_limit = 256M tmp_table_size = 256M key_buffer_size = 64M read_buffer_size = 128M read_rnd_buffer_size = 128M bulk_insert_buffer_size = 64M myisam_sort_buffer_size = 128M myisam_max_sort_file_size = 128M myisam_max_extra_sort_file_size = 128M myisam_repair_threads = 2 myisam_recover innodb_additional_mem_pool_size = 256M innodb_log_buffer_size = 128M innodb_log_file_size = 128M innodb_log_files_in_group = 2 innodb_flush_log_at_trx_commit = 0 innodb_buffer_pool_size = 512M innodb_data_home_dir = /var/lib/mysql/ innodb_data_file_path = ibdata1:256M:autoextend innodb_autoextend_increment=32 max_allowed_packet = 16M wait_timeout = 1800 connect_timeout = 120 Notice the above is adjusted for a DB dedicated server with 2GB of RAM.

Magento Interview Questions and Answers

Magento Interview Q & A

What Is The Universe?

Image

Sanitize Phone no, if phone no length is more than 10 then, Remove 0, +91, 91 from phone no

Sanitize Phone no, if phone no length is more than 10 then, Remove 0, +91, 91 from phone no. All Indian phone no's length is 10 digits including with STD code /**  *  Sanitize Phone no, if phone no length is more than 10 then  */ function sanitizePhoneNo(phone){ if(phone.length >= 10) { if(phone[0] == 0) { phone = makePNo(phone, 1); }else if( (phone[0] == 9) && (phone[1] == 1) ){ phone = makePNo(phone, 2); }else if( (phone[0] == '+') && (phone[1] == 9) && (phone[2] == 1) ){ phone = makePNo(phone, 3); } } return phone; } function makePNo(val, cnt){ var a=''; for(var i=0; i<=(val.length)-1; i++){ if(i>=cnt){ a += val[i];} } return a; } /**  *  Validate Phone no with regular expression  */ function validatePhoneNo(phone){ if( /^[0-9\ \-]+$/.test(phone)){ if(phone.length==10){return true;}else {return false;} }else {return false;} }

Lok Satta Videos: Lok Satta Leader Hyma With Kommineni Srinivas Rao ...

Lok Satta Videos: Lok Satta Leader Hyma With Kommineni Srinivas Rao ...