Understanding Synchronous and Asynchronous JavaScript – paRt_2: JavaScript – its DiFFereNt


In the first part of this post, we saw how the concepts of synchronous and asynchronous are perceived in JavaScript. In this second part, Mr K appears again to help us understand how the setTimeout() and AJAX APIs work.


Let’s go back in past to the story of Mr. K and the date you wanted to go on! but what if you leave a task for Mr. K before outing and tell him that he can only begin to work on this task five hours after he got your message. 
He isn’t happy about it! But why does Mr H leave a message in the queue instead of directly contacting Mr K? Because as I mentioned in the first part, the only way to contact Mr K is by leaving a message to him via phone call — no exceptions., remember, he doesn’t take a new message until he is done with the current one, and if he takes yours, he has to wait for five hours to even start on the task. So, to not be wasteful of time, he brings in a helper, Mr H.
Instead of waiting, he asks Mr H to leave a new message for the task in the queue after the given hours had passed, and moves on to the next message.
Five hours past; Mr H updates the queue with a new message. After he’s done processing all the accrued messages prior to Mr H’s, Mr K carries out your requested task. So, this way, you can leave a request to be complied upon at a later time, and not wait until it’s fulfilled.

1:-> The setTimeout() method

Suppose you have a set of code that you want to execute after a certain time. In order to do that, you just wrap it in a function, and add it to a setTimeout() method along with the delay time. The syntax of setTimeout() is as follows:
  • setTimeout(function, delay-time, arg…)
The arg… parameter stands for any argument the function takes, and delay-time is to be added in milliseconds. Below you can see a simple code example, that outputs “hey” in the console after 3 seconds.
  • setTimeout( function() { console.log(‘hey’) }, 3000 );
Once setTimeout() starts running, instead of blocking the call stack until the indicated delay time is over, a timer is triggered, and the call stack is gradually emptied for the next message (similarly to the correspondence between Mr K and Mr H).
When the timer expires, a new message joins the queue, and the event loop picks it up when the call stack is free after processing all the messages before it — thus the code runs asynchronously.

JavaScript call stack with timer
JavaScript call stack with timer

2:-> AJAX

AJAX (Asynchronous JavaScript and XML) is a concept that uses the XMLHttpRequest (XHR) API to make server requests and handle the responses.
When browsers make server requests without using XMLHttpRequest, the page refreshes and reloads its UI. When the processing of requests and responses are handled by the XHR API, and UI remains unaffected.

XMLHttpRequest we API
XMLHttpRequest we API

XMLHttpRequest Web API

Now, where is the “asynchronous” in this! Just using XHR code doesn’t mean it’s AJAX, because the XHR API can work in both synchronous and asynchronous ways.
XHR by default is set to work asynchronously; when a function makes a request using XHR, it returns without waiting for the response.
If XHR is configured to be synchronous, then the function waits until the response is received and processed before returning.

Code Example 1

This example presents an XMLHttpRequest object creation. The open() method, validates the request URL, and the send() method sends the request.

Asynchronous XHR

var xhr = new XMLHttpRequest();
xhr.open(“GET”, url);
xhr.send();
Any direct access to the response data after send() will be in vain, because send() doesn’t wait until the request is completed. Remember, XMLHTTPRequest is set to work asynchronously by default.

Code Example 2

The hello.txt file in this example is a simple text file containing the text ‘hello’. The response property of XHR is invalid, since it didn’t output the text ‘hello’.

Asynchronous XHR

var xhr = new XMLHttpRequest();
xhr.open(“GET”, “hello.txt”);
xhr.send();
document.write(xhr.response); // empty string
XHR implements a micro-routine that keeps checking for response in every millisecond, and triggers complimentary events for the different states a request goes through. When the response is loaded, a load event is triggered by XHR, which can deliver a valid response.

Asynchronous XHR

var xhr = new XMLHttpRequest();
xhr.open(“GET”, “hello.txt”);
xhr.send();
xhr.onload = function(){ document.write(this.response) } // writes ‘hello’ to the document
The response inside the load event outputs ‘hello’, the correct text.
Going the asynchronous way is preferred, as it doesn’t block other scripts until the request is completed.
If the response has to be processed synchronously, we pass false as the last argument of open, which flags the XHR API saying it has to be synchronous.

Synchronous XHR

var xhr = new XMLHttpRequest();
xhr.open(“GET”, “hello.txt”, false);
xhr.send();
document.write(xhr.response); // writes ‘hello’ to document

Conculsion

If you know how the puzzle fits, you can avoid confusion of stTimeout() and AJAX requests. You know that the delay time in setTimeout() does not indicate the time when the code execution starts, but the time when the timer expires and a new message is queued, which will only be processed when the call stack is free to do so.

Learn WebTechnology with Us!

Anthony Scaramucci Publicly Blasts ‘Loser’ Steve Bannon During Hannukah Party Remarks

