How to Use iOS GameCenter Leaderboards in Unity3d

You need to setup your app on the appstore connect first with the appropriate leaderboard. And you can only test this code on the iOS device and not in the unity3d player.


using UnityEngine.SocialPlatforms;

  private ILeaderboard leaderboard;
  private string leaderboard_id = "yourleaderboardid"; // setup on appstore connect

 void Start()
 {

    // Authenticate user first
        Social.localUser.Authenticate(success => {
            if (success)
            {
                Debug.Log("Authentication successful");
                string userInfo = "Username: " + Social.localUser.userName +
                    "\nUser ID: " + Social.localUser.id +
                    "\nIsUnderage: " + Social.localUser.underage;
                Debug.Log(userInfo);
            }
            else
                Debug.Log("Authentication failed");
        });

  // create social leaderboard
        leaderboard  = Social.CreateLeaderboard();
        leaderboard.id = leaderboard_id;
        leaderboard.LoadScores(result =>
        {
            Debug.Log("Received " + leaderboard.scores.Length + " scores");
            foreach (IScore score in leaderboard.scores)
                Debug.Log(score);
        });
  }

  void ReportScore(long score, string leaderboardID)
  {
        Debug.Log("Reporting score " + score + " on leaderboard " + leaderboardID);
        Social.ReportScore(score, leaderboardID, success => {
            Debug.Log(success ? "Reported score successfully" : "Failed to report score");
        });
  }

 void OpenLeaderboard()
 {
        Social.ShowLeaderboardUI();
 }

What is SoftBank, and who is behind the Silicon Valley’s largest VC fund?

Recode:

SoftBank is a Tokyo-based company founded almost four decades ago by Masayoshi Son at the age of 24. What started as a store for computer parts has become one of Japan’s most important public companies, valued at over $115 billion. It now is essentially a tech, media, and telecom conglomerate — it owns more than 80 percent of Sprint, more than one-quarter of Alibaba, and 100 percent of the robotics company Boston Dynamics, whose nightmare-inducing animatronics might be familiar to you.

But SoftBank in recent years has been transitioning from a Verizon or AT&T of Japan to something like more of a Blackstone of the world, intentionally moving from a telecom-based giant to a global investing vehicle — thanks, largely, to the Vision Fund.

To understand SoftBank is to understand Son, an eccentric, Star Wars-quoting, diminutive man who is known in the world of high finance solely as “Masa.” To his fans, Son is a daring savant, whose early investment in Alibaba has become part of venture capital lore and at one point made him one of the richest men in the world. To his detractors, Son is an arrogant fool who got lucky once but has since run roughshod over a venture capital system that was already working.

Scary & interesting read.

Uber Stock is a Disaster

Gizmodo reporting:

According to one analyst, the company may be profitable by 2024, though its only real plan so far is to continue to screw workers and eventually replace them with unproven technology. As former CEO Travis Kalanick said in 2014, “the reason that Uber could be expensive is you’re not just paying for the car, you’re paying for the other dude in the car who’s driving.”

Presently, investors are probably realizing that what they’re paying for is an unsustainable company so huge that its main justification for existing is sunk cost.

Ouch.

How to Create Looping Sound with Amazon Alexa Skill App

An example how to play audio with AWS Lambda function for your Amazon Alexa Skill:

The way to do this is to append the same mp3 file to the play queue once the current file is “nearly finished” playing.


const Alexa = require('ask-sdk-core');

const soundURL = 'https://urltosomefile.mp3';
let expectedPreviousToken = '';

const LaunchRequestHandler = {
	canHandle(handlerInput) {
	  return handlerInput.requestEnvelope.request.type === 'LaunchRequest';
	},
	handle(handlerInput) {

	expectedPreviousToken = 'sometoken' + Math.random();
	return handlerInput.responseBuilder
	 .speak('start playing sound')
	 .addAudioPlayerPlayDirective('REPLACE_ALL', soundURL, expectedPreviousToken, 0, null)
	 .withSimpleCard('Example', 'Example')
	 .getResponse();
	}
};

