Saving a file downloaded with wget with a different name

wget is a command line utility for downloading files from FTP and HTTP web servers. By default when you download a file with wget, the file will be written to the current directory,  with the same name as the filename in the URL. For example, if you were to download the little Tux penguin and […]

Read More

How to resolve wget/ping/dig not working in AWS AMAZON server

How can I enable outgoing HTTP/HTTPS requests on an EC2 in a public subnet within a VPC on Amazon AWS Why doesn’t the provided AWS DNS Server work in this case? PROBLEM The problem was that DNS names weren’t resolving via the local DNS server than Amazon provided when originally creating the VPC. I discovered that […]

Read More

Upload Multiple Files or Images in Codeigniter using Ajax JQuery

Source Code Controllers – Upload_multiple.php <?php defined(‘BASEPATH’) OR exit(‘No direct script access allowed’); class Upload_multiple extends CI_Controller { function index() { $this->load->view(“upload_multiple”); } function upload() { sleep(3); if($_FILES[“files”][“name”] != ”) { $output = ”; $config[“upload_path”] = ‘./upload/’; $config[“allowed_types”] = ‘gif|jpg|png’; $this->load->library(‘upload’, $config); $this->upload->initialize($config); for($count = 0; $count<count($_FILES[“files”][“name”]); $count++) { $_FILES[“file”][“name”] = $_FILES[“files”][“name”][$count]; $_FILES[“file”][“type”] = $_FILES[“files”][“type”][$count]; […]

Read More

MySQL query to select events between start/end date

I have a MySQL table named ‘events’ that contains event data. The important columns are ‘start’ and ‘end’ which contain string (YYYY-MM-DD) to represent when the events starts and ends. I want to get the records for all the active events in a time period. Events: —————————— ID | START_DATE | END_DATE | —————————— 1 […]

Read More

php url crawler

Crawl a webpage for all url Method – 1 <?php function crawl_page($url, $depth = 5) { $arr = array(); static $seen = array(); if (isset($seen[$url]) || $depth === 0) { return; } $seen[$url] = true; $dom = new DOMDocument(‘1.0’); @$dom->loadHTMLFile($url); $anchors = $dom->getElementsByTagName(‘a’); foreach ($anchors as $element) { $href = $element->getAttribute(‘href’); if (0 !== strpos($href, […]

Read More

Bitly PHP Api to Create Short Link, Get Long Url and Get Stats

Use this PHP fucntion to create Bitly Short Link using PHP     In Additional to this if  you want to create Short link using php function :- <?php function createShortLink($long_url) { $bitly_login = “bitlydemo”; $bitly_api = “R_0da49e0a9118ff35f52f629d2d71bf07”; $long_url = urlencode($long_url); $bitly_response = json_decode(file_get_contents(“http://api.bit.ly/v3/shorten?login={$bitly_login}&apiKey={$bitly_api}&longUrl={$long_url}&format=json”)); $short_url = $bitly_response->data->url; return $short_url; } ?> if you want to […]

Read More

How to embed a google plus post in webpage

What is an embedded post? A new feature on Google+ has been released enabling you to take any public post (except communities at present) and embed it on a website just by adding in a simple code. It really is simple. Use the following code to embedding  a google plus post <!–place this code in […]

Read More

How To Get Posts Category In WordPress

Problem Can we get the list of blog posts in the following structure? Published Date Author Category Post Title Blog URL Solution 1 2 3 4 5 6 7 8 9 10 SELECT p.ID,DATE(p.post_date) Date,u.display_name Author,p.post_title Title,GROUP_CONCAT(t.name) Category, CONCAT(‘http://yourdomain.com/blog/’,p.post_name) URL FROM wp_posts p LEFT JOIN wp_users u ON p.post_author = u.ID LEFT JOIN wp_term_relationships rel ON rel.object_id = […]

Read More

How to add a remote database connection for other server

Remote Connections Mysql Ubuntu To expose MySQL to anything other than localhost you will have to have the following line For mysql version 5.6 and below uncommented in /etc/mysql/my.cnf and assigned to your computers IP address and not loopback For mysql version 5.7 and above uncommented in /etc/mysql/mysql.conf.d/mysqld.cnf and assigned to your computers IP address […]

Read More

How To Import and Export Databases and Reset a Root Password in MySQL

How to Import and Export Databases Export To Export a database, open up terminal, making sure that you are not logged into MySQL and type, mysqldump -u [username] -p [database name] > [database name].sql The database that you selected in the command will now be exported to your droplet. Import To import a database, first […]

Read More