The speech was supposed to be about his pilgrimage to Israel.

On Tuesday, short-lived White House Communications Director Anthony Scaramucci took a jab at fellow ex-Trump aide Steve Bannon at a New York Hannukah party.

As the New York Post‘s Page Six reports, The Mooch blasted Bannon as a “messianic loser” at Rabbi Shmuley Boteach’s annual Hannukah party on the second-to-last night of Jewish holiday.

As Page Six notes, Scaramucci was at Rabbi Boteach’s party to discuss his recent trip to Israel — and was also the subject of a recent controversy after his “Scaramucci Post” Twitter account published a controversial tweet poll asking how many people died in the Holocaust.

“He’s a loser,” Scaramucci reportedly said. “He’ll be a stalwart defender of Israel until he’s not. That’s how this guy operates. I’ve seen this guy operate.”

“The problem with Bannon is he’s a messianic figure,” he added. “It’s his way or the highway.”

Scaramucci also once again brought up “leakers,” the ostensible subject of his rant to a New Yorker writer over the summer that likely led to his ouster a mere 10 days after taking his press secretary job. At the Hannukah party, The Mooch accused Bannon of “leaking on everybody” in the White House.

“I’m not Steve Bannon,” Scaramucci told The New Yorker‘s Ryan Lizza in July. “I’m not trying to suck my own c*ck.”

 

Related Stories

  • How Fox News Is Waging ‘Psychological Warfare’ on the American People
  • Trump Judicial Nominee Withdraws After GOP Senator Publicly Humiliates Him
  • Steve Bannon Failed to Disclose That He’s $2 Million in Debt: Report

John Kelly Reportedly Working Toward Bipartisan DREAMers Solution

He attended a meeting with senators from both parties.

White House Chief of Staff John Kelly was seen on Capitol Hill Tuesday as part of the Trump administration’s push to reach a bipartisan solution for the Deferred Action for Childhood Arrivals program.

As Politico reports, Kelly attended a meeting with close to a dozen senators from both sides of the aisle and assured them that the White House “will soon present a list of border security and other policy changes it wants as part of a broader deal” for DACA recipients, also known as DREAMers.

“We couldn’t finish this product, this bill, until we knew where the administration was,” Sen. Jeff Flake (R-AZ), one of the senators working on the compromise, told Politico. “And that’s why this meeting was so important.”

Though senators who left the meeting said Kelly insisted the president’s terms may be released in a matter of days, Senate Majority Leader Mitch McConnell (R-KY) said the upper chamber would not vote on DACA before they break for the holidays this Friday.

“That’s a matter to be discussed next year,” McConnell said in an interview with Fox News earlier on Tuesday.

 

Related Stories

  • Is Trump an ‘Aspiring Despot’ or a ‘Bumbling Showman’? Why Not Both?
  • Paul Krugman: The GOP Is Completely, Hopelessly Corrupt
  • Trump Judicial Nominee Withdraws After GOP Senator Publicly Humiliates Him

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? 

Latest Razer Phone update delivers camera and audio improvements

We noted in our Razer Phone review that the photography performance was garbage. The 12 MP dual camera itself was adequate, but it was let down by poor processing, slow shutter speeds, and weak colors. Thankfully, Razer vowed to address some of these camera problems via software updates last month, and today we’ve come across one such OTA.

As reported by GSMArena, Razer is now rolling out a ~97 MB update which brings fixes several welcome improvements to the camera and audio technologies — check out the patch notes below.

Camera improvements:

  • Improved shutter speed in low light and when using HDR
  • Reduced noise and clearer shadows
  • Improved picture quality and better color cast
  • Crushed bugs and performance improvements

Audio improvements:

  • “Tweaked the knobs” for greater clarity during playback
  • Improved call quality for HD Audio
  • Fixed some issues with Dolby Audio

Meanwhile, Razer also lists a “smoothed out” auto-brightness luminosity, updated “Arrival theme icons to a dark style,” and other bug fixes in its list of optimizations. The handset remains on Android 7.1.1 Nougat for the time being, however, with the October security level.

These are much-needed improvements for the Razer Phone, and though we can’t yet attest to the effectiveness of this latest patch (we haven’t seen the update ourselves and it’s not clear which regions it’s currently rolling out in), we’ll be sure to investigate the situation once we do.

What are your thoughts on the Razer Phone? Is it worth the money? Let us know in the comments.

Hascon

Today Hascon 2017 starts, the convention of Hasbro, one of the world’s largest toy and board game makers. Obviously gamers have little interest in the latest news on My Little Pony or Monopoly, but as Hasbro bought Wizards of the Coast, who previously bought TSR, Hasbro controls two of the biggest names in tabletop gaming: Dungeons & Dragons and Magic the Gathering. But the one reason I am interested in Hascon is the promised reveal of “Magic Digital Next”, the next generation platform for playing Magic the Gathering electronically.