const StartSoundHandler = {
	canHandle(handlerInput) {
		return handlerInput.requestEnvelope.request.type === 'IntentRequest'
		&& handlerInput.requestEnvelope.request.intent.name === 'StartSoundHandler';
	},
	handle(handlerInput) {

	 expectedPreviousToken = 'sometoken'+Math.random();
	 return handlerInput.responseBuilder

	 .addAudioPlayerPlayDirective
              ('REPLACE_ALL', soundURL, expectedPreviousToken, 0, null)
	 .withSimpleCard('Example', 'Example')
	 .getResponse();
	}
};


const ExitHandler = {
	canHandle(handlerInput) {
	const request = handlerInput.requestEnvelope.request;

	return request.type === 'IntentRequest' &&
		(request.intent.name === 'AMAZON.StopIntent' ||
		request.intent.name === 'AMAZON.CancelIntent');
	},
	handle(handlerInput) {
		return handlerInput.responseBuilder
		.addAudioPlayerStopDirective()
		.getResponse();
	}
};

const SessionEndedRequestHandler = {
	canHandle(handlerInput) {
		return handlerInput.requestEnvelope.request.type === 'SessionEndedRequest';
	},
	handle(handlerInput) {
		//any cleanup logic goes here
		return handlerInput.responseBuilder.getResponse();
	}
};

const PausePlaybackHandler = {
	canHandle(handlerInput) {

	const request = handlerInput.requestEnvelope.request;

	return request.type === 'IntentRequest' &&
		request.intent.name === 'AMAZON.PauseIntent';
	},
	handle(handlerInput) {
		return handlerInput.responseBuilder
			.speak('Sound is paused.')
			.addAudioPlayerStopDirective()
			.withSimpleCard('Example', 'Bye!')
			.getResponse();
	},
};


const AudioPlayerEventHandler = {
	canHandle(handlerInput) {
		const request = handlerInput.requestEnvelope.request;

		return request.type === 'AudioPlayer.PlaybackStarted' ||
			request.type === 'AudioPlayer.PlaybackStopped' ||
			request.type === 'AudioPlayer.PlaybackNearlyFinished' ||
			request.type === 'AudioPlayer.PlaybackFailed';
	},
	handle(handlerInput) {
		const request = handlerInput.requestEnvelope.request;

		switch (request.type) {

		 case 'AudioPlayer.PlaybackStarted':
		   expectedPreviousToken = request.token;
		   return handlerInput.responseBuilder
		     .getResponse();

		 case 'AudioPlayer.PlaybackFinished':
		  return handlerInput.responseBuilder
		  .getResponse();

		 case 'AudioPlayer.PlaybackStopped':
			 return handlerInput.responseBuilder
			 .getResponse();

		 case 'AudioPlayer.PlaybackNearlyFinished':

		   return handlerInput.responseBuilder
		      .addAudioPlayerPlayDirective
                       ('ENQUEUE', soundURL, 'sometoken', 0, expectedPreviousToken)
		       .getResponse();

		 case 'AudioPlayer.PlaybackFailed':
			 console.log('Playback Failed');
			 break;
		}

		return handlerInput.responseBuilder.getResponse();
	},
};

const ErrorHandler = {
	canHandle() {
		return true;
	},
	handle(handlerInput, error) {
		console.log(`Error handled: ${error.message}`);

		return handlerInput.responseBuilder
			.getResponse();
	}
};


exports.handler = Alexa.SkillBuilders.custom()
	.addRequestHandlers(
		LaunchRequestHandler,
		StartSoundHandler,
		ExitHandler,
                SessionEndedRequestHandler,
		PausePlaybackHandler,
		AudioPlayerEventHandler)
	.addErrorHandlers(ErrorHandler)
	.lambda();

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