Wednesday, October 8, 2014

8 Common Tech Myths You Should Stop Believing Today


  1. Mac computers can’t get viruses: Yes, Apple computers are susceptible to malware, too. Apple used to brag its computers aren't vulnerable to PC viruses, but the company quickly changed its marketing page after a Trojan affected thousands of Mac computers in 2012.
  2. Private/Incognito browsing keeps you anonymous: There’s a misconception that “incognito” and “private” are synonymous with anonymous. If you’re using Incognito Mode in Google Chrome or Private browsing in Safari, it simply means the browser won’t keep track of your history, import your bookmarks, or automatically log into any of your accounts. It won’t keep your identity anonymous — so keep that in mind if you’re visiting sites you shouldn't be.
  3. Leaving your phone plugged in destroys the battery: If you’re like most people, you probably leave your phone plugged in overnight long after the battery is fully charged. Some used to say this would hurt your phone's battery life, but in fact, there's no proof that this damages your phone’s battery in any way. Modern smartphones run on lithium-ion batteries, which are smart enough to stop charging when they've reached capacity.
  4. More megapixels always means a better camera: What’s the difference between 12 megapixel cameras and 8 megapixel cameras? Not much, as it turns out. The quality of an image is determined by how much light the sensor is able to take in. Typically, bigger sensors come with larger pixels, and the larger the pixel the more light it can absorb. So, it’s really the size of the megapixels that matter more than the sheer number of megapixels. Here’s how TechCrunch’s Matthew Panzarino, who also happens to be a professional photographer, describes the role of the megapixel: “Think of this as holding a thimble in a rain storm to try to catch water. The bigger your thimble, the easier it is to catch more drops in a shorter amount of time." The thimble is a metaphor for a megapixel — using a few buckets would be much more efficient than a bunch of thimbles for catching water.
  5. Don’t charge your phone unless it’s almost dead: This, too, is a popular myth about lithium-ion batteries. It’s not harmful to plug your phone in before the battery is drained — in fact, it may be better for your battery. Batteries have a limited number of charge cycles before they lose their ability to hold a charge. A charge cycle consists of charging your battery back up to its full capacity when it’s out of juice. The reason your phone’s battery life diminishes as it gets older is because it’s already used up many of its cycles, not because you’re plugging it in when the battery is already half full.
  6. Higher display resolution is always better on a smartphone: Some have argued that at a certain point, screen resolution doesn't matter on a smartphone. Gizmodo cites experts in saying the human eye can't discern nitty-gritty detail when a display packs more than 300 pixels per inch. Earlier this year, LG unveiled its first quad-HD smartphone, the G3, which has a resolution of 2560 x 1440. That’s much higher than the average high-end smartphone, which usually comes with a 1920 x 1080 resolution display. But it's unclear if those numbers really matter after a certain point, because the eye can't discern individual pixels beyond a certain resolution. So when I tested the G3's display alongside the 1080 Galaxy S5's display, there was hardly a difference in terms of sharpness — that's why companies like Apple tend to focus on brightness, more so than ultra-dense displays.
  7. It’s bad to use your iPad charger for your iPhone: This one is a little trickier than a standard "yes or no" answer. Apple’s official website says its 12-watt iPad adapter can charge both the iPhone and the iPad. However, Steve Sandler, founder and chief technical officer at electronics analysis company AEi Systems, told Popular Mechanics that this could stress your iPhone’s battery over time if you do it regularly. It would take about a year, however, to notice any changes in battery efficiency.
  8. You shouldn't shut down your computer every day: While some may believe it’s harmful to shut down your computer every night, the truth is it’s actually good to turn off your computer regularly. It’s easy to get into the habit of putting your laptop in sleep mode so you can easily return to it without having to boot up. But, as Lifehacker points out, shutting it down when not in use conserves power and places less stress on its components, which could enable it to last longer.




source:

Wednesday, October 1, 2014

Why is printing “B” dramatically slower than printing “#”?

Pure speculation is that you're using a terminal that attempts to do word-wrapping rather than character-wrapping, and treats B as a word character but # as a non-word character. So when it reaches the end of a line and searches for a place to break the line, it sees a # almost immediately and happily breaks there; whereas with the B, it has to keep searching for longer, and may have more text to wrap (which may be expensive on some terminals, e.g., outputting backspaces, then outputting spaces to overwrite the letters being wrapped).

But that's pure speculation.










Source:
http://stackoverflow.com/questions/21947452/why-is-printing-b-dramatically-slower-than-printing

ما معنى "حديث غير محفوظ وهو حديث مرسل" برجاء الشرح لأني لا أفهم ماذا يعني حديث موقوف أو مرفوع ؟

ما معنى "حديث غير محفوظ وهو حديث مرسل" برجاء الشرح لأني لا أفهم ماذا يعني حديث موقوف أو مرفوع ؟