Right now Magic Digital Next doesn’t have a lot of goodwill from the community. Too much went wrong or was badly handled with the previous incarnations like Magic the Gathering Online or Magic Duels. Personally I am still quite angry that Hasbro dropped Magic Duels like a hot potato in June. They should have waited with that until Magic Digital Next is actually available, not 3 months before we get to see the first playable alpha version at a convention. I am also unhappy that they didn’t even make the slightest effort to bring Magic Duels in a state where it would still be viable to play until Magic Digital Next is released. Instead they left it as it was after they added the Amonkhet expansion, so the computer is only ever playing decks around that expansion instead of using decks from all previous expansions. And more than half of the daily quests are still for online multiplayer only, which is a problem when players leave an abandoned game and the remaining players can’t find matches any more.

Then there is of course the issue of “virtual property”. Previous versions of electronic Magic sold you virtual boosters of cards. If you are forced to switch to a new product, you lose your virtual card collection of the previous versions and have to start over. Legally of course you never really owned those electronic Magic cards. But players don’t feel like that, especially with platforms like MtGO where cards can be traded with other players for real money. I liked Magic Duels because it altered the rules of how many rare and legendary cards you can use, which made building up a full collection much more affordable. I doubt the next version will have that feature.

I am still on the fence about Magic Digital Next (I assume they’ll announce another name for it this weekend). I left MtGO long ago because it was too PvP-centric for me, which resulted in an environment full of card sharks, scams, and toxic players. I mostly used the PvE part of Magic Duels, which for me was probably the best incarnation of Magic on a tablet. So my appreciation of Magic Digital Next will mostly depend on whether it supports more than a token AI and PvE play. These days far too many game developers have become extremely lazy, and beyond a tutorial make their games mostly PvP, basically using their customers as content for other customers. As they never solved even the basic problems of that approach for virtual cardgames, like stalling or quitting at the first sign of trouble, I wouldn’t be interested in a PvP version of electronic Magic the Gathering.

[EDIT: The new name is Magic the Gathering Arena, more info here.]

Trump Is Really Trying to Set the World on Fire

And the whole world burns.

“I’ve just heard that my family home near Carpenteria is literally in flames at this moment,” a friend told me recently. She was particularly worried, she said, because “my mom has MS. She and my dad got the call to evacuate after midnight last night. They were able to grab a few photos, my sister’s childhood teddy bear, and the dog. That’s it. That’s all that’s left.”

My friend’s parents are among the thousands of victims of the 240,000-acre Thomas fire, one of California’s spate of late-season wildfires. Stoked by 80-mile-an-hour Santa Ana winds, plenty of dry fuel, and 8% humidity, such fires are devouring huge swaths of southern California from Los Angeles to Santa Barbara. Months of dry weather and unseasonably warm temperatures have turned the southern part of the state into a tinderbox.

Once again the country watches in horror as firefighters struggle to contain blazes of historic voracity — as we watched only a couple of months ago when at least 250 wildfires spread across the counties north of San Francisco. Even after long-awaited rains brought by an El Niño winter earlier in 2017, years of drought have left my state ready to explode in flames on an increasingly warming planet. All it takes is a spark.

Sort of like the whole world in the age of Donald Trump.

Torching Jerusalem

The crazy comes so fast and furious these days, it’s easy to forget some of the smaller brushfires — like the one President Trump lit at the end of November when he retweeted three false and “inflammatory” videos about Muslims that he found on the Twitter feed of the leader of a British ultra-nationalist group.

The president’s next move in the international arena — his “recognition” of Jerusalem as the capital of the state of Israel — hasn’t yet slipped from memory, in part because of the outrage it evoked around the world. As Moustafa Bayoumi, acclaimed author of How Does It Feel to be a Problem? Being Young and Arab in America, wrote in the Guardian, “The entire Middle East, from Palestine to Yemen, appears set to burst into flames after this week.” Not surprisingly, his prediction has already begun to come true with demonstrations in the West Bank, Gaza, and Lebanon, where U.S. flags and posters of President Trump were set alight. We’ve also seen the first rockets fired from Gaza into Israel and the predictable reprisal Israeli air attacks.

Trump’s Jerusalem announcement comes as his son-in-law, Jared Kushner, pursues his so-called Middle East peace initiative. Kushner’s new BFF is Mohammed bin Salman, the heir apparent to the Saudi throne. We don’t know just what the two of them talked about during a late night tête-à-tête as October ended, but it probably involved Salman’s plans to jail hundreds of prominent Saudis, including 11 fellow princes. They undoubtedly also discussed a new, incendiary Israeli-Palestinian “peace plan” that the U.S. and Saudi Arabia are reportedly quietly circulating.

