BackboneJS Compatibility Layer for React-MVx MVVM Framework

Important notice

NestedReact is the BackboneJS compatibility layer for React-MVx - modern React MVVM application framework. It will be maintained as long as Verizon/Volicon systems will depend in the legacy technologies - BackboneJS Views and jQuery.

If you don't need to reuse BackboneJS Views in your React application - please, switch to ReactMVx.

NestedReact documentation won't be updated. Use React-MVx docs as your primary source of docs.

Features

Feature list consists of all the features of React-MVx v2.x, plus this:

  • Gradual transition procedure for backbone applications (Backbone Migration Guide):
    • Complete interoperation with existing Backbone Views allowing you to reuse existing code and avoid upfront application rewrite.
    • Any type of application refactoring strategy is possible - top-to-bottom, bottom-to-top, and random parts at the middle.
    • Support for Backbone events and jQuery accessors in React components simplifies View refactoring.

Installation and Requirements

It's packed as single UMD, thus grab the module or use npm to install. It has NestedTypes model framework, react, react-dom, prop-types, jquery, and underscore as strong dependencies.

npm install --save-dev nestedreact nestedtypes underscore jquery react react-dom prop-types

Module extends React namespace (without modifying original React), and its safe to use it as a replacement for react.

import React from 'nestedreact'

If you're migrating from backbone-based frameworks such as ChaplinJS or Marionette, you need to do following things to make convergence layer work properly:

Make sure that frameworks includes nestedtypes instead of backbone.

On application start, tell nestedreact to use proper base class for the View.

React.useView( Chaplin.View );

Documentation

Please, use React-MVx documentation as a primary source of documentation and examples.

Author: VoliJS
Source Code: https://github.com/VoliJS/NestedReact 
License: 

#react #javascript #typescript #state 

BackboneJS Compatibility Layer for React-MVx MVVM Framework

A Reactive State Management Library for Flutter Applications

Restate

Restate is a reactive state management library for Flutter applications with no dependencies and < 200 lines.

Each Restate StateBloc holds a single state value accessible synchronously, as a Future or as a Stream of values.

  • StateBloc.value - Returns the current state value synchronously.
  • StateBloc.current - Returns a Future that resolves with the current value if it already has a value or otherwise waits for one to be added.
  • StateBloc.stream - Returns a Stream of updates to the state value.
  • StateBloc.changes - Returns a Stream of changes to the state value including the current and previous value.

Reading the current value

import 'package:restate/restate.dart';

final counterState = StateBloc<int>(0);
print(counterState.value); // 0
counterState.add(1);
print(counterState.value); // 1

Listening to a Stream of values

import 'package:restate/restate.dart';

final counterState = StateBloc<int>(0);

counterState.stream.listen((value) {
  print(value);
  // 0
  // 1
  // 2
});

counterState.add(1);
counterState.add(2);

Listening to a Stream of changes

import 'package:restate/restate.dart';

final counterState = StateBloc<int>(0);

counterState.changes.listen((value) {
  print('${value.previous}->${value.current}');
  // null->0
  // 0->1
  // 1->2
});

counterState.add(1);
counterState.add(2);

Waiting for the current value

import 'package:restate/restate.dart';

final counterState = StateBloc<int>();

counterState.current.then((value) => print(value)); // 1
counterState.add(1);
counterState.current.then((value) => print(value)); // 1

Accessing State in Widgets

Accesing and listening for updates to your state is as simple as creating a StateBloc and then using a StreamBuilder to rebuild your widget when data changes:

final counterStateBloc = StateBloc<int>(0);

class MyWidget extends StatelessWidget {
  @override
  build(context) {
    return StreamBuilder(
      stream: counterStateBloc.stream,
      builder: (context, counterSnap) {
        if (!counterSnap.hasData) {
          return Text('Waiting for value...');
        }

        final counter = counterSnap.data;

        return Column(
          children: [
            Text('Counter: $counter'),
            ElevatedButton(
              onPressed: () {
                counterStateBloc.add(counter + 1);
              },
            ),
          ],
        );
      }
    )
  }
}

That's it! You can run the demo to see a more in-depth working example.

Updating a StateBloc value

Generally, the StateBloc.add API is sufficient for updating the current value held by a StateBloc. Sometimes, however, you may be working with complex objects that need to be mutated.

To keep your state values immutable, you can see if it's possible to use a copyWith function to return new objects:

class User {
  String firstName;
  String lastName;

  User({
    required this.firstName,
    required this.lastName,
  });

  User copyWith({
    String? firstName,
    String? lastName,
  }) {
    return User(
      firstName: firstName ?? this.firstName,
      lastName: lastName ?? this.lastName,
    );
  }
}

final user = User(firstName: 'Anakin', lastName: 'Skywalker');
final userState = UserStateBloc<User>(user);

userState.add(
  userState.value.copyWith(
    firstName: 'Darth',
    lastName: 'Vader',
  ),
);

Many Flutter data objects like TextStyle already support this pattern.

If you instead need to mutate the current value, you can use the StateBloc.setValue API:

final user = User(firstName: 'Anakin', lastName: 'Skywalker');
final userState = UserStateBloc<User>(user);

userState.setValue((currentUser) {
  currentUser.firstName = 'Darth';
  currentUser.lastName = 'Vader';
});

The setValue API provides the current value held by the StateBloc, allowing you to mutate it as necessary, and then re-emits that object on the StateBloc.stream.

Feedback Welcome

Let us know if there's a feature or changes you would like to see to Restate on GitHub and happy coding!

Use this package as a library

Depend on it

Run this command:

With Dart:

 $ dart pub add restate

With Flutter:

 $ flutter pub add restate

This will add a line like this to your package's pubspec.yaml (and run an implicit dart pub get):

dependencies:
  restate: ^0.2.0

Alternatively, your editor might support dart pub get or flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:restate/restate.dart'; 

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:restate/restate.dart';
import 'package:restate/state_change_tuple.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

StateBloc<int> _counterBloc = StateBloc<int>();

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            ElevatedButton(
              onPressed: () {
                _counterBloc.add((_counterBloc.value ?? 0) + 1);
              },
              child: const Text('Increment count'),
            ),
            const SizedBox(height: 16),
            StreamBuilder<int?>(
              stream: _counterBloc.stream,
              builder: (context, counterBlocSnap) {
                if (!counterBlocSnap.hasData) {
                  return const SizedBox();
                }

                final clickedCount = counterBlocSnap.data!;

                return Text('Clicked $clickedCount times');
              },
            ),
            Padding(
              padding: const EdgeInsets.symmetric(vertical: 16),
              child: FutureBuilder<int?>(
                future: _counterBloc.current,
                builder: (context, counterBlocSnap) {
                  if (!counterBlocSnap.hasData) {
                    return const Text('The counter has not been clicked.');
                  }

                  final clickedCount = counterBlocSnap.data;

                  if (clickedCount == 0) {
                    return const Text('The counter has not been clicked.');
                  }

                  return const Text('The counter has been clicked!');
                },
              ),
            ),
            StreamBuilder<StateChangeTuple?>(
              stream: _counterBloc.changes,
              builder: (context, counterChangeBlocSnap) {
                if (!counterChangeBlocSnap.hasData) {
                  return const SizedBox();
                }

                final clickCountChange = counterChangeBlocSnap.data!;

                return Text(
                  'Changed from ${clickCountChange.previous ?? 0} to ${clickCountChange.current}',
                );
              },
            ),
          ],
        ),
      ),
    );
  }
} 

Download Details:

Author: danReynolds