الحمد لله والصلاة والسلام على رسول الله وعلى آله وصحبه أما بعد:

فالعبارات التي سألت عنها؟ هي مصطلحات وضعها علماء الحديث للحكم عليه، وإليك بيان لمعانيها: 

  1. المرسل: هو الحديث الذي سقط من سنده الصحابي مثاله قول: سعيد بن المسيب وأمثاله من التابعين، قال رسول الله صلى الله عليه وسلم، بحذف الصحابي الذي روى عنه، والحديث المرسل من أنواع الحديث الضعيف.
  2. الموقوف: هو ما يروى عن الصحابة رضي الله عنهم من أقوالهم وأفعالهم ونحوها، فيوقف عليهم ولا يتجاوز بها إلى رسول الله صلى الله عليه وسلم، وهذا النوع من الصحيح والحسن والضعيف.
  3. المرفوع: هو ما أضيف إلى رسول الله صلى الله عليه وسلم، من قول أو فعل أو صفة. وقد يكون صحيحاً أو حسناً أو ضعيفاً بحسب حال سنده ومتنه. 


Thursday, July 10, 2014

HTML Debugging Hack !

I have just read an article for this guy (Gajus Kuizinas) ... He presented a very awesome way/hack to debug the html of any page ... All what he did is adding this block of css code into his website

* { background-color: rgba(255,0,0,.2); }
* * { background-color: rgba(0,255,0,.2); }
* * * { background-color: rgba(0,0,255,.2); }
* * * * { background-color: rgba(255,0,255,.2); }
* * * * * { background-color: rgba(0,255,255,.2); }
* * * * * * { background-color: rgba(255,255,0,.2); }

I will quote from his article:
"The problem is that unless the element on the page has a solid background or it is a picture, you do not see how does it fit into the layout, e.g. most of the text nodes, pictures with transparency, etc.
With the above CSS, you will see something along the lines of: "



"Different depth of nodes will use different colour allowing you to see the size of each element on the page, their margin and their padding. Now you can easily identify inconsistencies."

Wednesday, March 26, 2014

Types of errors in PHP

  An error is a type of mistake. We can say an error is a condition of having incorrect or false knowledge or an error is defined as an unexpected, invalid program state from which it is impossible to recover.
  Error can be defined also as "deviation from accuracy or correctness". A "mistake" is an error caused by a fault: the fault being misjudgment, carelessness or forgetfulness. An error with file name, line number and a message that describing the error is sent to the browser.

Types of errors
  Basically there are four types of errors in PHP, which are as follows:
  • Parse Errors (Syntax Error).
  • Fatal Errors.
  • Warning Errors.
  • Notice Errors.
  1. Parse Errors (Syntax Error)
  The parse error occurs if there is a syntax mistake in the script; the output is parse error. A parse error stops the execution of the script. There are many reasons for the occurrence of parse error in PHP. The common reasons for the parse error is the following:
    • Unclosed quotes.
    • Missing or extra parentheses.
    • Unclosed braces.
    • Missing semicolon.
  Example:
<?php
echo "cat";
echo "dog"
echo "lion";
?>
  Output:
  In the above code I missed the semicolon in the second line. When that happens there will be a parse or syntax error which will stop the execution of the script, as in the following image:

  2. Fatal Errors
  Fatal errors occurs when php understand what you have written, however what you'er asking to do cannot be done. Fatal errors stops the execution of the script. If you are trying to access undefined functions, then the output is a fatal error.
  Example:
<?php
function fun1(){
echo "Hello";
}
fun2();
?>
  Output:
    In the above code we defined a function fun1 but we call another function fun2 which is not defined. So a fatal error will be produced that stops the execution of the script, as the following image:

  3. Warning Errors
  Warning errors will not stop the execution of the script. The main reason of warning errors are to include a missing file or pass a wrong number of parameter for a certain function, as the following example.
  Example:
<?php
include("welcome.php");
?>
  Output:

  4. Notice Errors
  Notice errors are same as Warning errors; as the script do not stop, it occurs when you are trying to access an undefined variables, as in this example:
  Example:
<?php
$a = 12;
echo $b;
?>
  Output:
  In the above example we defined a variable $a, and called another "undefined" variable $b, that produced a notice error without stopping the script, a message will be produced like in the following snapshot:

Wednesday, February 12, 2014

include, include_once, require or require_once?

  The only difference between the two is that require and its sister require_once throw a fatal error if the file is not found, whereas include and include_once only show a warning and continue to load the rest of the page.
  If you don't want PHP to attempt to load the rest of your page without the database info (which I would assume), then use require_once. You don't need to include the file more than once, so there is no need to use the regular require function.

What is the difference between split() and explode()?

Split() function has been deprecated because:-
  • explode() is substantially faster because it doesn't split based on a regular expression, so the string doesn't have to be analyzed by the regex parser. Simply it splits string.
  • preg_split() is faster and uses PCRE regular expressions for regex splits
  • join() and implode() are aliases of each other and therefore don't have any differences.

