MSNBC Shows Scary Clip of Trump and Putin Using Exact Same Talking Points

The two appear to be synching their propaganda.

Using footage from President Donald Trump’s recent rally in Florida and Russian President Vladimir Putin’s annual media conference, MSNBC demonstrated how the two world leaders are sharing talking points.

Both leaders insulted Trump’s opposition, made grandiose claims about the stock market and claimed Trump is the victim of fake news.

Putin has spoken on the phone at least twice with the president in the last week as he blatantly vies for power over Trump by boosting his fragile ego.

Watch the clip below.

 

Related Stories

  • There’s an Insidious Strategy Behind Donald Trump’s Retweets
  • Treasury Secretary Steve Mnuchin Seriously Claims Ignorance of CDC Banned Words Report
  • Sarah Palin’s Son Track Palin Was Arrested in Alaska on Domestic Violence Charges

About Trees, different Traversals and BST

A tree is a data structure made up of nodes or vertices and edges without having any cycle. The tree with no nodes is called the null or empty tree. A tree that is not empty consists of a root node and potentially many levels of additional nodes that form a hierarchy.

Tree

Tree Terminology

Lets see some tree terminologies:-
Root: The top node in a tree.
Child: A node directly connected to another node when moving away from the Root.
Parent: The converse notion of a child.
Siblings: A group of nodes with the same parent.
Descendant: A node reachable by repeated proceeding from parent to child.
Ancestor: A node reachable by repeated proceeding from child to parent.
Leaf: A node with no children.
Internal node: A node with at least one child.
Degree: The number of sub trees of a node.
Edge: The connection between one node and another.
Path: A sequence of nodes and edges connecting a node with a descendant.
Level: The level of a node is defined by 1 + (the number of connections between the node and the root).
Height of node: The height of a node is the number of edges on the longest path between that node and a leaf.
Height of tree: The height of a tree is the height of its root node.
Depth: The depth of a node is the number of edges from the tree’s root node to the node.
Forest: A forest is a set of n ≥ 0 disjoint trees.

Tree Node

Tree Node has a data part and references to its left and right child nodes.

struct node {
int data;
struct node *leftChild;
struct node *rightChild;
};
In a tree, all nodes share common construct.

Tree Traversals

Traversal is a process to visit all the nodes of a tree and may print their values too. Because, all nodes are connected via edges (links) we always start from the root (head) node. That is, we cannot randomly access a node in a tree. Unlike linear data structures (Array, Linked List, Queues, Stacks, etc) which have only one logical way to traverse them, trees can be traversed in different ways. Following are the generally used ways for traversing trees.

  • In-order Traversal
  • Pre-order Traversal
  • Post-order Traversal

In-Order Traversal

In this traversal method we first visit the left sub-tree, then the root and later the right sub-tree. If a binary tree is traversed in-order, the output will produce sorted key values in an ascending order.
For e.g.
Output of the In-Order traversal for above tree is
4 -> 2 -> 5 -> 1 -> 3
Algorithm Inorder(tree)
1. Recursively traverse the left subtree, i.e., call Inorder(left-subtree)
2. Visit the root
3. Recursively traverse the right subtree, i.e., call Inorder(right-subtree)

Pre-Order Traversal

In this traversal method we first visit the root node, then the left sub tree and finally the right sub-tree.
For e.g.
Output of the In-Order traversal for above tree is 
1-> 2 -> 4 -> 5 -> 3
Algorithm Preorder(tree)
1. Visit the root.
2. Recursively traverse the left subtree, i.e., call Preorder(left-subtree)
3. Recursively traverse the right subtree, i.e., call Preorder(right-subtree)

Post-Order Traversal

In this traversal method we first visit the left sub tree, then the right sub-tree and finally the root node.
For e.g.
Output of the In-Order traversal for above tree is 
4-> 5 -> 2 -> 3 -> 1
Algorithm Postorder(tree)
1. Recursively traverse the left subtree, i.e., call Postorder(left-subtree)
2. Recursively traverse the right subtree, i.e., call Postorder(right-subtree)
3. Visit the root