Source Code: https://github.com/danReynolds/restate

#flutter #state 

A Reactive State Management Library for Flutter Applications
Dominic  Feeney

Dominic Feeney

1648333320

Tsf Rnn: Implement Recurrent Neural Networks in TensorFlow

What is a Recurrent Neural Network (RNN)?

A Recurrent Neural Network (RNN) is a class of Artificial Neural Network in which the connection between different nodes forms a directed graph to give a temporal dynamic behavior. It helps to model sequential data that are derived from feedforward networks. It works similarly to human brains to deliver predictive results.

A recurrent neural network looks quite similar to a traditional neural network except that a memory-state is added to the neurons. The computation to include a memory is simple.

Imagine a simple model with only one neuron feeds by a batch of data. In a traditional neural net, the model produces the output by multiplying the input with the weight and the activation function. With an RNN, this output is sent back to itself number of time. We call timestep the amount of time the output becomes the input of the next matrice multiplication.

For instance, in the picture below, you can see the network is composed of one neuron. The network computes the matrices multiplication between the input and the weight and adds non-linearity with the activation function. It becomes the output at t-1. This output is the input of the second matrix multiplication.

Recurrent Neural Network (RNN)

 

Recurrent Neural Network (RNN)

Below, we code a simple RNN in TensorFlow to understand the step and also the shape of the output.

The network is composed of:

  • Four inputs
  • Six neurons
  • 2-time steps

The network will proceed as depicted by the picture below.

Recurrent Neural Network (RNN) Example

The network is called ‘recurrent’ because it performs the same operation in each activate square. The network computed the weights of the inputs and the previous output before to use an activation function.

import numpy as np
import tensorflow as tf
n_inputs = 4
n_neurons = 6
n_timesteps = 2
The data is a sequence of a number from 0 to 9 and divided into three batches of data.
## Data 
X_batch = np.array([
        [[0, 1, 2, 5], [9, 8, 7, 4]], # Batch 1
        [[3, 4, 5, 2], [0, 0, 0, 0]], # Batch 2
        [[6, 7, 8, 5], [6, 5, 4, 2]], # Batch 3
    ])

We can build the network with a placeholder for the data, the recurrent stage and the output.

  1. Define the placeholder for the data
X = tf.placeholder(tf.float32, [None, n_timesteps, n_inputs])

Here:

  • None: Unknown and will take the size of the batch
  • n_timesteps: Number of times the network will send the output back to the neuron
  • n_inputs: Number of input per batch
  1. Define the recurrent network

As mentioned in the picture above, the network is composed of 6 neurons. The network will compute two dot product:

  • Input data with the first set of weights (i.e., 6: equal to the number of neurons)
  • Previous output with a second set of weights (i.e., 6: corresponding to the number of output)

Note that, during the first feedforward, the values of the previous output are equal to zeroes because we don’t have any value available.

The object to build an RNN is tf.contrib.rnn.BasicRNNCell with the argument num_units to define the number of input

basic_cell = tf.contrib.rnn.BasicRNNCell(num_units=n_neurons)

Now that the network is defined, you can compute the outputs and states

outputs, states = tf.nn.dynamic_rnn(basic_cell, X, dtype=tf.float32)

This object uses an internal loop to multiply the matrices the appropriate number of times.

Note that the recurent neuron is a function of all the inputs of the previous time steps. This is how the network build its own memory. The information from the previous time can propagate in future time. This is the magic of Recurrent neural network

## Define the shape of the tensor
X = tf.placeholder(tf.float32, [None, n_timesteps, n_inputs])
## Define the network
basic_cell = tf.contrib.rnn.BasicRNNCell(num_units=n_neurons)
outputs, states = tf.nn.dynamic_rnn(basic_cell, X, dtype=tf.float32)
init = tf.global_variables_initializer()
init = tf.global_variables_initializer()
with tf.Session() as sess:
    init.run()
    outputs_val = outputs.eval(feed_dict={X: X_batch})
print(states.eval(feed_dict={X: X_batch}))
[[ 0.38941205 -0.9980438   0.99750966  0.7892596   0.9978241   0.9999997 ]
 [ 0.61096436  0.7255889   0.82977575 -0.88226104  0.29261455 -0.15597084]
 [ 0.62091285 -0.87023467  0.99729395 -0.58261937  0.9811445   0.99969864]]

For explanatory purposes, you print the values of the previous state. The output printed above shows the output from the last state. Now print all the output, you can notice the states are the previous output of each batch. That is, the previous output contains the information about the entire sequence.e

print(outputs_val)    
print(outputs_val.shape)    
[[[-0.75934666 -0.99537754  0.9735819  -0.9722234  -0.14234993
   -0.9984044 ]
  [ 0.99975264 -0.9983206   0.9999993  -1.         -0.9997506
   -1.        ]]

 [[ 0.97486496 -0.98773265  0.9969686  -0.99950117 -0.7092863
   -0.99998885]
  [ 0.9326837   0.2673438   0.2808514  -0.7535883  -0.43337247
    0.5700631 ]]

 [[ 0.99628735 -0.9998728   0.99999213 -0.99999976 -0.9884324
   -1.        ]
  [ 0.99962527 -0.9467421   0.9997403  -0.99999714 -0.99929446
   -0.9999795 ]]]
(3, 2, 6)

Recurrent Neural Network (RNN) Example

The output has the shape of (3, 2, 6):

  • 3: Number of batches
  • 2: Number of the timestep
  • 6: Number of neurons

The optimization of a recurrent neural network is identical to a traditional neural network. You will see in more detail how to code optimization in the next part of this Recurrent Neural Network tutorial.

Setup

Refer to the setup instructions

# Import MINST data
import input_data
mnist = input_data.read_data_sets("/tmp/data/", one_hot=True)

import tensorflow as tf
from tensorflow.models.rnn import rnn, rnn_cell
import numpy as np
Extracting /tmp/data/train-images-idx3-ubyte.gz
Extracting /tmp/data/train-labels-idx1-ubyte.gz
Extracting /tmp/data/t10k-images-idx3-ubyte.gz
Extracting /tmp/data/t10k-labels-idx1-ubyte.gz
'''
To classify images using a reccurent neural network, we consider every image row as a sequence of pixels.
Because MNIST image shape is 28*28px, we will then handle 28 sequences of 28 steps for every sample.
'''

# Parameters
learning_rate = 0.001
training_iters = 100000
batch_size = 128
display_step = 10

# Network Parameters
n_input = 28 # MNIST data input (img shape: 28*28)
n_steps = 28 # timesteps
n_hidden = 128 # hidden layer num of features
n_classes = 10 # MNIST total classes (0-9 digits)
# tf Graph input
x = tf.placeholder("float", [None, n_steps, n_input])
istate = tf.placeholder("float", [None, 2*n_hidden]) #state & cell => 2x n_hidden
y = tf.placeholder("float", [None, n_classes])

# Define weights
weights = {
    'hidden': tf.Variable(tf.random_normal([n_input, n_hidden])), # Hidden layer weights
    'out': tf.Variable(tf.random_normal([n_hidden, n_classes]))
}
biases = {
    'hidden': tf.Variable(tf.random_normal([n_hidden])),
    'out': tf.Variable(tf.random_normal([n_classes]))
}
def RNN(_X, _istate, _weights, _biases):

    # input shape: (batch_size, n_steps, n_input)
    _X = tf.transpose(_X, [1, 0, 2])  # permute n_steps and batch_size
    # Reshape to prepare input to hidden activation
    _X = tf.reshape(_X, [-1, n_input]) # (n_steps*batch_size, n_input)
    # Linear activation
    _X = tf.matmul(_X, _weights['hidden']) + _biases['hidden']

    # Define a lstm cell with tensorflow
    lstm_cell = rnn_cell.BasicLSTMCell(n_hidden, forget_bias=1.0)
    # Split data because rnn cell needs a list of inputs for the RNN inner loop
    _X = tf.split(0, n_steps, _X) # n_steps * (batch_size, n_hidden)

    # Get lstm cell output
    outputs, states = rnn.rnn(lstm_cell, _X, initial_state=_istate)

    # Linear activation
    # Get inner loop last output
    return tf.matmul(outputs[-1], _weights['out']) + _biases['out']