Under this proposal, according to the New York Times, “The Palestinians would get a state of their own but only noncontiguous parts of the West Bank and only limited sovereignty over their own territory. The vast majority of Israeli settlements in the West Bank, which most of the world considers illegal, would remain. The Palestinians would not be given East Jerusalem as their capital and there would be no right of return for Palestinian refugees and their descendants.”

If this is the “deal of the century” that President Trump plans to roll out, then it’s no surprise that he’d prepare the way by announcing his plans to move the U.S. embassy to Jerusalem.

That move reveals a lot about Trump’s much vaunted deal-making skills when it comes to the international arena.  Here he has made a major concession to Israel without receiving a thing in return, except words of praise from Prime Minister Benjamin Netanyahu (and from evangelicals in this country). Given that Israel came into possession of the eastern half of Jerusalem through military conquest in 1967, a method of acquiring territory that international law views as illegal, it was quite a concession. The ultimate status of Jersalem is supposed to be a subject for the final stage of Palestinian-Israeli negotiations, not a gift to one side before the talks even begin.

Behind this concession, as far as can be seen, lies no strategic intent of any sort, not in the Middle East at least. In fact, President Trump was perfectly clear about just why he was making the announcement: to distinguish himself from his predecessors. (That is, to make himself feel good.) “While previous presidents have made [moving the U.S. embassy to Jerusalem] a major campaign promise, they failed to deliver. Today, I am delivering.”

“Some say,” he added, that his predecessors failed because “they lacked courage.” In point of fact, Trump did not exactly “deliver” either. Just like his predecessors, he promptly signed a semi-annual waiver that once again delayed the actual embassy move for six months.

Pyromania?

Rather than serving a larger Middle East strategy, Trump’s Jerusalem announcement served mainly his own ego. It gave him the usual warm bath of adulation from his base and another burst of the pleasure he derives from seeing his name in the headlines.

In his daily behavior, in fact, Trump acts less like a shrewd dealmaker than a child with pyromania, one who relieves anxiety and draws attention by starting fires. How else to explain his tendency every time there’s a lull in the coverage of him, to post something incendiary on Twitter? Each time, just imagine him striking another match, lighting another fuse, and then sitting back to watch the pyrotechnics.

Here is the grim reality of this American moment: whoever has access to the president also has a good shot at pointing this human flamethrower wherever he or she chooses, whether at “Little Rocket Man” in North Korea or Doug Jones in Alabama (although that flame turned out to be, as they British say, a damp squib).
The Middle East has hardly been the only part of the world our president has taken visible pleasure in threatening to send up in flames. Consider the situation on the Korean peninsula, which remains the greatest danger the world faces today. Who could forget the way he stoked the already glowing embers of the Korean crisis in August by threatening to rain “fire and fury like the world has never seen” — an obvious nuclear reference — on North Korea? And ever since it’s only gotten worse.  In recent weeks, for instance, not only Trump but his coterie have continued to ramp up the rhetoric against that country. Earlier this month, for instance, National Security Adviser General H.R. McMaster renewed the threat of military action, saying ominously, “There are ways to address this problem short of armed conflict, but it is a race because [North Korean leader Kim Jong-un]’s getting closer and closer [to having a nuclear capacity to hit the United States], and there’s not much time left.”

In September, Trump’s ambassador to the United Nations, Nikki Haley, reinforced this message in an interview with CNN. “If North Korea keeps on with this reckless behavior, if the United States has to defend itself or defend its allies in any way, North Korea will be destroyed.”

Indeed, Vipin Narang, a nuclear nonproliferation specialist at MIT, thinks the Trump administration may already have accepted the inevitability of such a war and the near-guarantee that South Korea and Japan will be devastated as well — as long as it comes before North Korea can effectively launch a nuclear strike on the U.S. mainland. “There are a lot of people who argue that there’s still a window to stop North Korea from getting an ICBM with a nuclear warhead to use against the United States,” he commented to the Washington Post. “They’re telling themselves that if they strike now, worst-case scenario: only Japan and South Korea will eat a nuclear weapon.”

You don’t exactly have to be an admirer of Kim Jong-un and his sad outcast regime to imagine why he might be reluctant to relinquish his nuclear arsenal. North Korea remains the designated U.S. enemy in a war that, almost seven decades later, has never officially ended. It’s situated on a peninsula where the most powerful nation in the world holds military exercises twice a year. And Kim has had ample opportunity to observe how Washington has treated other leaders (Saddam Hussein and Muammar Gaddafi) who gave up their nuclear programs. Certainly, threats of fire and fury are not going to make him surrender his arsenal, but they may still make Donald Trump feel like a real commander-in-chief.

Home Fires Burning

It’s not only in the international arena that Trump’s been burning things up. He’s failed — for now — to destroy the Affordable Care Act (though not for lack of striking matches), but the GOP has successfully aimed the Trump flamethrower at any vestiges of progressive taxation at the federal level. And now that the House and Senate are close to reconciling their versions of tax legislation, the Republicans have made it clear just why they’re so delighted to pass a bill that will increase the deficit by $1.5 trillion dollars. It gives them a “reason” to put to flames what still remains of President Franklin Roosevelt’s New Deal of the 1930s and President Lyndon Johnson’s Great Society of the 1960s.