Sunday, February 9, 2014

HTTP Request GET, HEAD, POST, PUT, DELETE, OPTIONS, TRACE Methods



  An HTTP request is a class consisting of HTTP style requests, request lines, request methods, request URL, header fields, and body content. The most common methods that are used by a client in an HTTP request are as follows:-
1) GET:- Used when the client is requesting a resource on the Web server.
2) HEAD:- Used when the client is requesting some information about a resource but not requesting the resource itself.
3) POST:- Used when the client is sending information or data to the server—for example, filling out an online form (i.e. Sends a large amount of complex data to the Web Server).
4) PUT:- Used when the client is sending a replacement document or uploading a new document to the Web server under the request URL.
5) DELETE:- Used when the client is trying to delete a document from the Web server, identified by the request URL.
6) TRACE:- Used when the client is asking the available proxies or intermediate servers changing the request to announce themselves.
7) OPTIONS:- Used when the client wants to determine other available methods to retrieve or process a document on the Web server. 
8) CONNECT:- Used when the client wants to establish a transparent connection to a remote host, usually to facilitate SSL-encrypted communication (HTTPS) through an HTTP proxy.


The GET Request Method
  The GET method is the simplest and the most frequently used request method. It is used to access the static resources, such as HTML documents and images. GET request can be used to retrieve dynamic information by including query parameters in the request URL. For instance, we can send a parameter name with the URL, such as http://www.domain.com?name=Harsh. In this example, Harsh is the dynamic information sent by including a parameter,name, in the request URL. The Web Server can then access this dynamic information through the “name” parameter.

The HEAD Request Method
  According to Wikipedia “Asks for the response identical to the one that would correspond to a GET request, but without the response body. This is useful for retrieving meta-information written in response headers, without having to transport the entire content.” It is used when the client is requesting some information about a resource but not requesting the resource itself. This means that we have a faster way of checking the headers and some server info for a given resource on the server i.e. checking if a given url is serviceable, a given file exists, etc..Sometimes client might only need to view the header of a response (Content-Type or Content-Length). The client can use the HEAD request method to retrieve the header in such cases. The HEAD method is similar to GET method, except that the server does not return a message body (actual page) in response of the HEAD method.

The POST Request Method
  The Post method is commonly used for accessing dynamic resources or when a large amount of complex information is to be sent to the server. The Web Server accepts the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI( Uniform Resource Identifier). According to Wikipedia “Submits data to be processed (e.g., from an HTML form) to the identified resource. The data is included in the body of the request. This may result in the creation of a new resource or the updates of existing resources or both.” The major difference between GET and POST is that in GET the request parameters are transmitted as a query string appended to the request URL, while in POST the request parameters are transmitted within the body of the request.
  The POST request method provides the following functionalities:-
1) Providing annotations of the existing resources.
2) Posting a message to a bulletin board, newsgroup, mailing list, or a similar group of articles.
3) Providing a block of data, such as the result of the submitting a form, to a data-handling process.
4) Extending a database through an append operation.

The PUT Request method
  The PUT method stores an entity in the specified Request-URI. The entity is a resource residing on the Web server under the specified Request-URI. If the Request-URI does not point to an existing resource, but is capable of being defined as a new resource by the requesting user, the Web Server can create the resource with that URI. If an existing resource is modified, either the 200(OK) or 204 (No Content) response code should be sent to indicate successful modification of a resource. The Web Server must inform the user via the 201 (Created) responses if a new resource is created. If the resource is not created or modified with the Request-URI, an appropriate error response is generated, which reflects the nature of the problem.

The DELETE Request method
  The DELETE method requests the Web server to delete the resource identified by the Request-URI. This method may be overridden by human intervention (or other means) on the Web Server. If the response includes an entity describing the status of deletion, the 200(OK) response code specifies that the resource has been deleted successfully. If the response is 202(Accepted), it specifies that the resource has not yet been deleted. Similarly, if the response code is 204 ( No Content), it specifies that the resource has been deleted but the response code does not include an entity.

The OPTIONS Request method
  According to Wikipedia “Returns the HTTP methods that the server supports for specified URL. This can be used to check the functionality of a web server by requesting '*' instead of a specific resource.”
  The OPTION method requests for information about the communication options available on the request/response chain identified by a Request-URI. Responses to this method are not cacheable. This method allows the client to determine the options and /or requirements associated with a resource, or the capabilities of a server. If the OPTIONS method includes an entity body, the media type must be indicated by the content-type field.

The TRACE Request method
  According to Wikipedia “Echoes back the received request, so that a client can see what (if any) changes or additions have been made by intermediate servers.”
  The TRACE method is used to invoke a remote application layer associated with a request message. A TRACE request must not include an entity. A client uses the TRACE method to see the received input at the other end of the request chain and diagnostic or testing information.