WEB


  JavaScript interview questions

This post will cover the JavaScript questions I have encountered and have seen during my programming career. They will mainly focus on vanilla JavaScript though there are lots of excellent frameworks out there and many people are using them in their daily work.this keywordthis keyword is an very important but easy to confuse concept in JavaScript since it is always referring to the calling object of the function.1. What will be the output of below code snippet?function User(name) { this.name = name; this.display = function(){ console.log(this.name); }}var user = new User("javas...

9,139 0       ALGORITHM JAVASCRIPT THIS CLOSURE


  PHP to integrate with Sign in with Google

Google has a huge user base and hence it provides an authentication service for third party service to integrate with them so that people can sign in with Google in their services. Google also adopts OAuth 2 to provide this kind of Open ID connect service.This post will introduce how to integrate with sign in with Google functionality in your PHP website. Create a client app on GoogleThe first step you should follow is to create a Google app, you can follow the post here to create the project. Once the project is created, you will get a client id and client secret, these will be used late...

4,191 0       PHP GOOGLE API OPEN API SIGN IN WITH GOOGLE


  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,636 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,908 2       PHP GODADDY PHPMAILER


  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 ...

12,087 0       PHP FILE_GET_CONTENTS PHP-CGI


  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,551 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,818 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,461 0       IFRAME CHROME IMAGE LAZYLOAD