pred = RNN(x, istate, weights, biases)

# Define loss and optimizer
cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(pred, y)) # Softmax loss
optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate).minimize(cost) # Adam Optimizer

# Evaluate model
correct_pred = tf.equal(tf.argmax(pred,1), tf.argmax(y,1))
accuracy = tf.reduce_mean(tf.cast(correct_pred, tf.float32))
# Initializing the variables
init = tf.global_variables_initializer()

# Launch the graph
with tf.Session() as sess:
    sess.run(init)
    step = 1
    # Keep training until reach max iterations
    while step * batch_size < training_iters:
        batch_xs, batch_ys = mnist.train.next_batch(batch_size)
        # Reshape data to get 28 seq of 28 elements
        batch_xs = batch_xs.reshape((batch_size, n_steps, n_input))
        # Fit training using batch data
        sess.run(optimizer, feed_dict={x: batch_xs, y: batch_ys,
                                       istate: np.zeros((batch_size, 2*n_hidden))})
        if step % display_step == 0:
            # Calculate batch accuracy
            acc = sess.run(accuracy, feed_dict={x: batch_xs, y: batch_ys,
                                                istate: np.zeros((batch_size, 2*n_hidden))})
            # Calculate batch loss
            loss = sess.run(cost, feed_dict={x: batch_xs, y: batch_ys,
                                             istate: np.zeros((batch_size, 2*n_hidden))})
            print "Iter " + str(step*batch_size) + ", Minibatch Loss= " + "{:.6f}".format(loss) + \
                  ", Training Accuracy= " + "{:.5f}".format(acc)
        step += 1
    print "Optimization Finished!"
    # Calculate accuracy for 256 mnist test images
    test_len = 256
    test_data = mnist.test.images[:test_len].reshape((-1, n_steps, n_input))
    test_label = mnist.test.labels[:test_len]
    print "Testing Accuracy:", sess.run(accuracy, feed_dict={x: test_data, y: test_label,
                                                             istate: np.zeros((test_len, 2*n_hidden))})
Iter 1280, Minibatch Loss= 1.888242, Training Accuracy= 0.39844
Iter 2560, Minibatch Loss= 1.519879, Training Accuracy= 0.47656
Iter 3840, Minibatch Loss= 1.238005, Training Accuracy= 0.63281
Iter 5120, Minibatch Loss= 0.933760, Training Accuracy= 0.71875
Iter 6400, Minibatch Loss= 0.832130, Training Accuracy= 0.73438
Iter 7680, Minibatch Loss= 0.979760, Training Accuracy= 0.70312
Iter 8960, Minibatch Loss= 0.821921, Training Accuracy= 0.71875
Iter 10240, Minibatch Loss= 0.710566, Training Accuracy= 0.79688
Iter 11520, Minibatch Loss= 0.578501, Training Accuracy= 0.82812
Iter 12800, Minibatch Loss= 0.765049, Training Accuracy= 0.75000
Iter 14080, Minibatch Loss= 0.582995, Training Accuracy= 0.78125
Iter 15360, Minibatch Loss= 0.575092, Training Accuracy= 0.79688
Iter 16640, Minibatch Loss= 0.701214, Training Accuracy= 0.75781
Iter 17920, Minibatch Loss= 0.561972, Training Accuracy= 0.78125
Iter 19200, Minibatch Loss= 0.394480, Training Accuracy= 0.85938
Iter 20480, Minibatch Loss= 0.356244, Training Accuracy= 0.91406
Iter 21760, Minibatch Loss= 0.632163, Training Accuracy= 0.78125
Iter 23040, Minibatch Loss= 0.269334, Training Accuracy= 0.90625
Iter 24320, Minibatch Loss= 0.485007, Training Accuracy= 0.86719
Iter 25600, Minibatch Loss= 0.569704, Training Accuracy= 0.78906
Iter 26880, Minibatch Loss= 0.267697, Training Accuracy= 0.92188
Iter 28160, Minibatch Loss= 0.381177, Training Accuracy= 0.90625
Iter 29440, Minibatch Loss= 0.350800, Training Accuracy= 0.87500
Iter 30720, Minibatch Loss= 0.356782, Training Accuracy= 0.90625
Iter 32000, Minibatch Loss= 0.322511, Training Accuracy= 0.89062
Iter 33280, Minibatch Loss= 0.309195, Training Accuracy= 0.90625
Iter 34560, Minibatch Loss= 0.535408, Training Accuracy= 0.83594
Iter 35840, Minibatch Loss= 0.281643, Training Accuracy= 0.92969
Iter 37120, Minibatch Loss= 0.290962, Training Accuracy= 0.89844
Iter 38400, Minibatch Loss= 0.204718, Training Accuracy= 0.93750
Iter 39680, Minibatch Loss= 0.205882, Training Accuracy= 0.92969
Iter 40960, Minibatch Loss= 0.481441, Training Accuracy= 0.84375
Iter 42240, Minibatch Loss= 0.348245, Training Accuracy= 0.89844
Iter 43520, Minibatch Loss= 0.274692, Training Accuracy= 0.90625
Iter 44800, Minibatch Loss= 0.171815, Training Accuracy= 0.94531
Iter 46080, Minibatch Loss= 0.171035, Training Accuracy= 0.93750
Iter 47360, Minibatch Loss= 0.235800, Training Accuracy= 0.89844
Iter 48640, Minibatch Loss= 0.235974, Training Accuracy= 0.93750
Iter 49920, Minibatch Loss= 0.207323, Training Accuracy= 0.92188
Iter 51200, Minibatch Loss= 0.212989, Training Accuracy= 0.91406
Iter 52480, Minibatch Loss= 0.151774, Training Accuracy= 0.95312
Iter 53760, Minibatch Loss= 0.090070, Training Accuracy= 0.96875
Iter 55040, Minibatch Loss= 0.264714, Training Accuracy= 0.92969
Iter 56320, Minibatch Loss= 0.235086, Training Accuracy= 0.92969
Iter 57600, Minibatch Loss= 0.160302, Training Accuracy= 0.95312
Iter 58880, Minibatch Loss= 0.106515, Training Accuracy= 0.96875
Iter 60160, Minibatch Loss= 0.236039, Training Accuracy= 0.94531
Iter 61440, Minibatch Loss= 0.279540, Training Accuracy= 0.90625
Iter 62720, Minibatch Loss= 0.173585, Training Accuracy= 0.93750
Iter 64000, Minibatch Loss= 0.191009, Training Accuracy= 0.92188
Iter 65280, Minibatch Loss= 0.210331, Training Accuracy= 0.89844
Iter 66560, Minibatch Loss= 0.223444, Training Accuracy= 0.94531
Iter 67840, Minibatch Loss= 0.278210, Training Accuracy= 0.91406
Iter 69120, Minibatch Loss= 0.174290, Training Accuracy= 0.95312
Iter 70400, Minibatch Loss= 0.188701, Training Accuracy= 0.94531
Iter 71680, Minibatch Loss= 0.210277, Training Accuracy= 0.94531
Iter 72960, Minibatch Loss= 0.249951, Training Accuracy= 0.95312
Iter 74240, Minibatch Loss= 0.209853, Training Accuracy= 0.92188
Iter 75520, Minibatch Loss= 0.049742, Training Accuracy= 0.99219
Iter 76800, Minibatch Loss= 0.250095, Training Accuracy= 0.92969
Iter 78080, Minibatch Loss= 0.133853, Training Accuracy= 0.95312
Iter 79360, Minibatch Loss= 0.110206, Training Accuracy= 0.97656
Iter 80640, Minibatch Loss= 0.141906, Training Accuracy= 0.93750
Iter 81920, Minibatch Loss= 0.126872, Training Accuracy= 0.94531
Iter 83200, Minibatch Loss= 0.138925, Training Accuracy= 0.95312
Iter 84480, Minibatch Loss= 0.128652, Training Accuracy= 0.96094
Iter 85760, Minibatch Loss= 0.099837, Training Accuracy= 0.96094
Iter 87040, Minibatch Loss= 0.119000, Training Accuracy= 0.95312
Iter 88320, Minibatch Loss= 0.179807, Training Accuracy= 0.95312
Iter 89600, Minibatch Loss= 0.141792, Training Accuracy= 0.96094
Iter 90880, Minibatch Loss= 0.142424, Training Accuracy= 0.96094
Iter 92160, Minibatch Loss= 0.159564, Training Accuracy= 0.96094
Iter 93440, Minibatch Loss= 0.111984, Training Accuracy= 0.95312
Iter 94720, Minibatch Loss= 0.238978, Training Accuracy= 0.92969
Iter 96000, Minibatch Loss= 0.068002, Training Accuracy= 0.97656
Iter 97280, Minibatch Loss= 0.191819, Training Accuracy= 0.94531
Iter 98560, Minibatch Loss= 0.081197, Training Accuracy= 0.99219
Iter 99840, Minibatch Loss= 0.206797, Training Accuracy= 0.95312
Optimization Finished!
Testing Accuracy: 0.941406