Binary Search Tree(BST)

In binary tree, every node can have maximum two children but there is no order of nodes based on their values. Binary search tree is a type of binary tree in which all the nodes in left subtree of any node contains smaller values and all the nodes in right sub-tree of that contains larger values as shown in following figure

Operations on a Binary Search Tree

Following Oprations performed on BST
1. Search
2. Insertion
3. Deletion

Search Operation

Whenever an element is to be searched, start searching from the root node. Then if the data is less than the key value, search for the element in the left subtree. Otherwise, search for the element in the right subtree. Follow the same algorithm for each node.
Algorithm
node* search(int data){
struct node *current = root;
printf("Visiting elements: ");
while(current->data != data){
if(current != NULL) {
printf("%d ",current->data);
//go to left tree
if(current->data > data){
current = current->leftChild;
}//else go to right tree
else {
current = current->rightChild;
}
//not found
if(current == NULL){
return NULL;
}
}
}
return current;
}

Insert Operation

Whenever an element is to be inserted, first locate its proper location. Start searching from the root node, then if the data is less than the key value, search for the empty location in the left subtree and insert the data. Otherwise, search for the empty location in the right subtree and insert the data.
Algorithm
Node * Insert(Node * root, int data)
{
if(root == nullptr)
{
Node * NN = new Node();
root = NN;
root->data = data;
root->left = root ->right = NULL;
}
else
{
if(data < root->data)
{
root->left = Insert(root->left, data);
}
else
{
root->right = Insert(root->right, data);
}
}
return root;
}

Deletion Operation in BST

In a binary search tree, the deletion operation is performed with O(log n) time complexity. Deleting a node from Binary search tree has following three cases:-
Case 1: Deleting a Leaf node (A node with no children)
Step 1: Find the node to be deleted using search operation
Step 2: Delete the node using free function (If it is a leaf) and terminate the function.
Case 2: Deleting a node with one child
Step 1: Find the node to be deleted using search operation
Step 2: If it has only one child, then create a link between its parent and child nodes.
Step 3: Delete the node using free function and terminate the function.
Case 3: Deleting a node with two children
Step 1: Find the node to be deleted using search operation
Step 2: If it has two children, then find the largest node in its left subtree (OR) the smallest node in its right subtree.
Step 3: Swap both deleting node and node which found in above step.
Step 4: Then, check whether deleting node came to case 1 or case 2 else goto steps 2
Step 5: If it comes to case 1, then delete using case 1 logic.
Step 6: If it comes to case 2, then delete using case 2 logic.
Step 7: Repeat the same process until node is deleted from the tree.

Do you want to learn Java Programming?

Tobold’s Game of the Year

This year my prestigious (that is to say totally unknown) game of the year award goes to, *drumroll*, The Legend of Zelda – Breath of the Wild on the Nintendo Switch. None of the other games I played on various platforms this year comes even close to the level of craftsmanship of Zelda. It is an explorer’s paradise: Huge is both quantity and quality of handcrafted features in the landscape, the next discovery feels always right around the next corner. No procedurally generated landscapes here! There is a great mix of different challenges, from fights to puzzles to riddles to crafting, which always keeps you entertained.

This game really is a “system seller”: if you can afford to spend $400 on a game, buying a Switch to play Zelda is totally worth it. And because it is hundreds of hours of gameplay you do get your money’s worth back in entertainment (some people tried to finish the game as fast as possible and the fastest speedrun of 100% completion took already 49 hours). And inversely I’m not sure buying a Switch without Zelda is worth it, unless you are a fan of Mario (I like Mario + Rabbids Kingdom Battles). The non-exclusive games on the Switch tend to be older and overpriced. And the Switch’s famous “mobile” mode is somewhat hampered by low battery life.