House Speaker Paul Ryan gave a vivid sense of where that presidential flamethrower could be aimed soon when he told radio host Ross Kaminsky, “We’re going to have to get back next year at entitlement reform, which is how you tackle the debt and the deficit.” The goal? Cutting appropriations for Medicare and Medicaid, programs shepherded through Congress in the mid-1960s by Lyndon Johnson. These achievements helped realize his vision of the United States as a Great Society, one that provides for the basic needs of all its citizens.

Meanwhile, when it comes to setting the American social environment on fire, President Trump has already announced his post-tax-bill target du jour: welfare “reform.”
Welfare reform? Not a subject he even mentioned on the campaign trail in 2016, but different people are aiming that flamethrower now. The Hill reports the scene as Trump talked to a group of lawmakers in the Capitol basement:

“Ticking through a number of upcoming legislative priorities, Trump briefly mentioned welfare reform, sources in the room said.

“‘We need to do that. I want to do that,’ Trump told rank-and-file lawmakers in a conference room in the basement of the Capitol. The welfare line got a big applause, with one lawmaker describing it as an ‘off-the-charts’ reception.”

We know that getting “big applause” guarantees that a Trump line will also get repeated.

At a time when “entitlement” has become a dirty word, we’d do well to remember that not so long ago it wasn’t crazy to think that the government existed to help people do collectively what they couldn’t do as individuals. As a friend said to me recently, taxes are a more organized way of crowd-funding human needs.

Who even remembers that ancient time when candidate Trump, not yet an arsonist on the home front, promised to protect Medicare, Medicaid, and Social Security? President Trump is a different matter.

It seems likely, however, that at least for now the Republicans won’t push him on Social Security because, as Paul Ryan told the Washington Post’s “Wonkblog,” the Republicans don’t have enough votes to overcome a Senate filibuster and the program is too popular back home for a super-majority of Republicans to go after it.
Why can they pass a tax “reform” bill with only a simple majority, but not Social Security cuts? The tax bill is being rushed through Congress using the “reconciliation” process by which differences in the Senate and House versions are smoothed over to produce a single bill.  This only requires a simple majority to pass in each house. The Senate’s “Byrd Rule,” adopted in 1974, prohibits the use of the reconciliation process to make changes to Social Security. Thank you, former West Virginia senator Robert Byrd!

In addition to the programs that made up Johnson’s “War on Poverty,” he also signed the 1964 Civil Rights Act and the 1965 Voting Rights Act. Trump’s Presidential Advisory Commission on Election Integrity is already hard at work setting fire to the latter, as the president continues to demand evidence for his absurd claim that he won the popular vote in the 2016 election. He must be having an effect. At least half of all Republicans now seem to believe that he indeed did win that vote.

And before we leave the subject, just a couple of final notes on literal fires in the Trump era. His Department of Transportation has been quietly at work making those more likely, too. In a move supported by fans of train fires everywhere, that department has quietly reversed an Obama-era rule requiring that trains carrying crude oil deploy, as Reuters reports, “an advanced braking system designed to prevent fiery derailments… The requirement to install so-called electronically controlled pneumatic (ECP) brakes was included in a package of safety reforms unveiled by the Obama administration in 2015 in response to a series of deadly derailments that grew out of the U.S. shale boom.”

Government data shows there have been 17 such derailments of trains carrying crude oil or ethanol in the U.S. since 2006.
Then there’s the fire that has probably destroyed my friend’s house in southern California even as I wrote this. Donald Trump can hardly be blamed for that one. The climate in this part of the world has already grown hotter and drier.  We can certainly blame him, however, for turning up the heat on planet Earth by announcing plans to pull the United States out of the 2015 Paris agreement on climate change, overseeing the slashing of tax incentives for alternative energy (amid a bonanza of favors for the fossil fuel industry), and working to assert an oil, gas, and coal version of American “energy dominance” globally.  From the world’s leading economic power, there may be no larger “match” on the planet.  

A Flame of Hope

What hope is there of quenching the Trumpian fires?

There is the fact that much of the world is standing up to him. At this month’s climate accord follow-up meeting in Paris, billionaires Bill Gates and Richard Branson announced “a dozen international projects emerging from the summit that will inject money into efforts to curb climate change.” The head of the World Bank insisted that the institution would stop funding fossil fuel programs within the next two years. Former American officials spoke up, too, as U.S. News & World Report observed:
“One by one, officials including former California Gov. Arnold Schwarzenegger, billionaire [and former New York City mayor] Michael Bloomberg, and former U.S. Secretary of State John Kerry insisted the world will shift to cleaner fuels and reduce emissions regardless of whether the Trump administration pitches in.