Link: https://nbviewer.org/github/TarrySingh/Machine-Learning-Tutorials/blob/master/deep-learning/tensor-flow-examples/notebooks/3_neural_networks/recurrent_network.ipynb

#tensorflow  #python 

Tsf Rnn: Implement Recurrent Neural Networks in TensorFlow

Easily Create A Finite State Machine and Define Legal State Transition

Dart State Machine

Easily create a finite state machine and define legal state transitions. Listen to state entrances, departures, and transitions.

Getting Started

Import the state_machine package:

import 'package:state_machine/state_machine.dart';

Create a Machine

Once created, the StateMachine will be used to create states and state transitions.

StateMachine light = new StateMachine('light');

Define a Set of States

Use the machine to create all required states. A string name is required for ease of debugging.

State isOn = light.newState('on');
State isOff = light.newState('off');

It's recommended that states be named in the format "is[State]". This may seem strange at first, but it has two main benefits:

  1. It helps differentiate states from transitions, which can be confusing since many words in English are the same as a verb and an adjective ("open" or "secure", for example).
  2. It reads better when calling the state to determine if it's active, as will be demonstrated later.

Define the Legal State Transitions

By defining legal state transitions, you can prevent certain actions based on the current state of the machine. Defining a state transition requires a name (again for ease of debugging), a list of valid "from" states, and the state to transition the machine to.

StateTransition turnOn = light.newStateTransition('turnOn', [isOff], isOn);
StateTransition turnOff = light.newStateTransition('turnOff', [isOn], isOff);

Start the Machine

Before executing any state transitions, the machine should be started at a specific starting state.

light.start(isOff);

Executing a State Transition

The StateTransition class implements Function so that you can simply call a transition to execute it.

light.start(isOff);
turnOn(); // transitions machine from "isOff" to "isOn"

Determining the Active State

The StateMachine instance exposes a current state property which allows you to retrieve the machine's current state at any time.

light.start(isOff);
light.current == isOff; // true

Additionally, the State class implements Function so that you can simply call a state to determine if it's active.

light.start(isOff);
isOff(); // true
isOn();  // false

Listening to State Transitions

The StateTransition class exposes a listen() method that allows you to listen to the transition and receive an event every time the transition executes.

turnOn.listen((StateChange change) {
  print('Light transitioned from ${change.from.name} to ${change.to.name}');
});
light.start(isOff);
turnOn(); // "Light transitioned from off to on"

Passing Data with a State Transition

State transitions accept an optional payload in case you need to pass data along to listeners.

turnOn.listen((StateChange change) {
  print('Light turned on. Wattage: ${change.payload}');
});
light.start(isOff);
turnOn('15w'); // "Light turned on. Wattage: 15w"

Listening for State Entrances and Departures

The State class exposes two streams so that you can listen for the state being entered and the state being left.

isOff.onLeave.listen((StateChange change) {
  print('Left: off');
});
isOn.onEnter.listen((StateChange change) {
  print('Entered: on');
});
light.start(isOff);
turnOn(); // "Left: off"
          // "Entered: on"

Wildcard State and State Transitions

The State class exposes a static instance State.any that can be used as a wildcard when defining a state transition.

StateMachine machine = new StateMachine('machine');
State isFailed = machine.newState('failed');

// This transition will be valid regardless of which state the machine is in.
StateTransition fail = machine.newStateTransition('fail', [State.any], isFailed);

Illegal State Transitions

When you create state transitions, you must define the list of valid "from" states. The machine must be in one of these states in order to execute the transition. If that's not the case, an IllegalStateTransition exception will be thrown.

// Consider a door with the following states and transitions.
StateMachine door = new StateMachine('door');

State isOpen = door.newState('open');
State isClosed = door.newState('closed');
State isLocked = door.newState('locked');

StateTransition open = door.newStateTransition('open', [isClosed], isOpen);
StateTransition close = door.newStateTransition('close', [isOpen], isClosed);
StateTransition lock = door.newStateTransition('lock', [isClosed], isLocked);
StateTransition unlock = door.newStateTransition('unlock', [isLocked], isClosed);

// Let's transition the door from open, to closed, to locked.
door.start(isOpen);
close();
lock();

// In order to open the door, we must first unlock it.
// If we try to open it first, an exception will be thrown.
open(); // throws IllegalStateTransition

Canceling State Transitions

State machines have a set of legal state transitions that are set in stone and provide the required structure. But, there may be scenarios where a state transition may or may not be desirable based on additional logic. To handle this, state transitions support cancellation conditions.

// Consider two state machines - a person and a door.
// The door can be locked or unlocked and the person
// can be with or without a key.
StateMachine door = new StateMachine('door');
State isLocked = door.newState('locked');
State isUnlocked = door.newState('unlocked');
StateTransition unlock = door.newStateTransition('unlock', [isLocked], isUnlocked);

StateMachine person = new StateMachine('person');
State isWithKey = person.newState('withKey');
State isWithoutKey = person.newState('withoutKey');
StateTransition obtainKey = person.newStateTransition('obtainKey', [isWithoutKey], isWithKey);

door.start(isLocked);
person.start(isWithoutKey);

// Add a cancellation condition for unlocking the door:
// If the person is without a key, cancel the unlock transition.
unlock.cancelIf((StateChange change) => isWithoutKey());

unlock(); // false (canceled)
isUnlocked(); // false
obtainKey();
unlock(); // true (not canceled)
isUnlocked(); // true