What makes Zelda such a great exploration game is the absence of any invisible walls. If you see something ahead of you, you can get there. It might need a bunch of stamina food to get to the top of the highest mountain or building, but you can get there. And there is probably a reward too for getting there. The terrain isn’t just there to walk or climb on it, it often has tricks to deal with the local monster population: You can roll down a boulder into the bokoblin camp to crush them, or explode their camp by throwing a bomb barrel in their camp fire or set grass on fire. You can open a drawbridge by shooting the ropes that hold it up with fire arrows.

The landscape never feels empty. Besides finding major stuff like the 120 shrines, you can also discover the 900 locations of Korok seeds, or the countless resources from mushrooms to ore. Interaction with your environment is fun because the game always goes a step beyond what you’d expect from other games: My niece tried to feed her horse a carrot and I was surprised to see that it worked! I was equally surprised to see that while I couldn’t kill chickens by hitting them with a sword, they did lay eggs when I did. Or got angry and called all their rooster friends that attacked me. 🙂

Another feature that makes Zelda a great game is how it handles difficulty. Don’t be fooled by the game’s colorful look, it can be quite challenging. You will die. Many times. But fortunately the game isn’t punishing death all that much. Which means that you’ll be back in the action and trying again in no time. And sometimes again. And again. Until you finally manage that challenging fight or puzzle, or you give up and decide to do something else first. And the game also constantly challenges your intelligence: Unless you look everything up on the internet, you need to figure out quite a lot of how the game works by yourself. Ultimately you end up having quite a lot of control over the level of challenge: Different zones have different monster difficulties, so you can go the easy way and do them in the right order or skip ahead to farm harder monsters for better weapons. You control the difficulty of puzzles by deciding how much help you want to get from sources like YouTube. And if the normal mode of the game is too easy for you, you can switch to the much harder master mode, which makes Dark Souls look like a game for wimps. If you want the game easier, you could also use Amiibos (haven’t tried those yet) to get various gear, or a horse, or a wolf pet.

In summary, Legend of Zelda: Breath of the Wild is a great game. It fully deserves its 97% Metacritic rating. The game doesn’t just play well, it also has far more handcrafted content than other open world games. Recommended!

Trump Diehards Take Over Taylor Swift’s New App, Instantly Start Spewing Hate

The pop star has come under fire for her refusal to condemn the so-called alt right.

Taylor Swift launched a new app for her loyal fans last week and within just two days, it was overrun by President Donald Trump’s fans to spread homophobia.

In a Tuesday report from the Daily Beast, screen captures of the app reveal the newly launched app, “The Swift Life,” was taken over by dogged Trump supporters.

Swift’s followers rushed to the app stores and by Monday it was among the top trending apps. It gave Swift fans a place on social media to see exclusive videos, use “Tay-mojis” and have their own Swift-centric newsfeed. But the most popular feature, which allows supporters to meet each other and chat, was possessed by right-wing trolls. Many Swift fans already know each other and have met on Facebook and Twitter. They’ve formed a collective of fans ready to respond to any criticism of their favorite star.

While the singer’s fans all had something in common with Swift, their political ideologies don’t mesh well. When conversation turned to politics, the fans started in on Trump and hate aimed at Hillary Clinton.

“Republicans and Trump supporters have just as much right to be here as everyone. There are people who voted for him or may vote Republican but didn’t vote for him. They may not agree with his beliefs but at least he supports our troops,” on fan wrote.

The comment spawned an argument in the comments section which quickly devolved into other Swift fans saying things like, “I just don’t accept gays lesbians and bisexuals,” Britt said.

Another comment from Britt claimed that her husband serving in the military was safer with Trump in office. Hillary has “done some things I don’t agree with when it comes to the safety of our troops… at the end of the day it came down to what I felt was best. There are people who voted for reasons other than Trump being a bigoted, sexist, homophobe,” she wrote in another post. The backlash was swift.

Those who love Swift and Trump quickly flocked to the defense of their kin on social media. They demanded their freedom of speech be recognized.

“I downloaded Tay’s app and before you start criticising me I’m a trump supporter (sic),” one fan tweeted. “I don’t see why people talk politics in there???? Like helloooooo let’s talk about our fav. We should support Taylor and I’m so disappointed she didn’t have one million downloads a minute.”

