Friday 19 August 2016

How to Solve PHP Fatal error: Allowed memory size of 8388608 bytes exhausted

One of the most common and frustrating errors encountered by PHP coders reads: “Fatal error: Allowed memory size of 8388608 bytes exhausted…” followed by something like “(tried to allocate XXXX bytes) in /home/www/file.module on line 12.” This fatal PHP error crops up because, by default, PHP has a memory usage limit of 8 MB for any given script. This is a good thing, actually, because you don’t want a rogue PHP script to bring down your server by hogging all the memory. But occasionally, you’ll have a PHP script that normally exceeds the 8 MB limit (say, for importing or uploading). To workaround the “Fatal error: Allowed memory size of 8388608 bytes exhausted…” error message, simply insert this line of code into your script at the top:
ini_set(“memory_limit”,”16M“);





This will set your memory limit to 16 MB, rather than 8 MB. You can, and should, fiddle with this number so that it is as low as possible without repeating that error message. This will only alter the memory limit for that particular PHP file.
Alternately, you can alter your php.ini file to up the memory limit. This will affect all scripts on your server. Simply open php.ini and find the line that reads “memory_limit” and alter it:
memory_limit=16M

I’ve noticed in my own PHP.ini file that my default is much higher at 128M. So, if I were to ever receive this error message it would read: “Fatal error: Allowed memory size of 134217728 bytes exhausted…” and obviously be a much bigger problem. But it has the same workaround as “Fatal error: Allowed memory size of 8388608 bytes exhausted…” or “Fatal error: Allowed memory size of 16777216 bytes exhausted…” or whatever. Apparently, the  memory_limit default was upped  from 8M to 16M in PHP 5.2.0 and is now 128M for PHP 5.3.0, which would explain why you may not get this error message at all.

You can also disable the memory limit by setting memory_limit to –1 in PHP.ini.
memory_limit=-1
This isn’t usually a good idea, though, for obvious reasons.
Note: You can also use the memory_limit line in your .htaccess page.
Now, remember, this is only a workaround. Really, your PHP script should not be exceeding 8 MB, unless your uploading files or doing something else that’s obviously taking up a lot of memory usage. What you should really be doing is trying to figure out why your script is using so much memory and attempt to fix it. One way to figure out how much memory your PHP script is using is to use the memory_get_usage() PHP function. Simply echo it at any point in your script to find out where your memory usage is spiking:
echo memory_get_usage();
If you’re getting this error message in Drupal or Joomla, the likely culprit is a new module or package. For example, in Drupal, the admin/modules page loads every module in your Drupal installation, which can get hairy if a custom module is buggy, corrupt or hacked. Try disabling modules one by one to identify which is bringing the party down. Also, some hosting providers will ignore your attempts to modify the memory limits for your PHP code so you might need to contact your hosting support to assist you. I’ve found sometimes I need to edit the php.ini file and sometimes put the code into the .htaccess file. Either way, hopefully this info here is enough to get you on your way!

Sunday 7 August 2016

CodeIgniter 4 Development

What is CodeIgniter?

CodeIgniter is a PHP full-stack web framework that is light, fast, flexible, and secure. More information can be found at the official site.
This repository holds the pre-alpha code for CodeIgniter 4 only. Version 4 is a complete rewrite to bring the quality and the code into a more modern version, while still keeping as many of the things intact that has made people love the framework over the years.
This is pre-release code and should not be used in production sites.
More information about the plans for version 4 can be found in the announcement on the forums.

Important Change with index.php

index.php is no longer in the root of the project! It has been moved inside the public folder, for better security and separation of components.
This means that you should configure your web server to "point" to your project's public folder, and not to the project root. A better practice would be to configure a virtual host to point there. A poor practice would be to point your web server to the project root and expect to enter public/..., as the rest of your logic and the framework are exposed.
Please read the user guide for a better explanation of how CI4 works! The user guide updating and deployment is a bit awkward at the moment, but we are working on it!

Repository Management