Development

This project leverages the dart_dev package for most of its tooling needs, including static analysis, code formatting, running tests, collecting coverage, and serving examples. Check out the dart_dev readme for more information.

Use this package as a library

Depend on it

Run this command:

With Dart:

 $ dart pub add state_machine

With Flutter:

 $ flutter pub add state_machine

This will add a line like this to your package's pubspec.yaml (and run an implicit dart pub get):

dependencies:
  state_machine: ^2.2.2

Alternatively, your editor might support dart pub get or flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:state_machine/state_machine.dart'; 

Download Details:

Author: Workiva

Source Code: https://github.com/Workiva/state_machine

#dart #state #machine 

Easily Create A Finite State Machine and Define Legal State Transition
Duy  Tien

Duy Tien

1635253200

Cách Sử dụng State Design Pattern Chỉ với 10 Phút

Trong video Này Tôi Sẽ hướng dẫn Cách Sử dụng State Design Pattern Chỉ với 10 Phút 
#state #design-pattern 

Cách Sử dụng State Design Pattern Chỉ với 10 Phút

Creating A Reusable Dialog Component with Material UI V5

In this video we create a reusable dialog component. In bigger apps you'll have a ton of dialogs. Having to rewrite the same useState hooks and passing the same stuff for different screens can be tiresome. Creating a reusable component as in this video can be the solution :)

 #material #ui #state #usestate 

Creating A Reusable Dialog Component with Material UI V5
藤本  結衣

藤本 結衣

1633347300

Reduxのアプリ状態で大量のデータを追加する

Reduxストアは、コンポーネントツリーのすべてのレベルで小道具をドリルすることなく、複数のコンポーネントで使用するデータを格納するグローバル状態です。アプリが大きく複雑になると、大きくてかさばるデータをReduxストア内に保存し、コンポーネント内でアクセスしたい場合があります。Reduxストアには保存されるデータの量に制限がないため、かさばるJSONデータ、テーブル形式のデータなど、ほとんどすべてのものを保存するために使用できます。このガイドでは、大量のデータを追加する方法について説明します。 ReactReduxアプリの状態のデータ。

Reduxボイラープレートの作成

空のCreate-React-AppReact-Reduxプロジェクトでstore.js、ルートディレクトリ内に呼び出されるファイルで以下のコードを使用して単純なストアとレデューサーをセットアップします。

import { createStore} from 'redux';
const initailState={
    data:'lorem ipsum',
}
const rootReducer=(state=initailState,action)=>{
    switch(action.type){
        case 'ADD_DATA':
            return{
                ...state,
                data: action.payload
            }
        default:
            return state;
    }
}

export default createStore(rootReducer)

次に、アプリをProviderコンポーネントにラップし、storeasを渡して、propsこのProviderコンポーネント内のすべてのコンポーネントが内部を使用できるようにしstoreますindex.js

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import {Provider} from 'react-redux';
import store from './store';

ReactDOM.render(
  <React.StrictMode>
    <Provider store={store}>
      <App />
    </Provider>
  </React.StrictMode>,
  document.getElementById('root')
);

serviceWorker.unregister();

ストアには、最初は短くて単純なデータがいくつかあります。次に、ファイルaction.jsを作成し、タイプがアクションのアクションクリエーターを作成しますADD_DATA。またaddData、アクションtypepayloadプロパティをdispatch()メソッドを介して渡されるデータに接続するオブジェクトも含まれています。 

 

 

 

最後に、storedispatch()を、何らかのアクションをディスパッチしてグローバル状態にデータを追加できるコンポーネントに接続します。

 

 

 

アプリコンポーネントは、ADD_DATAアクションを起動またはディスパッチする単純なボタンをレンダリングします。このアクションをディスパッチするときに、グローバルストアの状態にいくつかの簡単なデータを追加します。

大きなJSONデータの作成

次のステップはdata.js、ダミーデータをテスト用に配置できるファイルを作成することです。data.jsルートディレクトリ内にという新しいファイルを作成し、その中に大量のデータを追加します。この例では、オンラインのモックデータ生成ツールMockarooを使用して作成された1,000エントリの大きなJSONデータを使用しています。同じツールを使用して、あらゆる種類の大きなデータを生成したり、独自のデータを使用したりできます。data.jsファイル内で、大きなJSONデータをコピーして貼り付け、オブジェクトとしてエクスポートします。

 

 

 

このデータimportは、コンポーネントの上部にあるキーワードを使用して通常のオブジェクトのようにインポートすることで、アプリ全体のどこでも使用できます。

 

 

州内に大量のデータを追加する

action.jsファイル内の大きなデータをインポートし、このデータをオブジェクトpayload内のプロパティに渡しaddDataます。

 

 

これでADD_DATA、アプリコンポーネントからアクションをディスパッチし、アプリのグローバルストアの状態に数千のエントリの大きなJSONデータを追加する準備が整いました。[データ追加]ボタンをクリックすると、ストアの状態にこの大きなJSONデータが含まれていることを確認できます。したがって、レデューサーを介してそのデータをReduxストアに保存するアクションをディスパッチすることで、アプリの状態に任意の量のデータを追加できます。

大規模な書き込み操作の分析

Reduxストアは保存されているデータの量に依存しないため、1行のデータまたは複雑なJSONオブジェクトの1000エントリを保存してもReduxに違いはありません。[データの追加]ボタンをクリックすると、ADD_DATAアクションがディスパッチされます。これにより、ちらつきやUIラグなしにストア内に大きなデータが追加されます。これは、アプリの状態で大きなデータを追加してもパフォーマンスに違いがないことを示しています。さらに大きなデータセットで試すこともできますが、結果は同じです。

より詳細な分析については、Google ChromeのLighthouseを使用して、この操作の実行後にアプリレポートを生成することでアプリのパフォーマンスを評価できます。ある場合は単純なデータを使用し、別の場合は大きなJSONデータを使用して、両方のパフォーマンスレポートを比較します。どちらもほぼ同じパフォーマンスを示しており、大量のデータを追加してもアプリのパフォーマンスに影響がないことを示しています。

結論

Reduxストアは、保存されるデータのサイズに制限を課しません。この操作を実行するアクションをディスパッチしてもアプリのパフォーマンスは低下しないため、アプリのに任意の量のデータを安全に保存できますstate。ただし、大きなデータをアプリの状態で保存している場合は、ある時点で、DOMにレンダリングしてユーザーに表示したい場合があります。アプリのすべてのコンテンツを配信しながら、このような状況でアプリのパフォーマンスを向上させるために、遅延読み込みなどの手法を使用することをお勧めします。

リンク: https://www.pluralsight.com/

#reactjs #state #dom 

Reduxのアプリ状態で大量のデータを追加する

Flutter Bindings for State Notifier

Welcome to flutter_state_notifier~

This repository is a side-package that is destined to be used together with state_notifier.

It adds extra Flutter bindings to StateNotifier, such as provider integration.

The available widgets

StateNotifierProvider

StateNotifierProvider is the equivalent of ChangeNotifierProvider but for StateNotifier.

Its job is to both create a StateNotifier and dispose it when the provider is removed from the widget tree.

If the created StateNotifier uses LocatorMixin, StateNotifierProvider will also do the necessary to make read/update work with provider.

It is used like most providers, with a small difference:
Instead of exposing one value, it exposes two values at the same time:

Which means that when you write:

class MyState {}

class MyStateNotifier extends StateNotifier<MyState> {
  MyStateNotifier(): super(MyState());
}

// ...