Britt ultimately deleted all of her posts about the president before writing, “Speak now and forever hold your peace. Not on TSL. Speak now here and everyone jumps down your throat.”

“You don’t get to use ‘free speech’ as an excuse to be rude and hateful,” another fan responded.

Rumors spread of political posts being deleted by moderators while international Swift fans blasted Americans for “ruining the app” and “distracting from Taylor.”

 

 

When a user logs into the app it demands users “help make this a safe and inclusive place for everyone to enjoy.” They’re encouraged to report content, saying, “see anything inappropriate, including instances of bullying or harassment, please report it.”

Swift made news when she refused to speak out against neo-Nazis and white supremacists in the so-called “alt-right.” She ultimately became the darling of the far-right movement, although Swift has tried to remain non-political. However, in 2016 Swift drew attacks from feminist supporters, who alleged that she was using feminist ideals to sell records while secretly supporting the anti-feminist candidate.

In a Yahoo interview with Swift friend Todrick Hall, Swift’s politics came up and he shut down the speculation she was a closet Trump supporter.

“Yeah, many people have been tweeting me, ‘She supports Trump! She probably voted for Trump!’” he said. “They’re making this huge assumption, when Taylor has never to my knowledge come out and said anything about her being pro-Trump.”

While he wouldn’t confess any inside information on whether Swift was a closet white supremacist, he said she has been “nothing but a great person to me,” as an gay African-American man.

“Her family has welcomed me into their home and treated me like I was a member of the family,” he said. “They’ve welcomed every single person I’ve ever brought around them. I’ve never felt like there was ever a moment that I couldn’t be myself, and talk about the fact that I’m gay or whatever.”

“Maybe one day, Taylor will start being super-political, and using her voice to do the things that people think that she should be doing,” he added. “But even then, she will probably be ridiculed for not being vocal enough, or not being on the right side.”

Left-leaning Swift fans attacked the pop star just last week after she claimed she “couldn’t have asked for a better year.” They allege the comment was “tone deaf” to the horrors many people of color faced in wake of the Trump presidency.

“I mean, yeah there were Nazi’s and white supremacy marches, and families are being torn apart, and there were mass shootings, and people are losing health care, but none of that affects me, so 2017 was great!” one person said on Twitter.

 

 

Related Stories

  • Paul Krugman: The GOP Is Completely, Hopelessly Corrupt
  • How Fox News Is Waging ‘Psychological Warfare’ on the American People
  • Trump Judicial Nominee Withdraws After GOP Senator Publicly Humiliates Him

Unsubscribed Humble Bundle Monthly

I recently subscribed to the Humble Bundle Monthly, because the $12 for the bundle included Civilization VI with two DLCs, which was way cheaper than any other way to pick up Civ VI. Now the rest of the bundle arrived, and I must say that I am disappointed. The idea of the Humble Bundle Monthly is that it is “curated”, giving you a bunch of good games. So I thought that in a curated bundle with Civilization VI I would find a few other nice strategy games. Unfortunately I was very wrong: The other games in the February bundle are all adventure games, and cheap ones at that.

To quote Steam when I open the page of one of those games: “Is this game relevant to you? This game doesn’t look like other things you’ve played in the past. As such we don’t have much information on whether or not you might be interested in it.”. Steam is right. Basically I haven’t played adventure games since way back when adventure games were still a thing, the days of Leisure Suit Larry or Monkey Island. I don’t really like the new generation of adventure games, which is often described as “walking simulators”. The only game in the Humble Bundle Monthly I might try is Snake Pass, because I’ve heard that it is somewhat unique with its controls, and not really an “adventure game”.

Another reason to unsubscribe was that the highlight of next month’s bundle is Dark Souls III plus one DLC. If you like the Dark Souls series, you might consider this, as $12 is an excellent price for something going for $75 on Steam. For me the unforgiving nature of the series has always turned me off. I don’t play games to get punished for my mistakes, I have a job for that!

