How to Enable Preflight CORS in PHP for Angular HTTP requests

When testing Ionic or Angular app you might need to set CORS policy to access a service on a different domain. One way to do this in PHP for testing is to send OK responses for all OPTIONS requests. (If you are testing POST and GET requests)

In your php file set:

// change to your app origin
header('Access-Control-Allow-Origin: http://localhost:8100');
header ("Access-Control-Expose-Headers: Content-Length, X-JSON");
header ("Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE, OPTIONS");
header ("Access-Control-Allow-Headers: Content-Type, Authorization, Accept, Accept-Language, X-Authorization");
header('Access-Control-Max-Age: 86400');

if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
    // The request is using the POST method
    header("HTTP/1.1 200 OK");
    return;

}

Don’t ship this test code, this is just for your internal testing of http requests.

Facebook Deleted Mark Zuckerberg Early Posts

Business Insider:

Old Facebook posts by Mark Zuckerberg have disappeared — obscuring details about core moments in Facebook’s history.

On multiple occassions, years-old public posts made by the 34-year-old billionaire chief executive that were previously public and reported on by news outlets at the time have since vanished, Business Insider has found. That includes all of the posts he made during 2007 and 2008.

Reached for comment, a Facebook spokesperson said the posts were “mistakenly deleted” due to “technical errors.”

Right. Mistake.

Categories NewsCategories

How To Force Restart Frozen iPhone X

How To Force Restart Frozen iPhone X:

Press and quickly release the Volume up button then press and quickly release the Volume down button. To complete, press and hold the Side button until the Apple logo appears on the screen.

For some reason Apple decided to hide this information after changing how the phone works.

Facebook Saved Passwords in Regular Text File

Ars Technica:

Brian Krebs reports that hundreds of millions of Facebook users had their credentials logged in plain text by various applications written by Facebook employees. Those credentials were searched by about 2,000 Facebook engineers and developers more than 9 million times, according to a senior Facebook employee who spoke to Krebs; the employee asked to remain anonymous because they did not have permission to speak to the press on the matter.

In a blog post today, Facebook Vice President of Engineering, Security, and Privacy Pedro Canahuati wrote that the unencrypted passwords were found during “a routine security review in January” on Facebook’s internal network data storage. “This caught our attention because our login systems are designed to mask passwords using techniques that make them unreadable. We have fixed these issues and, as a precaution, we will be notifying everyone whose passwords we have found were stored in this way.”

Not surprised.

Eggs Are Bad For You, Again

Gizmodo:

Ultimately, they found there was a 17 percent increased risk of cardiovascular disease associated with every extra 300 milligrams of dietary cholesterol a day, along with an 18 percent increased risk of early death, even after adjusting for factors like the amount of calories eaten per day. And each extra half-egg a day was similarly linked to a 6 percent and 8 percent increased risk of cardiovascular disease and early death, respectively.

The link between egg consumption and poorer health went away after accounting for a person’s cholesterol intake, suggesting their high cholesterol content was the principle reason behind the increased risk.

F***

How to mask and unmask input element password type in Ionic / Angluar

How to mask and unmask input element password type in ionic/angular/js:

  
this.togglePasswordField = function () {
     console.log("toggle password field called");
     if (document.getElementById("passwordElement").type == "password") {
        document.getElementById("passwordElement").type = "text";

         document.getElementById("passwordHideIcon").classList.remove("ion-eye");
         document.getElementById("passwordHideIcon").classList.add("ion-eye-disabled");
     }
     else {
          document.getElementById("passwordElement").type = "password";
          document.getElementById("passwordHideIcon").classList.remove("ion-eye-disabled");
          document.getElementById("passwordHideIcon").classList.add("ion-eye");     
          }
    }

This way only uses basic html element manipulation.

passwordHideIcon element is a button that calls the function and uses the ionic icon for eyes and eyes disabled.

Facebook Announces Leadership Changes

The Verge:

Here’s the breakdown of the executive changes:

Chris Cox will depart Facebook, but hasn’t revealed plans for what’s next.

Chris Daniels will leave WhatsApp, and Facebook declined to provide any details on why or the circumstances.

Will Cathcart will go from running the main Facebook app to VP of WhatsApp

Fidji Simo who was the VP of Product for Facebook video, news, and advertising will take over Cathcart’s role running Facebook’s main app

Javier Olivan who was Facebook’s VP of growth will lead the task of identifying how to integrate Facebook’s products, including the plan to unify the backend of Facebook Messenger, WhatsApp, and Instagram direct to expand encryption and allow cross-app messaging that some see a shield against Facebook being broken up.

Instagram VP Adam Mosseri, Messenger’s VP Stan Chudnovsky, Simo, and Cathcart will now report directly to Zuckerberg, while Chief Marketing Officer Antonio Lucio reports to COO Sheryl Sandberg

How to install the Android Q beta

The Verge:

If you’re not the kind of person who wants to unlock your phone’s bootloader, I can’t blame you. Google lets Pixel owners enroll in the beta by simply logging in with a Google account, then selecting the compatible device that they’d like to install the beta. You’ll get an over-the-air update that way, just like you normally would for stable versions of Android.