MultiProvider(
  providers: [
    StateNotifierProvider<MyStateNotifier, MyState>(create: (_) => MyStateNotifier()).
  ]
)

This allows you to both:

  • obtain the StateNotifier in the widget tree, by writing context.read<MyStateNotifier>()
  • obtain and observe the current [MyState], through context.watch<MyState>()

StateNotifierBuilder

StateNotifierBuilder is equivalent to ValueListenableBuilder from Flutter.

It allows you to listen to a StateNotifier and rebuild your UI accordingly, but does not create/dispose/provide the object.

As opposed to StateNotifierProvider, this will not make read/update of StateNotifier work.

It is used as such:

class MyState {}

class MyStateNotifier extends StateNotifier<MyState> {
  MyStateNotifier(): super(MyState());
}

// ...

MyStateNotifier stateNotifier;

return StateNotifierBuilder<MyState>(
  stateNotifier: stateNotifier,
  builder: (BuildContext context, MyState state, Widget child) {
    return Text('$state');
  },
)

Use this package as a library

Depend on it

Run this command:

With Dart:

 $ dart pub add flutter_state_notifier

With Flutter:

 $ flutter pub add flutter_state_notifier

This will add a line like this to your package's pubspec.yaml (and run an implicit dart pub get):

dependencies:
  flutter_state_notifier: ^0.7.1

Alternatively, your editor might support dart pub get or flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:flutter_state_notifier/flutter_state_notifier.dart'; 

example/lib/main.dart

import 'package:example/my_state_notifier.dart';
import 'package:flutter/material.dart';
import 'package:flutter_state_notifier/flutter_state_notifier.dart';
import 'package:provider/provider.dart';

// This is the default counter example reimplemented using StateNotifier + provider
// It will print in the console the counter whenever it changes
// The state change is also animated.

// The "print to console" feature is abstracted through a "Logger" class like
// we would do in production.

// This showcase how our custom MyStateNotifier does not depend on Flutter,
// but is still able to read providers and be used as usual in a Flutter app.

void main() {
  runApp(
    MultiProvider(
      providers: [
        Provider<Logger>(create: (_) => ConsoleLogger()),
        StateNotifierProvider<MyStateNotifier, MyState>(
          create: (_) => MyStateNotifier(),
          // Override MyState to make it animated
          builder: (context, child) {
            return TweenAnimationBuilder<MyState>(
              duration: const Duration(milliseconds: 500),
              tween: MyStateTween(end: context.watch<MyState>()),
              builder: (context, state, _) {
                return Provider.value(value: state, child: child);
              },
            );
          },
        ),
      ],
      child: MyApp(),
    ),
  );
}

/// A [MyStateTween].
///
/// This will apply an [IntTween] on [MyState.count].
class MyStateTween extends Tween<MyState> {
  MyStateTween({MyState begin, MyState end}) : super(begin: begin, end: end);

  @override
  MyState lerp(double t) {
    final countTween = IntTween(begin: begin.count, end: end.count);
    // Tween the count
    return MyState(
      countTween.lerp(t),
    );
  }
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Flutter Demo',
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Counter example'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              context.select((MyState value) => value.count).toString(),
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: context.watch<MyStateNotifier>().increment,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
} 

Download Details:

Author: rrousselGit

Source Code: https://github.com/rrousselGit/state_notifier

#flutter #state 

 

Flutter Bindings for State Notifier
Skye  Torp

Skye Torp

1625796720

Vue.js 3 & State • Full-Stack TypeScript with Kretes • E03

In this tutorial we are building a full-stack application in TypeScript. This means we will not only cover the frontend part, but also the backend part.

The frontend will be built in Vue.js using the upcoming version 3 that’s currently in beta. Specifically we will focus on exploring the Composition API that this version introduces. Composition API is similar to Hooks from React. On the backend we will use Node.js, but still writing TypeScript.

We will not only see how to connect frontend with backend, but also how to design the database, how to deploy the app, and much more. Our goal is to build yet another task management application.

So far we designed and build a simple UI using Tailwind CSS. We also generated the application scaffold using Kretes which is an integrated programming environment for TypeScript. We configured and connected Vue.js to handle the UI. We are now finally ready to make our static prototype interactive. This is what we will see in this episode.

#vuejs #typescript #kretes

#state #vue.js

Vue.js 3 & State • Full-Stack TypeScript with Kretes • E03
Gordon  Taylor

Gordon Taylor

1624992660

Not always you need a state management library-How to build your own simple Store use RxJs

Sometimes, it’s not necessary to add huge store libraries in an Angular application. All we need is RxJs library which provides observables and operators. In the article we will figure out how to create a state management from scratch using Subject and Observables on the example of the recipe finder Angular application.

What’s the problem?

We have several components or, even, modules around the application which use the same data. How to provide and update this data easily? Where should we keep it?

Mr. Store is hurrying to help!

Defining the Store

Let’s create a separate service where we want to save everything we can use in any component of the project. Also, we would like to take any values from our Store and, furthermore, subscribe to any changes.

export interface Store {
  recipes: Recipe[];
  savedRecipes: Set<Recipe>;
}
@Injectable({
  providedIn: 'root',
})
export class StoreService {
  private store: BehaviorSubject<Store>;

  constructor() {
    this.store = new BehaviorSubject<Store>({
      recipes: [],
      savedRecipes: new Set<Recipe>()
    });
  }
}

#state #rxjs #javascript #angular

Not always you need a state management library-How to build your own simple Store use RxJs
Dexter  Goodwin

Dexter Goodwin

1623184260

Announcing New and Simple State Manager “Exome”

TLDR: I created new state library called  Exome (works with React and there’s a PR for Vue too (excuse me, that sounded like a pokemon)). The end.

Introduction

Let me introduce myself first. I’m working as a front-end dev for as long as I can remember. Since before the days of jQuery dominance even. So I’ve seen a lot from dead simple JS libraries to utterly complex ones and again back to simple ones and so on. When I started learning Redux, NgRx and Vuex back in a day it was a high hill to climb at first always wishing for something easier. Much easier, like a plain object being state easier.

So I started tinkering with different ideas of how I would like my ideal state manager to look and feel years ago. I remember having random ideas at random times and just dropped them in notes. I never did anything with those because none of them really felt good enough.

Until now when I reached a point when starting a new project were working with deeply nested tree structures was a must have. Since that is one of Redux (and I’d say the whole flux architecture for that matter) core problems, I went withvaltio, a library by Pmndrs. And it was great at first, but then I started to see a real mess in code with my made up actions and selectors making sense less and less. And the line between what gets selected from state and what updated became blurred together. So I knew that I had only one option, to finally figure out my dream state manager.

From idea to library

I set a few goals for state manager I wanted:

  1. Must have actions (in a sense that it would be the only way to modify state);
  2. Must integrate with Redux Devtools and to see deeply nested objects right away, not clicking through tree to find exact one I’m looking for;
  3. Must be typed via TypeScript, I mean when working with data, there must be some guards and of course that sweet autocomplete;
  4. Must be able to save and load as a string (since in my case I needed a way to save state in a file and restore it);
  5. Must be dead simple so any junior developer can get productive right away;
  6. Must not bottleneck the view renderer (must be performant).

So those were my initial goals and in a single evening I came up with Exome and developed a prototype. I was so happy with it that I decided to make it open source. It really hits all of the goals I set and more. Only issue is that  it doesn’t support IE11, since it uses Proxy. But in my case it didn’t matter.

UPDATE: It now  supports IE11! 🎉

#javascript #react #store #state #exome

Announcing New and Simple State Manager “Exome”