What I did now is change my Humble Bundle e-mail settings to send me info on future Humble Bundle Monthly offers. (I had turned that off, which resulted in me not even getting informed that there was a bundle of games waiting for me.) Getting $60 games plus DLC for $12 is interesting. The rest of the bundles probably not so.

Common HTTP Errors

Every HTTP transaction has a status code sent back by the server to define how the server handled the transaction.
Apart from the 404 error, how many other HTML error pages do you know about? Have you ever thought about what happens in the background when you see any of these HTML error pages on your screen?
Those codes are meant to convey important information to the user. Using them properly reduces your bounce rate, improves your search engine ranking and gives you knowledge on the performance of your site.

Status Codes

Status codes come in the format of 3 digit numbers. The first digit marks the class of the status code:
1XX status codes have informational purposes
2XX indicates success
3XX is for redirection
None of these three classes result in an HTML error page as in this cases the client knows what to do and goes on with the task without hesitation. 

What we usually see are the 4XX and 5XX kind:

4XX represent client-side errors
5XX indicate problems on the server side
HTML error pages are displayed in these cases because the client has no idea about what how to move on.

Lets see some Client side and Server side HTTP error codes

Client Side Errors(4XX)

400 – Bad Request

Whenever the client sends a request the server is unable to understand, the 400 Bad Request error page shows up. It usually happens when the data sent by the browser doesn’t respect the rules of the HTTP protocol, so the web server is clueless about how to process a request containing a malformed syntax.

Open the same webpage in a different browser, clear the cache, and check if you are due with security updates. If you regularly meet the 400 error on different sites, your PC or Mac is awaiting a thorough security checkup.

401 – Authorization Required

When there’s a password-protected webpage behind the client’s request, the server responds with a 401 Authorization Required code. 401 doesn’t return a classical error message at once, but a popup that asks the user to provide a login-password combination.

403 – Forbidden

The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated.By returning the 403 status code the server basically rejects the client with a big loud “No” without any explanation.
The most common reason is that the website owner doesn’t permit visitors to browse the file directory structure of the site.

404 – Not Found


The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent.

408 – Request Time-Out

When the request of the client takes too long, the server times out, closes the connection, and the browser displays a 408 Request Time-Out error message. The time-out happens because the server didn’t receive a complete request from the client within the time frame it was prepared to wait.

410 – Gone

The requested resource is no longer available at the server and no forwarding address is known. This condition is expected to be considered permanent. Clients with link editing capabilities SHOULD delete references to the Request-URI after user approval.

If the server does not know, or has no facility to determine, whether or not the condition is permanent, the status code 404 Not Found SHOULD be used instead. This response is cacheable unless indicated otherwise. It’s a good idea to distinguish between 404 and 410 to enhance your Google-friendliness. 

Server Side Errors

500 – Internal Server Error

The server encountered an unexpected condition which prevented it from fulfilling the request.
If you encounter the 500 error page on your own site, it will be wise to contact your hosting provider. The reason is most likely a permission error, a corrupt .htaccess file or a too low memory limit.

502 – Bad Gateway

The 502 error message represents a communication problem between two servers. It occurs when the client connects to a server acting as a gateway or a proxy that needs to access an upstream server that provides additional service to it.

503 – Service Unavailable

Your web server is unable to handle your HTTP request at the time. There are a myriad of reasons why this can occur but the most common are:

  • server crash
  • server maintenance
  • server overload
  • server maliciously being attacked
  • a website has used up its allotted bandwidth
  • server may be forbidden to return the requested document
  • This is usually a temporary condition. Since you are getting a return code, part of the server is working. The web people have made the server return this code until they fix the problem.

If you do not get service back soon, contact your web host as they would know the best. Some web hosts have server status pages you can check.

504 – Gateway Time-Out

There is a server-server communication problem behind the Gateway Time-Out error message, just like behind the 502 Bad Gateway error code. When the 504 status code is returned there’s also a higher-level server in the background that is supposed to send data to the server that is connected to our client. In this case the lower-level server doesn’t receive a timely response from the upstream server it accessed.