I take comfort, too, in the extraordinary achievements of international civil society. Consider, for example, the work of the International Campaign to Abolish Nuclear Weapons (ICAN), this year’s recipient of the Nobel Peace Prize. This summer, as a result of a campaign it led, two-thirds of the world’s nations — 122 of them — signed the Treaty on the Prohibition of Nuclear Weapons, which outlaws the use, production, and possession of nuclear arms. That treaty — and the Nobel that rewarded its organizers — didn’t get a lot of coverage in the United States, perhaps because, predictably, we didn’t sign it.

In fact, none of the existing nuclear powers signed it, but the treaty remains significant nonetheless. We should not underestimate the moral power of international agreements like this one. Few of us remember the 1928 Kellogg-Briand pact, which outlawed recourse to war for the resolution of international disputes. Nevertheless, that treaty formed the basis for the conviction of Nazi war criminals at Nuremberg for their crimes against peace. By implication, the Kellogg-Briand treaty also legalized a whole set of non-military actions nations can now take, including the use of economic sanctions against countries that violate international norms or laws.

ICAN leaders Beatrice Fihn and Setsuko Thurlow (herself a Hiroshima survivor) believe that, over time, the treaty will change how the world thinks about nuclear weapons, transforming them from a necessary evil to an unthinkable one, and so will ultimately lead to their elimination. As Fihn told the BBC’s Stephen Sackur, “If you’re uncomfortable with nuclear weapons under Donald Trump, you’re probably uncomfortable with nuclear weapons” in general. In other words, the idea of Trump’s tiny fingers on the nuclear trigger is enough to start a person wondering whether anybody’s fingers should be on that trigger.

The world’s reaction in Paris and ICAN’s passionate, rational belief in the moral power of international law are like a cool drink of water on a very hot day.
 

 

Related Stories

  • Here’s How Trump Is Pitting Local Police Against the FBI
  • Unbelievable Censorship: Trump Bans CDC from Using These 7 Words
  • Why Even the Idea That Neocon Senator Tom Cotton Might Run Trump’s CIA Is Scary

Comparing Bootstrap With Google’s Material Design Lite : Bootstrap – ResponSive Design

Bootstrap vs Materialize

What is Materialize and Bootstrap?


Both Google’s Materialize and Twitter’s Bootstrap are front end CSS frameworks for webpages. Both are open source. In the question“What is the best CSS framework?” Bootstrap is ranked 1st while Materialize is ranked 5th. The most important reason people chose Bootstrap is:
Bootstrap is developed to be instantly compatible with all sizes of screens, so you don’t have to worry about which device the user is accessing your site from. Yet if you prefer, you can disable responsiveness of Bootstrap.

Bootstrap:

Bootstrap is a free and open-source front-end web framework for designing websites and web applications. It contains HTML and CSS-based design templates for typography, forms, buttons, navigation and other interface components, as well as optional JavaScript extensions. Unlike many web frameworks, it concerns itself with front-end development only.


Materialize:

Created and designed by Google, Material Design is a design language that combines the classic principles of successful design along with innovation and technology. Google’s goal is to develop a system of design that allows for a unified user experience across all their products on any platform.


Major Differences!

Philosophy

  • Bootstrap was originally built by Twitter with the purpose of making it easy to build responsive websites. It gives you a lot of components and customization options for making web apps.
  • Material Design Lite is a way for Google to spread its material design concept to the web. It gives you only the base building blocks for building material apps. The rest is up to the developer.

Development Experience

  • Bootstrap has a very detailed documentation. Development involves copy pasting from the examples and getting a usable result fast.
  • MDL is built around BEM, and components are built by combining multiple classes. This approach gives a great deal of control, but can sometimes lead to unwieldy HTML.

Components

  • In Bootstrap, almost all built-in HTML elements are styled and can fit nicely together in a layout. It gives you a great number of additional components for any type of design.
  • MDL gives you fewer components than Bootstrap, but they are all focused on building modern Material Design applications. They come with animations and beautiful default styles.

Layout

  • Bootstrap has an advanced grid system with offsets, column wrapping, hiding and reordering of columns.
  • MDL has a more primitive grid that gets the job done most of the time, but doesn’t support advanced features.

Design

  • Bootstrap gives you a passable default design which we have grown tired of by now, but there are plenty of wonderful themes to chose from.
  • MDL looks fresh and features bold colors and animations. It dictates exactly how your web app should look like and gives you a limited opportunity for customization by choosing base and accent colors.

Community

  • Bootstrap has been around for quite some time and has an enormous community, which produces themes, plugins and blog posts.
  • MDL came out only recently but has already become quite popular on GitHub. However it is still in its early days, and most of the time you are on your own.