Once you click “Enroll,” you’ll eventually get an update notification on the enrolled device that a system update is ready. You may need to check for a system update in order for it to fetch the beta software, but it usually doesn’t take long for it to be ready for download. (Google says it could take 24 hours or more, but we’ve rarely had to wait that long. The beta hit one of our phones less than a half-hour after enrolling it.) As new Android Q developer previews come out, you’ll get a notification to install them, too, as you would for any regular system update.

Alternatively, you can flash the Android Q beta to your Pixel phone. Google has provided a list of image downloads for the supported phones, but you should only take this road if you’re a developer, or if you just like to do things the hard way. Phones that are updated in this manner won’t receive over-the-air updates to upcoming beta versions, so if you want the latest Android Q features without much hassle, just enroll in the beta instead.

Boeing’s Proposed Solution to Max 8’s MCAS System

The Wired reporting:

The solution, then, is twofold: Boeing started by warning airlines that the MAX’s angle of attack sensors had malfunctioned before, that such a failure could lead the MCAS (Maneuvering Characteristics Augmentation System) to push the plane’s nose down, and that pilots could safely defuse the problem by cutting off the trim system and working the plane manually.

After making sure pilots knew about the problem and how to resolve it, Boeing would work on a longterm solution. Essentially, it would rejigger the software governing MCAS so that it wouldn’t be as prone to jumping into action based on one scary sensor reading, instead considering more data. And it would limit how many times it can engage.

Boeing said it would have it done within a few months. Then the Ethiopian Airlines jet crashed. We don’t yet know if the jet’s MCAS system is what brought the plane down, or what other factors may have been at work. We do know that what seemed a straightforward fix to an unforeseen problem is now muddied—and that the 737 MAX won’t take off again until it’s been cleared up.

Maneuvering Characteristics Augmentation System sounds like a software hack…

Boeing 737 Max 8 Design Issues

The Air Current:

Every airplane development is a series of compromises, but to deliver the 737 Max with its promised fuel efficiency, Boeing had to fit 12 gallons into a 10 gallon jug. Its bigger engines made for creative solutions as it found a way to mount the larger CFM International turbines under the notoriously low-slung jetliner. It lengthened the nose landing gear by eight inches, cleaned up the aerodynamics of the tail cone, added new winglets, fly-by-wire spoilers and big displays for the next generation of pilots.

It pushed technology, as it had done time and time again with ever-increasing costs, to deliver a product that made its jets more-efficient and less-costly to fly.

In the case of the 737 Max, with its nose pointed high in the air, the larger engines – generating their own lift – nudged it even higher. The risk Boeing found through analysis and later flight testing was that under certain high-speed conditions both in wind-up turns and wings-level flight, that upward nudge created a greater risk of stalling. Its solution was MCAS, the Maneuvering Characteristics Augmentation System control law that would allow for both generations of 737 to behave the same way.

MCAS would automatically trim the horizontal stabilizer to bring the nose down, activated with Angle of Attack data. It’s now at the center of the Lion Air investigation and stalking the periphery of the Ethiopian crash.

How to Disable Android Back Button in Ionic 1 / Angular

To disable back button in Android put one of the codes below in your app.js in the .run function.

// app.js

// Disable Back in Entire App
$ionicPlatform.registerBackButtonAction(function(){
  event.preventDefault();
}, 100);

Or Conditionally Disable Back:

// app.js

$ionicPlatform.registerBackButtonAction(function(){
  if($ionicHistory.currentStateName === 'someStateName'){
    event.preventDefault();
  }else{
    $ionicHistory.goBack();
  }
}, 100);

Facebook Service are Down For a Lot of Users

The Verge:

Facebook and Instagram appear to be partially down for some users around the world today. While you can open both platforms and some services appear to have been restored, users are reporting issues with sending messages on Messenger, posting to the feed on all Facebook products, and accessing other features on Facebook.com, Instagram, and WhatsApp. Even Facebook-owned Oculus VR is experiencing issues related to the outage.

Earlier in the day, WhatsApp appeared to be fine for many people, but users in Paraguay, India, Bangladesh, Argentina, and more note that they begun experiencing issues with sending messages as the afternoon went on. DownDetector indicates that those in Brazil were experiencing the most severe outages.

Facebook is using Twitter to explain its outage.

Spotify, Apple Battle Songwriter Royalties

Pitchfork:

The drama heated up in January 2018, when the U.S. Copyright Royalty Board decided to boost the royalty rate that Spotify, Apple Music, and similar streamers must pay songwriters and publishers. Flash forward to last week, when Spotify, Google, Pandora, and Amazon revealed they were each planning to appeal that ruling. The National Music Publishers Association (NMPA) blasted the move, claiming that Spotify and Amazon had chosen to “sue songwriters.”

Perhaps fueled by this incendiary wording—which a NMPA spokesperson tells Pitchfork is “shorthand for the technical legal process of them appealing”—backlash against the streaming services quickly spread among songwriters and industry figures. This week, Spotify responded to the criticism with a blog post noting the complexity of the situation.

Apple is not taking part in the appeals. As such, the NMPA and other industry figures were quick to praise Apple as pro-artist. That said, if the appeals succeed, Apple could conceivably have its cake and eat it too, enjoying the benefit of lower rates without the ire of coming out in favor of them. Apple’s vast phone business and huge cash reserves also mean it’s more insulated from higher costs of doing business than Spotify would be.

It’s a mess.