What is ParaState (STATE) | What is ParaState token | What is STATE token

What is  Parastate

ParaState is a proof-of-stake blockchain platform that says its goal is to ParaState aims to become a Polkadot parachain that extends the frontier of Ethereum with substrate framework. By supporting 20+ programming languages to create Ethereum-compatible smart contracts, we can unite a larger developer community to boost the cross-chain interoperability.

While supporting the EVM pallet to provide seamless compatibility with all existing Ethereum applications, ParaState also provides developers with a next-gen smart contract implementation environment, EWASM (Ethereum-flavored WebAssembly). These two infrastructures are ensured to talk to each other and share the same account system on ParaState.

This is the differentiation ParaState provides to the developer community, to enable them to surf in the highly optimized industrial standard infrastructure while exploring brand new possibilities at the Ethereum frontier. The EWASM is an Ethereum Foundation roadmap published in early 2019. We have fulfilled it in advance driven by our internal development team.

ParaState is prioritizing and emphasizing fast execution and delivery of novel research on production while committing to radical transparency and open-source values on our development journey.

Large developer community

All existing Ethereum smart contracts work on ParaState’s Ewasm VM (Pallet SSVM) without any change. ParaState expands the developer ecosystem by supporting 20+ programming languages to create Ethereum-compatible smart contracts. Examples include generic programming languages such as Solidity, Fe, Rust, and JavaScript, and domain specific languages (DSLs) such as MOVE, DeepSEA, and Marlowe.

Performance on steroids

Substrate-based blockchains, such as Polkadot parachains, already enjoy much higher TPS (transactions per second) than Ethereum. For a smart contract platform, compute performance is more important than TPS throughput. ParaChain utilizes the SSVM, recognized by IEEE Software as the fastest software execution sandbox, to execute smart contracts.

Substrate + Ethereum

ParaState provides a smart contract virtual machine (VM) for all Substrate-based blockchains. ParaState’s Pallet SSVM is a leading implementation of Ethereum flavored WebAssembly (Ewasm). By installing the Pallet, any Substrate blockchain can become Ethereum-compatible while taking full advantage of the modern WebAssembly ecosystem. The Pallet SSVM development is partially funded by a grant from the Web3 Foundation, and the team consists of Substrate Ambassadors.

Built-in DeFi infra

ParaState comes with core DeFi infrastructure built-in, including the Uniswap exchange, stable coins, lending protocols, as well as price oracles. Those Ethereum DeFi software applications are already ported and adapted to ParaState’s Ewasm VM to enjoy higher performance and interoperability with the WebAssembly ecosystem.

A token backed by developer treasuries

ParaState pioneers an innovative model for sustainable and decentralized open source software development. All Substrate blockchains that utilize the Pallet SSVM agree to collect a percentage of gas on all Ewasm transactions, and contribute it to a developer treasury managed by the ParaState foundation. The STATE token from ParaState is “backed by” a basket of native parachain tokens contributed to the developer treasure as ParaState gains developer adoption and use.

Why us? And the tradeoff of Layer 2

Recently I was being asked for numerous times what are the advantages to attract applications deploying on ParaState. Herein I’d like to write down this article to sort out pros & cons in details for your reference.

After almost five years development, today Ethereum is still the №1 public blockchain with most applications deploying on it, even it is running with limited performance and unsecured programming languages. There are also new public chain projects who aim to provide highly optimized and industrial standard infrastructure (WebAssembly) in order to solve the problems on Ethereum, like Solana, Near, Avalanche and Polkadot. These projects do implement WebAssembly standards, however they all face same issues which are lack of mature tooling support, and developers need to be educated to learn new programming languages. This takes time and you know Rome cannot be built in one day. That’s why all new public chains want to interact with Ethereum ecosystem closely to activate the onchained applications.

Do we have any approach to minus this gap and relieve the pain for developers?

Yes. One approach is to build a bridge to transfer assets from Ethereum to the new infrastructure chains for higher performance, like Solana (bridge assets via FTX), Near (bridge assets via Rainbow bridge), and Polkadot (bridge assets via Snowfork/Interlay). This approach cannot solve above issues perfectly, since it still requires developers using new programming languages to build applications on the new chains. The second approach is to provide seamless compatibility for existing Ethereum applications. Moonbeam and Plasm are other two projects within Polkadot ecosystem who aim at this goal. This approach really relieves a lot of pains for developers. As developer can use all mature tooling support on Ethereum to build Dapps, and they don’t need to rewrite the whole smart contracts. What’s the core part for the new layer 1 chains to achieve this goal? They just integrate the EVM pallet into its Substrate blockchain with some RPC developments. The EVM pallet is developed by Parity and it’s an EVM runtime modified version in order to deploy in Substrate framework. We see more and more parachain projects like Acala, Clover Finance, and Darwinia etc to integrate the EVM pallet into their parachains in order to interact with Ethereum ecosystem. It seems all parachains won’t have any differentiation in the runtime pallet infra in a foreseeable near future. I do agree it will benefit the whole Polkadot ecosystem to activate the liquidity at the very beginning. Will this approach attract talented developers coming to build new applications? Probably, but not so persuasive. Since if it’s the same smart contract runtime infra like the EVM runtime on Ethereum right now, developers would doubt how good the performance can gain by deploying on it.

Do we have a bit better approach?

Yes. That’s what ParaState is bringing into the industry. While supporting EVM pallet to provide seamless compatibility to all existing Ethereum applications, ParaState also provides developers a next-gen smart contract implementation environment, EWASM (Ethereum favored WebAssembly). These two infrastructure are ensured to talk to each other and sharing the same account system on ParaState. This is the differentiation ParaState provides to the developer community, to enable them surfing in the highly optimized industrial standard infrastructure and exploring brand new possibilities for Ethereum frontier. The EWASM is an Ethereum Foundation roadmap published in early 2019, we just fulfill it with internal development force in advance. Someone may still argue Ethereum has Layer 2 solutions to improve performance. Let’s discuss it in the next paragraph either.

_Through a unified developer community by supporting more popular programming languages, ParaState can bridge application and developer ecosystem between Ethereum and Polkadot, boostrapping the cross-chain software portability. If you are interested to dive deep into our EWASM infra, you may read about this article __“Diving into Ethereum’s virtue machine: the future of EWASM” _written by our developer program head Tim.

The tradeoff of Layer 2 solutions.

“The Bull Case for Ethereum Challengers”_ This article written by Kyle Samani from Multicoin Capital clearly pointed out the tradeoffs of current Layer 2 solutions. I don’t want to iterate all of them again. But I do want to emphasize no matter the Dapps choose zkRollup or Optimistics (two major Layer2 approaches), their protocols composability are broken. And composability is essential in the DeFi segment as it’s what the network effect lays. To deploy on ParaState, we can provide Dapps Layer 1 security, in the meanwhile maintaining the protocols composability that ensures capital flow fluidity is efficient._

Pros & Cons to deploy on ParaState

  • Pros:

1. Dapps can gain Layer 1 security, in the meanwhile maintaining the protocols composability.

2. With limited development efforts, developers can gain a high performance smart contract implementation environment to enable a better user experience.

3. You don’t have to abandon what you are doing on Ethereum, simply immigrate your source code and deploy it on ParaState, interacting with the whole rising Polkadot ecosystem. We call it “Mirror to launch”, and “Credit expansion” on ParaState. IMO, everyone likes credit expansion, especially the FED :).

Using Metamask to access ParaState’s TestNet

Setting up Metamask

Click here to install the Metamask extension on your browser. It can be installed using the Google Chrome Browser. Just click on the installation button and it should be automatically installed.

