How to Scan Fingerprints with Async PHP and React Native — SitePoint

How to Scan Fingerprints with Async PHP and #reactnative  #reactjs

  • Our composer.json file could look something like:
    {
    “scripts”: {
    “dev”: “vendor/bin/aerys -d -c loader.php”,
    “prod”: “vendor/bin/aerys -c loader.php”
    },
    “require”: {
    “amphp/aerys”: “dev-amp_v2”,
    “pre/kitchen-sink”: “^0.1.0”
    },
    “autoload”: {
    “psr-4”: {
    “App\\”: “app”
    }
    },
    “config”: {
    “process-timeout”: 0
    },
    “minimum-stability”: “dev”,
    “prefer-stable”: true
    }

    This is from composer.json in the server project

    We can also set up a placeholder for requesting scans, along with an HTTP GET route to get to it:
    namespace App\Action;

    use Aerys\Request;
    use Aerys\Response;

    class ScanAction
    {
    public function __invoke(Request $request, Response $response)
    {
    $response-end(“requesting a scan…”);
    }
    }

    This is from app/Action/ScanAction.

  • pre in the server project

    use Aerys\Router;
    use App\Action\ScanAction;

    return (Router $router) = {
    $router-route(
    “GET”, “/scan”, new ScanAction
    );
    };

    This is from routes/web.

  • pre in the server project

    And we can start the server up with a server config file and pre-processor loader script:
    $port = 8080;

    $host = new $port);

    $host-use($router = Aerys\router());

    $web = process ‘http://127.0.0.1:{$port}’ | pbcopy”);

    This is from config.pre in the server project

    return Pre\processAndRequire(__DIR__ . “

  • Let’s add web sockets to our server:
    namespace App\Socket;

    use Aerys\Request;
    use Aerys\Response;
    use Aerys\Websocket;
    use Aerys\Websocket\Endpoint;
    use FingerprintSocket implements Websocket
    {
    private $endpoint;
    private $connections = [];

    public function onStart(Endpoint $endpoint)
    {
    $this-endpoint = $endpoint;
    }

    public function onHandshake(Request $request,
    Response $response)
    {
    // $origin = $request-getHeader(“origin”);
    //
    // if ($origin !

  • == “http://127.0.0.1:8080”) {
    // $response-setStatus(403);
    // $response-end(“origin not allowed”);
    // return null;
    // }

    $info = return $info[“client_addr”];
    }

    public function onOpen(int $clientId, $address)
    {
    $this-connections[$clientId] = $address;
    }

    public function onData(int $clientId, Message $message)
    {
    $body = yield $message;

    yield $this-endpoint-send(
    $payload, $clientId
    );
    }

    public function onClose(int $clientId,
    int $code, string $reason)
    {
    }

    public function onStop()
    {
    // nothing to see here…
    }
    }

    This is from in the server project

    use Aerys\Router;
    use App\Action\ScanAction;
    use (Router $router) = {
    $router-route(
    “GET”, “/scan”, new ScanAction
    );

    $router-route(
    “GET”, “/ws”, Aerys\websocket(new FingerprintSocket)
    );
    };

    This is from routes/web.

In this comprehensive and advanced tutorial, Chris shows us how to scan fingerprints with Async PHP and React Native. The future is here!
Continue reading “How to Scan Fingerprints with Async PHP and React Native — SitePoint”

Angular 2: From Theory to Practice & FREE E-Book Coupon Save 95 %

Angular 2: From Theory to Practice & FREE E-Book
☞ 

#reactjs

  • The course was funded by a kickstarter campaign and is also available as a FREE 700 Page E-Book – Just preview chapter 3 to download 🙂
  • Angular Modules & Bootstrapping your Angular application.
  • The first chapter in the course is a quickstart where you dive straight into writing your first Angular 2 application.
  • _You don’t need to know Angular 1, this courses teaches you Angular 2 from scratch .
  • Build an Angular 2 application from scratch using TypeScript and the Angular command line interface.

Coupon 100 10 15 75 Build the web applications of tomorrow using the new Angular 2 web framework from Google.
Continue reading “Angular 2: From Theory to Practice & FREE E-Book Coupon Save 95 %”

Create React-Native Apps with CoffeeScript

“Create React-Native Apps with CoffeeScript”  #javascript #Mobileapps

  • I installed cjsx and compiled my code again: ( see the compiled result )
  • cjsx supports the same options as the CoffeeScript compiler.
  • The plain CoffeeScript compiler can’t understand JSX, but cjsx can help !
  • To avoid calling the command on every code change just add the -w option and it watches for file changes.
  • React = require “react-native” { AppRegistry, Text, StyleSheet } = React Application = React.createClass render: -> React.createElement Text, style: styles.heading, “Hello World” styles = StyleSheet.create heading: fontSize: 42 textAlign: ‘center’ marginTop: 50 AppRegistry.registerComponent “Example”, () -> Application

Being a web developer I really like React-Native to create native apps, while leveraging my existing Javascript knowledge.
More…
Continue reading “Create React-Native Apps with CoffeeScript”