We use Github issues to track BUGS and to track approved DEVELOPMENT work packages. We use our forum to provide SUPPORT and to discuss FEATURE REQUESTS.
If you raise an issue here that pertains to support or a feature request, it will be closed! If you are not sure if you have found a bug, raise a thread on the forum first - someone else may have encountered the same thing.
Before raising a new Github issue, please check that your bug hasn't already been reported or fixed.
We use pull requests (PRs) for CONTRIBUTIONS to the repository. We are looking for contributions that address one of the reported bugs or approved work packages.
Do not use a PR as a form of feature request. Unsolicited contributions will only be considered if they fit nicely into the framework roadmap. Remember that some components that were part of CodeIgniter 3 are being moved to optional packages, with their own repository.

Contributing

We are accepting contributions from the community, specifically those identified as part of phase 2.
We will try to manage the process somewhat, by adding a "Help wanted" label to those that we are specifically interested in at any point in time. Join the discussion for those issues, and let us know if you want to take the lead for one of them.
We are not looking for out-of-scope contributions, only those that would be considered part of our controlled evolution!
Please read the Contributing to CodeIgniter section in the user guide

Server Requirements

PHP version 7 or higher is required.

Running CodeIgniter Tests

Information on running CodeIgniter test suite can be found in the README.md file in the tests directory.

 https://github.com/bcit-ci/CodeIgniter4

Friday 29 July 2016

Understanding Node.js

Node.js is built on Google’s Chrome Javascript Engine and it’s a server side platform. In 2009, it was developed by Ryan Dahl. The latest version is v0.10.36. The definition of Node.js can be summed up as follows:
Chrome’s Javascript runtime is what Node.js is built off of. It allows you to build scalable and fast network applications.Node.js uses a non-blocking I/O model which is event-driven. It’s efficient and lightweight which makes it the right choice for real-time applications on distributed devices.

What is Node.js?
Node.js is a runtime environment which cross-platform and open source. It’s used for developing network applications and server-side applications. Node.js applications use Javascript as the code and they can be run on Microsoft Windows, OS X, and Linux through the Node.js runtime. There’s a rich library which holds many Javascript modules with Node.js. This makes development of web applications simple.
  • Event Driven and Asynchronous – The APIs which are a part of the Node.js library is considered asynchronous or non-blocking. This means that when a Node.js server is used it never waits for an API to return the data. The server will move onto the next API once it’s called and the notification mechanism of Events found in Node.js helps a server get a response from any previous API call.
  • Can be Built quickly on Chrome’s V8 JavaScript Engine – The library of Node.js offers fast code execution.
  • Highly Scalable even though Single Threaded – A Single threaded event looping model is used for Node.js. The event mechanisms help a server responding in a way which is non-blocking. The server is scalable where traditional server creates a limited number of threads to handle the requests. A single-threaded program is used with Node.js and the same program provides service to larger numbers of requests that regular serves such as the Apache HTTP Server.
  • There’s no Buffering – When you use Node.js applications data is never buffered. The applications use output data in chunks.
  • License – You get Node.js under the MIT license.
Who is Using Node.js?
There are many projects, companies, and applications which are using Node.js. You can fund this list on the github wiki. Some of the well-known ones are GoDaddy, General Electric, PayPal Microsoft, Uber, Yahoo!, Wikipins, Yammer, and others.
This diagram shows the important aspects of Node.js

Where is Node.js used?
Here are the areas where Node.js is perfect to use:
  • Data Streaming Applications
  • I/O bound Applications
  • JSON APIs based Applications
  • Data Intensive Real Time Applications (DIRT)
  • Single Page Applications
Where you Should Not Use Node.js
Don’t use Node.js for any applications which are CPU intensive.

PHP Check Server

This class can check if you can connect to a server.



It can take the network address of a server and the name of a protocol and it tries to establish a TCP connection to a given port of the server to see if it accepts the connection.

The server port to connect is configurable but it can also use the pre-defined ports for several known protocols like IMAP, POP3, SMTP, SMTP/TLS, SMTP/SSL, HTTP, HTTPS, FTP, CUPS, LDAP, LDAP/SSL, MYSQL, and PostreSQL.



 Download File