Want to learn Web Programming?

The One Scenario in Which Trump Would Risk Impeachment and Fire Robert Mueller

The president reportedly expects to be exonerated soon.

President Donald Trump believes that special counsel Robert Mueller will soon send him a letter that completely exonerates him of any wrongdoing — but the president’s allies fear that such a letter will never come.

CNN reports that Trump has recently been boasting to allies that the Russia probe will be over very shortly, and that Mueller will personally exonerate him. The president believes this, CNN’s sources say, because his attorneys have tried to manage him by telling him that he faces no real danger from the probe.

However, some of the president’s allies believe this is delusional, wishful thinking — and they fear what Trump will do if that exoneration letter never comes.

One Trump ally tells CNN that the president will likely have a “meltdown” after months go by without an exoneration letter, after which “he’ll try and fire Mueller and then be impeached.”

Another Trump ally similarly warns that Trump’s lawyers are playing a dangerous game by buttering him up with happy talk about the Mueller probe ending shortly.

“I’ve known him long enough to know that disappointing him is a problem and they’ve built up a level of expectations for him that are unrealistic,” the source said. “[They’ve] lulled him into a false sense of security.”

 

 

Related Stories

  • MSNBC Shows Frightening Clip of Trump and Putin Using Exact Same Talking Points
  • MSNBC Shows Scary Clip of Trump and Putin Using Exact Same Talking Points
  • Fox News’ Jeanine Pirro Delivers Her Most Disturbing Monologue of Trump’s Presidency

Jared Kushner and Ivanka Trump Reportedly Face New Financial Disclosures Lawsuit

The couple allegedly made significant omissions on their disclosure forms.

President Donald Trump’s daughter Ivanka and his son-in-law Jared Kushner were hit with a new lawsuit on Sunday alleging they made significant omissions on their federal financial disclosure forms.

Politico reported Sunday night that Washington lawyer Jeffrey Lovitky filed a complaint in U.S. District Court in Washington alleging that the two White House aides neglected to share information about some 30 investment funds in which they are invested. They also are accused of hiding the value of two investment vehicles in which they’re involved as well as income derived from them.

A large number of the holdings Kushner did report, the complaint states, are not listed in full detail due to “prior confidentiality agreements.”

However, Lovitky’s complaint said these agreements do not apply under the Ethics in Government Act (EIGA).

“The [Ethics in Government Act] does not allow a reporting individual to refuse to disclose the underlying assets of an investment vehicle, on the basis that such disclosure would violate a pre-existing confidentiality agreement. Nor does the EIGA allow a reporting individual to refuse to disclose the amount of income derived from any underlying asset of an investment vehicle, on the basis that such disclosure would violate a pre-existing confidentiality agreement,” said the suit.

Politico’s Josh Gerstein described Lovitky as “a health care finance lawyer who sometimes files civil rights cases.” He filed a similar suit against Pres. Trump himself earlier this year.

Kushner and Ms. Trump have been hit with repeated accusations of hiding information from federal regulators including charges that they failed to disclose millions of dollars of art in their possession. Kushner has had to revise his reports of meetings with foreign operatives and Russian banking officials multiple times, adding “more than 100 names” to the list last July.

Read the full report here.

 

Related Stories

  • Trump Didn’t Invite a Single Jewish Democratic Congressperson to the White House Hanukkah Party
  • Ivanka Trump and Jared Kushner Engaged in ‘Unethical’ Helicopter Use: Report
  • Treasury Secretary Steve Mnuchin Seriously Claims Ignorance of CDC Banned Words Report

JSON – PHP : work BeaUtifuLLy




JSON or JavaScript Object Notation is a lightweight text-based open standard designed for human-readable data interchange. Conventions used by JSON are known to programmers, which include C, C++, Java, Python, Perl, etc.

  • JSON stands for JavaScript Object Notation.
  • The format was specified by Douglas Crockford.
  • It was designed for human-readable data interchange.
  • It has been extended from the JavaScript scripting language.
  • The filename extension is .json.
  • JSON Internet Media type is application/json.
  • The Uniform Type Identifier is public.json.