By default, Metamask supports the Ethereum blockchain, but since ParaState is compatible with Ethereum, it can be used the same way by setting a custom RPC endpoint.

Adding a Custom RPC Endpoint

In order to connect to the ParaState TestNet, a custom RPC Endpoint needs to be added. On the top click on the network you are connected to and then on Custom RPC:

Filling the Endpoint Information

Network Name: ParaState

New RPC URL:  https://rpc.parastate.io:8545

Chain ID: 123

Currency Symbol (Optional): STATE

The example below shows the configuration that needs to be done to connect to ParaState Testnet:

Click now on the Save button and your configuration should be done!

Creating a New Account

In order to create a new account, click on the icon on top as shown by the image below and then on Create Account:

On the next window, fill it with the account you want to choose and click on the Create button. You should have successfully created a new account!

Get some Testnet STATE tokens from the Official ParaState Faucet

Now go to the official ParaState test net faucet http://faucet.parastate.io Enter the ParaState address that you just copied, check the checkbox, and click Fund.

Now you will receive some STATE testnet tokens to this address. Remember that these are just test net tokens and cannot be transferred or sold on any exchange.

Here’s the summary of the Plato Testnet phases:

Phase 1 (March 15–21): Closed Internal Testing

Phase 2 (March 22 — April 11) Open for community members and developers to provide feedback & Release of Polis incentivised testnet

Phase 3 (April 11 — until required): Identical to mainnet configuration with testnet token to mainnet conversion to attract developers ready to launch with ParaState

Phase 4: Mainnet launch with a future rolling upgrade from the testnet

To date, Parastate is the only Polkadot Parachain to successfully implement a fully operational EWASM that is ready for public launch. ParaState brings Ethereum protocol support to the Substrate ecosystem. While it is backwards compatible with today’s EVM applications, it future-proofs the Ethereum protocol by bringing the LLVM and WebAssembly developer communities into the Polkadot ecosystem. It is your best choice among one-stop development platforms for next-gen Web3 applications. It is Ethereum on Steroids.

You can find more information about ParaState in our Whitepaper 1.0

Whether you are a community member, ambassador, Polkadot user, Substrate or Solidity developer, decentralized app, or staking service, we look forward to engaging you (get in touch: marketing@parastate.io).

Would you like to earn TOKEN right now! ☞ CLICK HERE

How and Where to Buy ParaState (STATE)?

STATE has been listed on a number of crypto exchanges, unlike other main cryptocurrencies, it cannot be directly purchased with fiats money. However, You can still easily buy this coin by first buying Bitcoin, ETH, USDT from any large exchanges and then transfer to the exchange that offers to trade this coin, in this guide article we will walk you through in detail the steps to buy STATE

You will have to first buy one of the major cryptocurrencies, usually either Bitcoin (BTC), Ethereum (ETH), Tether (USDT)…

We will use Binance Exchange here as it is one of the largest crypto exchanges that accept fiat deposits.

Binance is a popular cryptocurrency exchange which was started in China but then moved their headquarters to the crypto-friendly Island of Malta in the EU. Binance is popular for its crypto to crypto exchange services. Binance exploded onto the scene in the mania of 2017 and has since gone on to become the top crypto exchange in the world.

Once you finished the KYC process. You will be asked to add a payment method. Here you can either choose to provide a credit/debit card or use a bank transfer, and buy one of the major cryptocurrencies, usually either Bitcoin (BTC), Ethereum (ETH), Tether (USDT)

SIGN UP ON BINANCE

Step by Step Guide : What is Binance | How to Create an account on Binance (Updated 2021)

Next step - Transfer your cryptos to an Altcoin Exchange

Since STATE is an altcoin we need to transfer our coins to an exchange that STATE can be traded. Below is a list of exchanges that offers to trade STATE in various market pairs, head to their websites and register for an account.

Once finished you will then need to make a BTC/ETH/USDT deposit to the exchange from Binance depending on the available market pairs. After the deposit is confirmed you may then purchase STATE from the exchange: Uniswap

Apart from the exchange(s) above, there are a few popular crypto exchanges where they have decent daily trading volumes and a huge user base. This will ensure you will be able to sell your coins at any time and the fees will usually be lower. It is suggested that you also register on these exchanges since once STATE gets listed there it will attract a large amount of trading volumes from the users there, that means you will be having some great trading opportunities!

Top exchanges for token-coin trading. Follow instructions and make unlimited money

https://www.binance.com
https://www.bittrex.com
https://www.poloniex.com
https://www.bitfinex.com
https://www.huobi.com
https://www.mxc.ai
https://www.probit.com
https://www.gate.io
https://www.coinbase.com

Find more information STATE

WebsiteExplorerSource CodeSocial ChannelSocial Channel 2Social Channel 3Message BoardMessage Board 2Coinmarketcap

🔺DISCLAIMER: Trading Cryptocurrency is VERY risky. Make sure that you understand these risks if you are a beginner. The Information in the post is my OPINION and not financial advice. You are responsible for what you do with your funds

Learn about Cryptocurrency in this article ☞ What You Should Know Before Investing in Cryptocurrency - For Beginner

I hope this post will help you. If you liked this, please sharing it with others. Thank you!

#blockchain #bitcoin #crypto #parastate #state

What is ParaState (STATE) | What is ParaState token | What is STATE token

What is State? How to use It?

In this lecture, we are going to learn what is state and how to use it in react component. We are going to see how to make react component more powerful with the state.

Subscribe: https://www.youtube.com/channel/UCrG2Z0usOCCdUTAr4D1A8mw

#state #javascript

What is State? How to use It?

excelr Tuhin

1614100693

Home - Sky Marketing

We are one weeks away from December and with it the Christmas bonus. However, it is necessary to remember that the bonus is not only a benefit that by law all workers must receive, it is also the result of the effort of the whole year and it is important to take care of it so that it does not disappear in the fury of the holidays.
Here are 4 tips to help you make the most of your Christmas bonus.

If you are going to spend, make a budget: It is inevitable that you want to use the bonus to make some purchases, but before taking out your wallet, make a plan. Identify the needs that you must cover and the amount that you will allocate to each of them and, above all, try to adhere to the plan to avoid compulsive purchases.
Sky Marketing strives to be Pakistan’s biggest real estate developer ever, guaranteeing the highest international standards, prompt execution, and lifetime customer loyalty. With projects like park view city islamabad location.

Suppress your inner Santa: Every year the spirit of Christmas takes over you and you become the Santa to your family and friends? Be careful, this practice can make a large part of your Christmas gift disappear in the blink of an eye. Make a list of the people you really want to gift to and set a budget for each of those gifts.

Catch up on your debts: Most personal finance experts recommend using a percentage of your Christmas bonus to heal your debts, this will give you the opportunity to start the year with a clean credit history, and what better gift!
Start saving: An income like the Christmas bonus is an impulse to start a savings plan, which will not only allow you to reach 2016 with a mattress to avoid the dreaded January cost, it will also allow you to be prepared for any eventuality throughout of the year. Experts recommend saving 30% of this income and setting a realistic goal for the next 12 months.

With the Christmas bonus, the end of the year becomes an excellent time to rethink your personal finances and goals. You know what it says, new year; new life.

#real #state #skymarketing

Home - Sky Marketing

Borish John

1609331096

Brother printer in error state how to fix? | Brother Support

Are you using Brother printer? and having any technical issues i.e. printer show error stateprinter show error state") message, and want to fix it. can follow the steps in this post can guide you all with no longer process.

#printer #in #error #state #fix