Wednesday 27 July 2016

PHP Convert Text to Audio

Spell text as MP3 audio using Google Translate



This class can spell text as MP3 audio using Google Translate.

It can take a given text string in an idiom and generates a MP3 audio stream using Google translate.

The class generates HTML with JavaScript to play the converted text in a Web page.

 Download
Example :-

<!doctype html> 
<html> 
<body> 
<center> 
<form method="post"> 
<h1>Text Reader</h1> 
<textarea name="testo_da_leggere"></textarea><br /> 
<input type="text" name="lingua_testo" placeholder="Codice lingua" /><br /> 
<input type="submit" value="Leggi" /> 
</form> 
</center> 
<?php 
include "text-reader.php"; 
$testo_da_leggere = ((isset($_POST['testo_da_leggere'])) ? $_POST['testo_da_leggere'] : "Inserisci un testo da leggere"); 
$lingua_testo = ((isset($_POST['lingua_testo'])) ? $_POST['lingua_testo'] : "it"); 
$textReader->Read($testo_da_leggere,$lingua_testo); 
?> 
</body> 

</html> 

JData: Connect to MySQL using MySQLi and run SQL queries

Short description:

Connect to MySQL using MySQLi and run SQL queries.

Description

This class can connect to MySQL using MySQLi and run SQL queries.

It can establish a connection to a given MySQL server using MySQLi.

The class can execute either queries that return results or not. Queries that return results return them in arrays.

It can also generate log files of the executed queries when in development environment.

 Download

DigitalOcean India Hosting is available on Cloudways

Cloudways, a Managed Cloud Hosting Platform is growing in the web market at an agile rate. Recently, Cloudways has announced its integration of DigitalOcean data center located in Bangalore (Bengaluru), India. DigitalOcean, being one of the four cloud providers on Cloudways, has proved itself as an amazing cloud service for users across the world.

 Signup


Startups
India is a hubspot for new startups and observing how technology is empowering the market, India outshines as a gem within the IT industry. The new DigitalOcean data center aims to promote such startups and already existing IT businesses by allowing them to launch servers based on different web applications.
Cloudways is a recognized hosting platform that permit users to host and manage business websites, ecommerce stores, interactive blogs and different other web applications to design such websites for developers.
According to the CTO and co-founder at Cloudways, Pere Hospital, “The new data center from DigitalOcean in India on Cloudways will help a large number of startups and individuals in setting up their web applications with ease,” he further added, “With blazing fast performance and affordable plans, Cloudways Cloud Platform is a powerful app deployment solution for India and its neighboring regions.”
Blazingly Fast Performance

Cloudways is an amazing solution for developers and designed crafting websites for small and mid sized organizations. It is equipped with a unique optimization formula that amalgamates the strength of Nginx, Varnish, Apache, and Memcached. Due to this Thunderstack formula, Cloudways ensures that websites load 100 percent faster as compared to traditional hosting environment.
Special offer from Cloudways
Cloudways Indian Hosting comes with quite affordable plans as low as up to $5. The hosting platform is packed with a number of amazing features such as free SSL (Let’s Encrypt), free subdomain-based staging areas, free SMTP addon, and free WordPress automated migrations.
It comes with a free trial period through which users can test their websites and experience the hosting performance at Cloudways.
Today, information is a major commodity in the tech market. We are all aware that all the information stored within a cloud environment is safe and secure in servers organized in different data centers.
When your local internet service provider is also your local collocation solution, everything runs more efficiently and smoothly. Upload, download, and disaster recovery all becomes a far easier and faster enterprise when you’re on a dedicated network. India is the next big things when it comes to startups and we believe the IT market of India will hopefully be investing more in the coming future.

Saturday 23 July 2016

Google I/O 2016 - a Roundup

io_banner.png

What was your favorite announcement from the Google I/O 2016 keynote? Here is a roundup of the biggest news coming out of Google I/O 2016 for you: 

Android N - smarter, faster, better:

Android-N-new-features.jpgGoogle released a new beta for Android N with features revolving around three key points - performance, securityand productivity - lots of new features for N.
    • Android N puts its biggest lead forward with ‘Volken’ - a modern 3D graphics API designed to give game controllers direct control over the GPU to produce incredible graphics and compute performance.
    • Next comes the all new Just in Time or ‘JIT compiler’ which ensures that the app installs are 75% much faster.
    • To capture security, N introduces File based encryption, strong media framework security and allows seamless updates.
The new operating system also improves productivity by adding new features into multitasking, multi window operations and enhanced notifications system and better emojis.
Android N is expected to release later this summer. The N could be for anything, our best guess Nougat orNutella!

google_io_android_wear_2-1.pngAndroid Wear 2.0:

Google announces a drastic overhaul to Android Wear. All updated to offer better battery life, phone-free operation, better fitness support and smarter, more predictive operation. Smart Reply, handwriting recognition and a new keyboard are some highlights. The developer preview launched last night, and it will be live in the fall.

 

The two all new communication apps:allo_duo_1.png

Allo, the smart messaging app: Google’s brings AI into messaging with Allo which smartens your text conversations. Allo’s best feature is Google Assistant integration, smart photo recognition and a better focus on emoji. The app also features an Incognito Mode, which includes end-to-end encryption, message expiration and private notifications.
Duo-video calling app: Duo is a video companion to Allo. A competitor of Facetime. Duo come with an interesting feature ‘ Knock-Knock’ that shows you a live video stream of the caller before you pick up the call.
Both Allo and duo will be available later this summer for iOS and Android.

google_daydream.png

Welcome to Android VR:

Android steps into mobile VR through DayDream, built on top of Android N. For the feature, Google has revamped the Play Store, so users can browse and download apps with the VR headset on. Movies will also be viewable in VR now, as well both regular and 360-degree YouTube videos. And while Google mentioned (but didn’t display) a new headset coming later this year, they did show off a new VR controller.

Google Home:google_home_1.png

Your new housemate from Google. Google Home is  a small white and grey speaker with always-listening microphones that integrates into a broad range of services.  It plays music and lets you control smart home devices. And yes of course, you can ask Google Home anything you want to know.

android_auto.png

 

Updates to Android Auto:

Google also announced a number of improvements for car drivers. The popular traffic-tracking app Waze is now built directly into Android Auto, letting drivers see speed trap warnings and accident alerts in real time.

Friday 22 July 2016

Top 5 Things You Need To Know to Learn NoSQL


Experts say that the world’s data is doubling every two years. This epic increase in Big Data has highlighted the limitations of reliance on traditional forms of data storage and management while also focusing attention on new methods for addressing the volume and variety and veracity of structured and unstructured data. In these discussions, one of the terms you’ve undoubtedly heard lots of buzz around is the expression “NoSQL.”



NoSQL databases grew rapidly in popularity over the last several years and the market outlook is great. In fact, NoSQL has emerged as the preferred choice for mobile and web development. So let’s stop and consider the most important points you should be considering about NoSQL. What is most critical to know at the current stage in this exciting market? In the following we outline the top 5 things you should know about NoSQL as it stands today.

NoSQL represents a deliberate shift away from relational DBs

NoSQL is a technical term that means either “No SQL” or “Not only SQL” and represents a paradigm shift away from sole reliance on relational databases. Relational databases (RDMS) emerged in the 1970s and were based on a set of data tables that could be queried and matched based on languages like SQL. These database architectures were ‘structured’ meaning that the data was organized in a uniform format and varied little over time.

NoSQL architecture has clear advantages

There are a number of types of NoSQL databases such as Key Value Pairs, Column Family Stores, Graph Databases, Document Databases. Key Value Pairs are the most popular and represent a fundamental method for representing data in computer systems and applications. In this schema a unique key exists for a particular object that needs to be returned; querying the database for that unique key will return results from whichever node has the object.
NoSQL is also much more scalable, data can be ingested without a predefined schema, and development is faster and code integration more reliable. This all translates into bigger and faster application changes in real-time.

NoSQL has a wide range of applications and use cases