Uses of JSON

  • It is used while writing JavaScript based applications that includes browser extensions and websites.
  • JSON format is used for serializing and transmitting structured data over network connection.
  • It is primarily used to transmit data between a server and web applications.
  • Web services and APIs use JSON format to provide public data.
  • It can be used with modern programming languages.

Characteristics of JSON

  • JSON is easy to read and write.
  • It is a lightweight text-based interchange format.
  • JSON is language independent.

Why use JSON?

Since the JSON format is text only, it can easily be sent to and from a server, and used as a data format by any programming language.
JavaScript has a built in function to convert a string, written in JSON format, into native JavaScript objects:
JSON.parse()
So, if you receive data from a server, in JSON format, you can use it like any other JavaScript object.

JSON Syntax:

JSON syntax is derived from JavaScript object notation syntax:
  • Data is in name/value pairs
  • Data is separated by commas
  • Curly braces hold objects
  • Square brackets hold arrays
Below is a simple example −
{
"book": [

{
"language": "Java",
"creator": "James Gosling"
},

{
"language": "PHP",
"creatoR": "Rasmus Lerdorf"
}
]
}


JSON with PHP

Let’s see how to encode and decode JSON objects using PHP programming language.

JSON Functions

PHP has some built-in functions to handle JSON.

Encoding JSON in PHP (json_encode)

PHP json_encode() function is used for encoding JSON in PHP. This function returns the JSON representation of a value on success or FALSE on failure.
Syntax:
string json_encode ( $value [, $options = 0 ] )
Parameters
value − The value being encoded. This function only works with UTF-8 encoded data.
options − This optional value is a bitmask consisting of JSON_HEX_QUOT, JSON_HEX_TAG,         JSON_HEX_AMP, JSON_HEX_APOS, JSON_NUMERIC_CHECK, JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, JSON_FORCE_OBJECT.
Example

The following example shows how to convert an array into JSON with PHP −
php
$myObj->course = "Rocky Jagtiani";
$myObj->age = 39;
$myObj->city = "Chembur";

$Suven = json_encode($myObj);

echo $Suven;

?>
While executing, this will produce the following result −

{"name":"Rocky Jagtiani","age":39,"city":"Chembur"}

PHP Array:
Arrays in PHP will also be converted into JSON when using the PHP function json_encode():
php
$myArr = array("Java", "Web Technology", "Android", "Digital Marketing");

$myJSON = json_encode($myArr);

echo $myJSON;

?>
this will produce the following result −

["Java","Web Technology","Android","Digital Marketing"]

Decoding JSON in PHP (json_decode)
PHP json_decode() function is used for decoding JSON in PHP. This function returns the value decoded from json to appropriate PHP type.
Syntax
mixed json_decode ($json [,$assoc = false [, $depth = 512 [, $options = 0 ]]])

Paramaters
json_string − It is an encoded string which must be UTF-8 encoded data.
assoc − It is a boolean type parameter, when set to TRUE, returned objects will be converted into associative arrays.
depth − It is an integer type parameter which specifies recursion depth
options − It is an integer type bitmask of JSON decode, JSON_BIGINT_AS_STRING is supported.
Example:
The following example shows how PHP can be used to decode JSON objects −
php
$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';

var_dump(json_decode($json));
var_dump(json_decode($json, true));

?>
While executing, it will produce the following result −
object(stdClass)#1 (5) {
["a"] => int(1)
["b"] => int(2)
["c"] => int(3)
["d"] => int(4)
["e"] => int(5)
}

array(5) {
["a"] => int(1)
["b"] => int(2)
["c"] => int(3)
["d"] => int(4)
["e"] => int(5)
}

Error-Handling and Testing

