Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 WEB


  Extension context menu is missing in Firefox after restart

If you have experience of writing Chrome extension, you may be familiar with how you can add a context menu for your extension. The code would be similar to below:chrome.runtime.onInstalled.addListener(function() { chrome.contextMenus.removeAll(); chrome.contextMenus.create({ "id": "your_id", "title": "Your Title", "contexts": ["all"] });});You need to add a listener listening to the extension install event. Once the extension is installed, create a context menu item with id your_id which applies to all elements on the page. After installing the extension, you wou...

2,532 0       CHROME EXTENSION FIREFOX CONTEXT MENU


  Send email using PHPMailer on GoDaddy hosting

According to PHPMailer troubleshooting guide, GoDaddy has a very strict rule on sending email using PHPMailer.Popular US hosting provider GoDaddy imposes very strict (to the point of becoming almost useless) constraints on sending an email. They block outbound SMTP to ports 25, 465 and 587 to all servers except their own. This problem is the subject of many frustrating questions on Stack Overflow. If you find your script works on your local machine, but not when you upload it to GoDaddy, this will be what's happening to you. The solution is extremely poorly documented by GoDaddy: you ...

15,593 2       PHP PHPMAILER GODADDY


  Resolve high CPU usage issue caused by file_get_contents in PHP

Sometimes a Linux server which runs Nginx + PHP-CGI(php-fpm) web service may experience sudden system load increase and the CPU usage is around 100% for many php-cgi processes when checking with top command. If this happens, file_get_contents may be the cause if it's used in the PHP script.In lots of web applications, normally there are lots of API requests based on HTTP. Many PHP developers like to use file_get_contents("http://example.com/") to get the API response because it's simple to use. But the problem of using file_get_contents is that it will block if the remote server responds ...

11,944 0       PHP-CGI FILE_GET_CONTENTS PHP


  5 Lightweight PHP Frameworks For Creating An API

PHP is undoubtedly one of the most popular programming languages that offer a wide range of lightweight frameworks for building basic websites to REST APIs. These frameworks are powerful tools that have the potential to enhance productivity in order to deliver faster results without getting distracted from the best practices of development.Developing REST APIs with plain PHP is a tedious and time-consuming process. In order to sort this out, you only need to hire php developers who have a niche expertise in the micro-frameworks of PHP as they have the capacity to make the process of building R...

3,488 0       PHP API


  + operation on JavaScript objects

In JavaScript, there are two types of values: primitive and object. Primitives consist undefined, null, boolean, number and string. Other values such as array and function are objects. When applying + operation on different type of values, there would be three kinds of type conversion.Primitive conversionNumber conversionString conversionThere three type conversions have corresponding abstract operations in JavaScript: ToPrimitive(), ToNumber(), ToString().For number addition, it's normal math addition(ToNumber). For strings, they are just string concatenations(ToString). For ob...

2,741 0       JAVASCRIPT PROGRAMMING


  Chrome to provide native image lazyload support

Previously we have introduced how Medium achieved loading images lazily, basically what they did was using lots of HTML tags and CSSs to change the images at different stage. It needs lots of code to do this. With the high demand of this feature for resource consumption and performance consideration, Chrome is now working on a feature to provide native support for loading images/iframes lazily. This feature is named lazyload.lazyload will allow three values:auto: the default behavior of lazyload attribute is not altered (user agent decides)on: the feature lazyload is turned on which ...

2,404 0       LAZYLOAD IMAGE CHROME IFRAME


  JavaScript to open link in new window without being popup blocked

To ensure security and reduce spamming, modern browsers have implemented very strict rules on when a new window can be opened in a web page. Currently browsers restrict that any new web page to be opened in a new window must be initiated with an user action. The action is usually an user click event. Otherwise, a popup blocker would show on the browser address bar which indicates that something is blocked.To workaround this issue, normally you should implement the window open logic in a click event handler. An example code block would look like:jQuery("#some_element").click(function(){ var win...

49,059 4       OPEN LINK IFRAME JAVASCRIPT NEW WINDOW


  Remove duplicated elements in JavaScript array

During interviews, one frequent question asked would be something like how to remove duplicated elements in a JavaScript array and how many different ways you can think of. The interviewee would also be asked to write the code down. In real applications, normally front end would not need to handle this case since normally it would be done by backend, but still it's necessary for front end developers to know different ways of doing this.This post will share some of the common ways to remove duplicated elements in JavaScript array.1. ES6 SetIn ES6, there is a new type called Set, The&n...

2,543 0       JAVASCRIPT ARRAY DUPLICATED ELEMENT