Interest Over Time

    trends.embed.renderExploreWidget(“TIMESERIES”, {“comparisonItem”:[{“keyword”:”Bootstrap”,”geo”:””,”time”:”2004-01-01 2017-06-12″},{“keyword”:”Materialize”,”geo”:””,”time”:”2004-01-01 2017-06-12″}],”category”:0,”property”:””}, {“exploreQuery”:”date=all&q=Bootstrap,Materialize”,”guestPath”:”https://trends.google.com:443/trends/embed/”});

    < 1 > Grid 

    Grid is the most important part of the framework as it makes the webpage responsive for all devices. 
    • The Bootstrap grid splits the page into 12 equally sized columns. Depending on the viewport width, four different size classes are applied – extra small (from 0 to 768px wide), small (768px to 992px), medium (992px to 1200px), and large (1200px+).
    • MDL has a similar grid system, but it only has three sizes – phone (0 to 480px), tablet (480px to 840px) and desktop (840px+). MDL desktop has 12 columns, tablet has 8 columns and phone has only 4 columns.
    comparison between materialize and bootstrap
    Grid system in Bootstrap and MDL
    comparison between materialize and bootstrap
    Grid changes in Bootstrap 
    comparison between materialize and bootstrap
    Grid changes in MDL

      Docs: Bootstrap Grid | MDL Grid
      Learn Bootstrap’s Grid system

      < 2 > Header Navigation

      Headers in Bootstrap are called Navbars. They begin collapsed in mobile views and become horizontal when there is enough space for them. Inside, you can nest an array of different elements that can be positioned with the help of classes.

      Similarly, MDL header navigations start off collapsed behind a hamburger menu and expand with the growth of the viewport. They too have different stylings and possible positions.

      Header navigation bars in Bootstrap and MDL

      Bootstrap’s collapsible menu
      A hamburger menu in MDL

      Docs: Bootstrap Navbars | MDL Navigation

      < 3 > Footer

      Bootstrap doesn’t actually have separate footer components, while Material Design Lite has two options, a mini and a mega footer. For this example, we’ve translated the default MDL design to Bootstrap, using the grid and a bit of extra CSS.
      Footers in Bootstrap and MDL

      Bootstrap’s menu in mobile’s view

      MDL’s mini footer

       Docs: MDL Footers

      < 4 > Tabs

      Both frameworks use pretty similar syntax to create selectable tabs with different content. A number of links for swapping between the tabs, and an array of divs, selectable by id, for storing the content. They also both require JavaScript to work (Bootstrap requires jQuery as well).
      Tabs in Bootstrap and MDL
      Docs: Bootstrap Tabs | MDL Tabs

      < 5 > Buttons

      Bootstraps default buttons are rectangular and have a bunch of size options. They can have their color changed via CSS or with the modifier classes. Another unique feature to Bootstrap is the split button which is half button, half drop-down.
      MDL offers both rectangular and circular buttons. Google has a guide on how and in which situations to use the different types of buttons. All buttons in MDL support the ripple animation effect.
      Different Buttons in Bootstrap and MDL
      Docs: Bootstrap Buttons | MDL Buttons

      < 6 > Tables

      In Bootstrap responsiveness is achieved using a scrollbar at the bottom of the table. MDL hasn’t added responsiveness to their tables yet. But they added different styles to the tables to make it attractive!  
      Tables in Bootstrap and MDL
      Docs:Bootstrap Tables | MDL Tables 

      < 7 > Forms

      • Bootstrap’s forms support more types of input elements and have classes to make alignments to labels and inputs but it doesn’t have inbuilt library for validation.
      • While MDL has few input elements but the ones with material animation support to make them attractive and fun! they have pattern matching and verification as well. MDL support validation. 
      Forms in Bootstrap and MDL

      Docs: Bootstrap forms | MDL forms

      < 8 > Drop-down Menu

      • Here Bootstrap give you an advantage by making a button split which makes half f the button dropdown menu and half normal button.
      • While MDL gives smooth animation effects compared to Bootstrap’s technique! 
      JavaScript is needed in both the cases.
      Dropdown menu styles in Bootstrap and MDL
      Docs:Bootstraps Menu | MDL Menu

      < 9 > Tool-tips

      Bootstrap gives you the best experience in case of Tool-tips. It gives you the options to show the tool-tip at at top or at bottom or at right or at left or you could just popover it on click!
      MDL has gone with simple approach here. Just two options small and Large design. 
      Tool-tips in Bootstrap and MDL 

      Docs: Bootstrap’s Tool-tips | Bootstrap’s Popover | MDL Tool-tips

        < 10 > Icons
      Bootstrap comes with the Glyphicons icon font, which gives you over 250 pretty icons to choose from. They come bundled with the bootstrap CSS file and no special setup is needed.
      MDL uses a set of icons that Google released some time ago called Material Icons. This is a huge set of nearly 800 icons. They are not bundled with MDL so you need to link it in the HEAD section of your page:

      <link rel=stylesheet href=https://fonts.googleapis.com/icon?family=Material+Icons>

      Icons in Bootstrap and MDL

      Conclusion

      By all means Google’s Materialize Lite is shaping up as a good front-end framework. It makes the webpage look cooler! It is still the early days, but the fact that it is made by Google gives you confidence that it will always conform to the latest material design spec.
      if you don’t find Material Design appealing, there is Bootstrap with its large community. You can even get the best of both worlds by using one of the material themes that are available for it.
      Learn Bootstrap!

      Deal: Get these great Noodlecake games for just $0.89 each at Google Play Store

      You still have just over five days left to pick up a handful of mobile games from Noodlecake Studios in Humble Bundle’s Indie Hits collection, but if there’s a particular game you’re after from the publisher then you might be in luck!

      The Canadian studio has slashed the price of some of its most popular titles and two classic PC ports over on the Google Play Store to celebrate the holidays (thanks, Droid Gamers). Let’s see what’s on offer, shall we?

      Android TV users will be crazy to miss out on Alto’s Adventure TV – a gorgeous physics-based snowboarding game that, like all of the games on this list, is on sale for just $0.99. There’s also The Bug Butcher for shooter fans and Caterzillar for those who like platformers with a sticky twist.

      Editor’s Pick

      The roguelike action adventure Wayward Souls is also on offer alongside the wonderfully bonkers Death Road to Canada – a “Randomly Generated Road Trip Action-RPG” in which you do battle with hordes of flesh-craving zombies.

      If you’re as old as I am, you might remember the puzzle adventure series, Myst. The early 1990s Mac/PC classic had you moving through stunningly realized pre-rendered backdrops and solving mysteries with point-and-click style gameplay.

      The original Myst and its direct sequel, Riven, have stood the test of time incredibly well and Noodlecake and developer Cyan’s mobile ports of both games are absolutely worth checking out if you’re into games like The Room or Monument Valley. Both are available for $0.89 each.

      You can grab the savings over at the Google Play Store via the links below:

      • Alto’s Adventure TV
      • The Bug Butcher
      • Caterzillar
      • Death Road to Canada
      • RealMyst
      • Riven : The sequel to Myst
      • Wayward Souls

      Will you be picking up any of the games on offer? Let us know in the comments.

      Watch Honor’s 3D camera prototype in action as Huawei looks to rival iPhone X’s Face ID

      • Huawei/Honor showed off its 3D facial recognition technology at a recent event in London
      • It claims that its Point Cloud Depth Camera is ten times more accurate than the iPhone X’s TrueDepth camera
      • Recent leaked documents show that Huawei’s next flagship may include a notch – could the 3D tech be included?

      Like it or not, the notch is coming, and it’s all thanks to Apple. Yet while a vast number of budget Android OEMs are expected to include camera cut-outs purely as an iPhone X-aping cosmetic choice, others are reportedly looking to take advantage of the notch and offer their own alternatives to Apple’s TrueDepth camera suite.

      The biggest contender in this field that we’ve seen so far is Huawei. We first got a glimpse of Huawei’s take on the technology during the Honor View 10’s launch in China, complete with a brief demonstration of how the system’s multiple sensors combine and, of course, a quick look at how it handles animated animal emojis.

      Editor’s Pick

      Evidence has since emerged that the Huawei P11 will sport a notch of some kind, but it remains to be seen if the Shenzhen giant’s next flagship will include Face ID-style features. Nevertheless, Huawei is clearly keen on its new tech, as it showed it off again during the Honor View 10 and Honor 7X launch event in London.

      While Honor president George Zhao briefly touched on the newly-christened Point Cloud Depth Camera, it also made a hands-on appearance as a prototype USB-C peripheral. Thanks to a new demonstration video by Notebook Italia and guided by Honor device engineer, Matthew Leone, we now know a little more about the 3D imaging tech and how it might fit on a future Huawei or Honor phone.

      Leone explains that the accessory uses a structured light near-infrared projector combined with other sensors – an RGB camera, infrared camera, near-infrared illuminator and two RGB LEDs – to create a 3D map of the user’s face.

      He then shows this in action as a single photo of his own face taken via the accessory turns into a 3D model. I actually attended the event and managed to give this a try myself and can vouch for how quick and accurate the process is even at this early stage. You can see my ugly mug in 3D in the photos below.

      While it’s clearly early days, representatives from Huawei’s Honor sub-brand have made a number of bold claims about its TrueDepth competitor. During the presentation, a slide noted that its Face Unlock biometrics system needs just 400 milliseconds to bypass an authentication prompt. Honor also says that the Point Cloud Depth Camera captures 300,000 points to create an accurate 3D reconstruction of your face – 10 times more so than the iPhone X.

      What do you think about Huawei/Honor’s facial recognition tech? Could it be the killer feature that takes the P11, or perhaps a Mate 10 successor, to the next level? Let us know in the comments.