If the JSON value could not be parsed or a nesting level deeper than the given (or default) depth is found, NULL is returned from json_decode. This means that no exception is raised by json_encode/json_deocde directly.
So how can we identify the cause of the error? The json_last_error function helps here. json_last_error returns an integer error code that can be one of the following constants (taken from here):
JSON_ERROR_NONE: No error has occurred.
JSON_ERROR_DEPTH: The maximum stack depth has been exceeded.
JSON_ERROR_STATE_MISMATCH: Invalid or malformed JSON.
JSON_ERROR_CTRL_CHAR: Control character error, possibly incorrectly encoded.
JSON_ERROR_SYNTAX: Syntax error.
JSON_ERROR_UTF8: Malformed UTF-8 characters, possibly incorrectly encoded (since PHP 5.3.3).

Want to Learn Web Technologies?

How Data Science Has Changed Everyday Life for the Better

data science


Data science is the study of where information comes from, what it represents and how it can be turned into a valuable resource in the creation of business and IT strategies. Mining large amounts of structured and unstructured data to identify patterns can help an organization rein in costs, increase efficiencies, recognize new market opportunities and increase the organization’s competitive advantage. Some companies are hiring data scientists to help them turn raw data into information.
Data scientists must possess a combination of analytic, machine learning, data mining and statistical skills as well as experience with algorithms and coding.

Application of Data Science

Here’s how Data Science comes to our rescue in our everyday routine.

Recommender Systems

recommendation systems


Who can forget the suggestions about similar products on Amazon? They not only help you find relevant products from billions of products available with them, but also adds a lot to the user experience. The recommendations are made based on previous search results for a user.

Internet Search

internet search

Search engines make use of data science algorithms to provide the best search result for searched query in fraction of seconds. Considering the fact that, Google processes more than 20 petabytes of data everyday. Had there been no data science, Google wouldn’t have been the ‘Google’ we know today.

Healthcare

Today fitness trackers and apps already help people lead a life that is more active, eat healthier and control their weight – and this is only the beginning. Already such devices monitor heart rate, sleep patterns and other vital signs that can be interpreted to serve other healthcare purposes and provide a diagnosis. The best cure is prevention, and with big data science, everyone will be able to keep their health in check.

Logistics

Logistic companies like DHL, FedEx, UPS, Kuhne+Nagel have used data science to improve their operational efficiency. Using data science, these companies have discovered the best routes to ship, the best suited time to deliver, the best mode of transport to choose thus leading to cost efficiency, and many more to mention. Further more, the data that these companies generate using the GPS installed, provides them a lots of possibilities to explore using data science.
Airlines schedule flights, predict delays based on precise weather forecasts and estimate the number of seats they are going to need for each direction based on seasonal fluctuations, competitors’ actions, latest social trends or political events. There are also mechanisms that allow them to decide on the class of planes they will need to purchase in the future.

Image Recognition

Today face recognition is not that big a deal. It offers you to tag your friends on social media photos; it enables goofy masks in Snapchat, Instagram and webcam programs. Lots of fun and nothing substantially useful. However, this can be a powerful tool of law enforcement in the future. Already this feature is making its way into security systems – in flagship models of modern smartphone, you may choose face recognition to unlock your device. In future, it can be used to identify suspects and find missing persons.

Data science and Python

Why Python is usful for Data Science? Python is a powerful, flexible, open source language that is easy to learn, easy to use, and has powerful libraries for data manipulation and analysis. Its simple syntax is very accessible to programming novices, and will look familiar to anyone with experience in Matlab, C/C++, Java, or Visual Basic. Python has a unique combination of being both a capable general-purpose programming language as well as being easy to use for analytical and quantitative computing.
python and data science
Python is easy for analysts to learn and use, but powerful enough to tackle even the most difficult problems in virtually any domain. It integrates well with existing IT infrastructure, and is very platform independent. Among modern languages, its agility and the productivity of Python-based solutions is legendary. Companies of all sizes and in all areas — from the biggest investment banks to the smallest social/mobile web app startups — are using Python to run their business and manage their data.

Because of growing importance and scope of data science, many are opting for business analytics and data science certification courses. Data Science is changing the world, and if you are passionate about this fascinating discipline, then this is the time to enroll yourself in a data science course.

Want to learn Python Programming?