There are any number of applications for NoSQL data storage and processing solutions today, ranging from user profile stores, to eCommerce sites, to mobile applications. Netflix is one high profile example of a major organization that migrated from Oracle to the NoSQL database Cassandra to help it better stream huge amounts of content to millions of customers worldwide each day. There are a growing number of possible use cases for how organizations today can leverage the benefits of NoSQL.


NoSQL is great for small businesses

The ability to deliver high-volume, high-variety online applications for a fraction of the cost that it took with traditional methods, is also one of the reasons why NoSQL technologies are an appealing solution for smaller organizations with limited budgets. Some of the top NoSQL databases on the market today include MongoDBMarkLogicCouchbaseCloudDB, and Amazon’s Dynamo DB. Each vendor has emerged with robust, scalable, cloud-based solutions that allow for rapid processing of real-time Big Data applications – all in ways that are affordable.

The NoSQL outlook is strong

The market is a formidable one with projected growth forecast to reach $3.4 Billion in 2020, representing a compound annual growth rate (CAGR) of 21% for the period 2015 – 2020. With the massive growth expected in the Internet of Things market and the enormous Big Data sets this will produce, small businesses would be well advised to start looking seriously at NoSQL and start taking measures to adopt the latest benefits of this technology.

Thursday 21 July 2016

How to view webpage in fullscreen using jQuery and HTML5 API


Today I’m going to share how to view your webpage in fullscreen mode using jQuery and HTML5 API
Advantage of Full Screen Design is that it is equally functional both on desktop and mobile devices and across different browsers. This helps streamline programming while providing viewers with a polished, professional brand image that is consistent from big to small screen devices.
Other Benefits of Full Screen Design
  • Research shows that it helps boost conversion rates
  • Its clean formatting doesn’t distract with unnecessary page elements
  • Its imagery fuses intuitively with written content; and
  • Stunning full screen design imagery increases the likelihood that viewers will continue to explore the site instead of hitting the back button.

Step 1 : Include jQuery.js and Font Awesome Scripts in the Header

Include the below scripts in your header tag
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//use.fontawesome.com/aa03aaad2f.js"></script>

HTML code

<a href="javascript:;" class="fullscreen-toggle"><i class="fa fa-arrows-alt"></i> View Fullscreen</a>

jQuery and HTML4 API code to activate Fullscreen

$(".fullscreen-toggle").on("click", function() {
    document.fullScreenElement && null !== document.fullScreenElement || !document.mozFullScreen && !document.webkitIsFullScreen ? document.documentElement.requestFullScreen ? document.documentElement.requestFullScreen() : document.documentElement.mozRequestFullScreen ? document.documentElement.mozRequestFullScreen() : document.documentElement.webkitRequestFullScreen && document.documentElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT) : document.cancelFullScreen ? document.cancelFullScreen() : document.mozCancelFullScreen ? document.mozCancelFullScreen() : document.webkitCancelFullScreen && document.webkitCancelFullScreen()
});
The Document.fullscreenElement read-only property returns the Element that is currently being presented in full-screen mode in this document, or null if full-screen mode is not currently in use
  • document.fullScreenElement: the element which has been pushed to fullscreen.
  • document.fullScreenEnabled: notes if fullscreen is current enabled.

Resize images to a given width and height

This class can resize images to a given width and height.It can take a given GIF, JPEG and PNG image and resize it to a given width and height.The class can display the image as the current script output or save to a given file.The quality percentage of the resized image is a configurable parameter.


Example :


<?phprequire('../image_sizer.php');$img = new image_sizer();/**
 * setImage()
 * url : http://localhost/example1.php?img=https://upload.wikimedia.org/wikipedia/commons/c/c1/PHP_Logo.png
 *
 */
$img->setImage($_GET['img']);/**
 * setSize
 * New image size
 * $img->setSize(Width, Height)
 */
$img->setSize(10060);/**
 * show image
 *
 * $img->show(type, quality);
 * type : png, jpeg, jpg, gif
 * quality : image show quality 100 = 100%
 */
$img->show('png'100);



 Download