Posts

Showing posts from 2018

MySQL event scheduler and how to create MySQL events to automate database tasks

Working with MySQL Scheduled Event  SET GLOBAL event_scheduler = OFF;  SET GLOBAL event_scheduler = ON; MySQL event scheduler and how to create MySQL events to automate database tasks. A MySQL event is a task that runs based on a predefined schedule therefore sometimes it is referred to as a scheduled event. MySQL event is also known as “temporal trigger” because it is triggered by time, not by table update like a trigger. A MySQL event is similar to a cron job in UNIX or a task scheduler in Windows. You can use MySQL events in many cases such as optimizing database tables, cleaning up logs, archiving data, or generate complex reports during off-peak time. MySQL event scheduler configuration MySQL uses a special thread called event schedule thread to execute all scheduled events. You can see the status of event scheduler thread by executing the following command: SHOW PROCESSLIST; By default, the event scheduler thread is not enabled. To enable and start the event scheduler t...

How to send Send Email with attached CSV file in codeigniter

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Home extends CI_Controller {     public function __construct() { parent::__construct(); $this->load->helper('url'); $this->load->library('email'); $this->load->helper('file'); $this->load->database(); } public function index() {     $data['rs'] =  $this->db->get('customer_profile');     $this->load->view('home', $data);    } // Download for CSV file. // http://localhost/codeigniterR/index.php/home/csv public function csv($query, $filename = 'CSV_Report.csv') { $this->load->dbutil(); $this->load->helper('download'); $delimiter = ","; $newline = "\r\n"; $enclosure = '"'; $query = $this->db->query("select customeremail as Radhey from customers"); $data = $this->dbutil->csv_from_result($query, $delimiter, $newline); // client ...

How to get the parameter from url in codeigniter?

$this -> uri -> segment ( n ); where n = 1 for controller, n = 2 for method and n = 3 for parameter and so on. You need n = 3 to get parameter. In your path localhost/log/job/php , your method name is missing. Even if your method name is index then you route will be localhost/log/job/index/php In case if you need to remove index.php from url then you will get parameter using localhost/log/index.php/job/index/php To remove index.php you need to create .htaccess file by following these steps: Create a .htaccess file where index.php file is located with content RewriteEngine on RewriteCond %{ REQUEST_FILENAME } !- f RewriteCond %{ REQUEST_FILENAME } !- d RewriteRule ^(.*) $ index . php / $1 [ L , QSA ] Make sure that apache can access this .htaccess file. To do this edit apache configuration file. If you use ubuntu, then it is /etc/apache2/sites-available/default and then change AllowOverride none to AllowOverride all for directory and www dir...

Connect more than one instance in phpmyadmin

Go to phpmyadmin GUI Go to previleges -> editprevileges -> Change Password type password -> retypepassword After Go to phpmyadmin folder chnage file config.inc.php $cfg['Servers'][$i]['host'] = 'hostip';         $cfg['Servers'][$i]['port'] = '3306';         $cfg['Servers'][$i]['socket'] = '';         $cfg['Servers'][$i]['connect_type'] = 'tcp';         $cfg['Servers'][$i]['extension'] = 'mysqli';         $cfg['Servers'][$i]['compress'] = TRUE;         $cfg['Servers'][$i]['auth_type'] = 'config';         $cfg['Servers'][$i]['user'] = 'admin';         $cfg['Servers'][$i]['password'] = 'password';

GIT create a new repository on the command line

create a new repository on the command line echo "# mynewrepository" >> README.md git init git add README.md git commit -m "first commit" git remote add origin https://github.com/radheymishra/mynewrepository.git git push -u origin master …or push an existing repository from the command line git remote add origin https://github.com/radheymishra/mynewrepository.git git push -u origin master user@user-HP-2000-Notebook-PC:~/Documents/devloper1$ ls user@user-HP-2000-Notebook-PC:~/Documents/devloper1$ git init Initialized empty Git repository in /home/user/Documents/devloper1/.git/ user@user-HP-2000-Notebook-PC:~/Documents/devloper1$ git clone https://github.com/radheymishra/mynewrepository.git Cloning into 'mynewrepository'... warning: You appear to have cloned an empty repository. Checking connectivity... done. user@user-HP-2000-Notebook-PC:~/Documents/devloper1$ git init Reinitialized existing Git repository in /home/user/Documents/devlope...

Getting started Mysql with JSON

Getting started Mysql with JSON Let us create a table playes CREATE TABLE `players` ( `id` INT NOT NULL , `player_and_games` varchar ( 5000 ), PRIMARY KEY ( `id` ) );     Insert JSON data into table    INSERT INTO `players` ( `id` , `player_and_games` ) VALUES ( 1 , '{ "name": "Sally", "games_played":{ "Battlefield": "yes", "Crazy Tennis": "yes", "Puzzler": { ...

Install Wordpress on Ubuntu 16.04

Image
Step 4: Download WordPress Now that our server software is configured, we can download and set up WordPress. For security reasons in particular, it is always recommended to get the latest version of WordPress from their site. Change into a writable directory and then download the compressed release by typing: cd /tmp curl -O https://wordpress.org/latest.tar.gz Extract the compressed file to create the WordPress directory structure: tar xzvf latest.tar.gz We will be moving these files into our document root momentarily. Before we do, we can add a dummy .htaccess file and set its permissions so that this will be available for WordPress to use later. Create the file and set the permissions by typing: touch /tmp/wordpress/.htaccess chmod 660 /tmp/wordpress/.htaccess We'll also copy over the sample configuration file to the filename that WordPress actually reads: cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php We can also creat...

How to Install WordPress 4.9 On Ubuntu 16.04 Using LAMP Stack

Image
First, we shall uncover the various steps for installation of LAMP stack before progressing to install WordPress . Step 1: Install Apache Web Server To install Apache web server, issue the command below: $ sudo apt-get install apache2 apache2-utils We need to enable Apache2 web server to start at system boot time, as well start the service as follows: $ sudo systemctl enable apache2 $ sudo systemctl start apache2 To test whether the server is running, open your web browser and enter http://server_address . The Apache2 default index page will be displayed in case the web server is up and running. Apache Default Page Under Ubuntu 16.04 Note : The Apache default root directory is /var/www/html, all your web files will be stored in this directory. Step 2: Install MySQL Database Server Next, we need to install MySQL database server by running the command below: $ sudo apt-get install mysql-client mysql-server During the package installation, you will be prompted to s...

AngularJS interview questions and answers

Read Angular js interview questions including topic advanced topics like Dependency injection, Two-way binding, Dependency injection, scope in angular js     What is AngularJS? List some benefits of using AngularJS?     List some Pros an Cons of angular js?     What is Angular Module? How to create a Module in Angular js?     What is Angular Controller?     What is $scope?     What is $rootscope? How is it different from the scope?     What is the difference between $scope and scope?     What are Angular Expressions?     List the major browsers Supported by Angular js?     How to enable HTML5 mod in Angular 1.x?     List some of the built-in validators in Angular JS?     What is Angular’s prefixes $ and $$?     What are directives? How to create and use custom Directive in Angular js.  ...

Top Javascript interview questions for Freshers and experienced

 Top Javascript interview questions for Freshers and experienced 1. Explain what is Javascript? List some data types supported by Javascript? Javascript Javascript is an object-oriented computer programming language commonly used to create interactive effects within web browsers.It is first used by the Netscape browser, that provides access to the HTML document object model (DOM), provides access to the browser object model (BOM). Javascript syntax looks a lot like java, c or c++ syntax. Below is the list of data types supported by Javascript:-     Undefined     Null     Boolean     String     Symbol     Number     Object 2. In Javascript are calculations with fractional numbers guaranteed to be precise? NO, calculations with fractional numbers are not guaranteed to be precise in Javascript 3. List the comparison operators supported by Javascript? Javascript supports below comp...