fabiochiu/medium-articles huggingface dataset:
Remove Occurrences of Elements From a List
By: Siddhant Sadangi
Tags: Code, Programming, Interview Questions, Algorithms, Python

On to the Code!

First we import the necessary libraries:

import random

import numpy as np

from collections import Counter

Then we generate a random list of any integers between one and nine, of any specified size:

Getting the frequencies of all the elements of the list:

According to our problem statement, for n=3, the output should be

[4, 9, 2, 7, 1, 6, 6, 7, 1, 1, 7, 3, 6, 3, 5, 9, 9]. All occurrences of an element after its third occurrence should be deleted. In our case, only 7 and 6 qualify as only they have a frequency greater than 3.

We create an empty list to store the output, and an empty dictionary which we’ll use to store the element frequencies:

op = []

freq = {}

Then we create a loop to iterate through the elements of the list. If the item already exists in the keys of freq , we increase its frequency by 1 , else we add it to freq with a frequency of 1 :

for item in ip:

if item in freq:

freq[item] += 1

else:

freq[item] = 1

Now, we have to check if the frequency of the item is less than or equal to the threshold. If yes, we append it to the output list op , else we skip it. For the first occurrence of an item, we can directly append it to op without any check:

for item in ip:

if item in freq:

freq[item] += 1

if freq[item] <= n:

op.append(item)

else:

freq[item] = 1

op.append(item)

Wrapping this in a neat little function which will accept the list and the threshold:

def remove_nth(ip, n):

op = []

freq = {}

for item in ip:

if item in freq:

freq[item] += 1

if freq[item] <= n:

op.append(item)

else:

freq[item] = 1

op.append(item)

return op

Now we can just call this function, pass the list and the threshold, and get a new list with the extra occurrences removed:

In this case, all occurrences from after the third occurrence have been removed from the list. To verify:

We see that the frequencies of 7 and 6 are now down to 3 each, from 5 and 4 respectively. The frequency of no other element has been affected.

Also, max(Counter(op).values()) verifies that no element occurs more than thrice in the modified list.

Calling the same function with a threshold of 1 will just give all the unique elements of the list:
hello world
By: On The Beach
Tags: Finance, Interview Questions, Job Hunting, Job Interview Tips, Job Interview Questions

Dear Friend,

Congrats on finding my not-so-secret blog as I go through job interviews!

In case you were wondering, the phrase “on the beach” is consulting-lingo for being “on the bench” (AKA unprofitable to a consulting firm). Since I am trying to get OUT of consulting and into more of a FP&A role (ideally at a tech firm), I thought the name was somewhat fitting.

In my 30-ish years of living, I’ve noticed lately that I have a penchant for stating very ambitious goals but not adequately following through. For example:

At 22, I was introduced to SQL and my friend mentioned that it would be a useful skill to learn

At 25, I learned about options trading and wanted to become a full-time derivatives trader

At 28, after a few successful trades, I thought I would become a full-time crypto trader

I now firmly believe that starting something but not finishing is a sign of a fixed mindset. It’s time for me to exhibit a growth mindset and see things through the end (or at least to a satisfactory point) as opposed to giving up when the going gets tough.

This morning on the bus, I was thinking about how my developer friend Matt was very clever for creating a list of his interview questions — he eventually ended up at Google. Considering that most people want a stable W-2 job, this list is an incredible value-add for anyone planning to undergo software engineering interviews…but does such a list even exist for the finance field?

In my current search for a new FP&A/Financial Analyst role at a tech firm, why can’t I draw upon the knowledge and experiences of others who are also currently interviewing? Why aren’t there any good interview books preparing finance professionals for real-world interview questions?

Then it dawned on me — since I have to go through the process myself anyway, I might as well report back to the world on my findings. Knowledge should be democratized and awesome companies like Google do a great job at exactly that. This could be my chance to contribute to the world!

But then a creeping thought lingered at the back of my mind: what if this is just another endeavor that you eventually table and never bring to fruition? What if you never even get another job after your current consulting gig?

I know it’s a tough world out there, KC, but cheer up cupcake — you can rest knowing that tomorrow is a new day and a new opportunity.

With the goal of compiling all of this into something else later, this site is just so I will keep track of my interviews and the questions they ask so that it can benefit you, the jaded finance interviewee.

Looking forward to going on this journey with you!

- KC
C++ Interview Questions & Answers Part-I (Fresher)
By: Vivek Auti
Tags: Oops Interview Questions, Oop Concepts, Interview Questions, Cpp

Hi Freshers,

After attempting campus placement drives and interviews with many companies. I have found a list of questions that are asked frequently in many companies. I will try to cover them in multiple parts. Here is the first part.

Q.1) What are class and object in C++?

A class is a user-defined data type that has data members and member functions.

An object is an instance of a class.

Q.2) What are the different data types in C++?

Primitive Datatype: char, short, int, float, long, double, bool, etc.

Derived datatype: array, pointer, etc.

Enumeration: enum

User-defined data types: structure, class, etc.

Q.3)What is the difference between C and C++?

C is a procedure-oriented programming language. C++ is an object-oriented programming language. C does not support polymorphism, encapsulation, and inheritance.C++ has support for polymorphism, encapsulation, and inheritance as it is being an object-oriented programming language C in general known as function-driven language. On the other hand, C++ is known as an object-driven language.

Q.4) What are Pillars of OOP?

Refer: https://vrauti13.medium.com/features-of-object-oriented-programming-5f52df746078

Q.5) What is operator overloading?

operator overloading is modifying the default meaning of the operators like +, -, *, /, <=, etc.

Q.6) Which operators cannot be overloaded?

?:, ::, . and sizeof() operators cannot be overloaded

Q.7) What is a constructor in C++?

The constructor is a member function that is executed automatically whenever an object is created. Constructors have the same name as the class name.

Q.8) What is a virtual function?

A virtual function is a member function in the base class that you redefine in a derived class. When the function is made virtual, C++ determines which function is to be invoked at the runtime based on the type of the object pointed by the base class pointer. A virtual function is declared using the virtual keyword.

Q.9)What is the inline function?

A function that eliminates the function calling overhead of a traditional function by replacing a copy of the code of that function at each point where the function is called at compile time

Q.10) What is call by value?

A copy of the parameter is passed to the function call. For these copied values a new memory is assigned and changes made to these values do not reflect the original variable.

Q.11) What is call by reference?

An address of the variable is passed to the function call. So changes made in the parameter alter the passing argument.
C++ Interview Questions & Answers Part-II (Fresher)
By: Vivek Auti
Tags: Interview, Cpp, Oop Concepts, Interview Questions, Oop

Here is part two of Frequently asked C++ Interview Questions and Answers. I Hope, It would be helpful for all the freshers who wish to get entry-level jobs in the Software industry.

Q.1) What is an abstract class?

A class is called an abstract class whose objects can never be created. We can make an abstract class by placing pure virtual functions inside it.

Q.2) What is a Pure Virtual Function?

A pure virtual function is a function declared in the base class that has no definition relative to the base class.

For Ex: virtual void display() = 0;

Q.3) What is namespace in C++?

The namespace is a logical division of the code which is designed to stop the naming conflict. The namespace defines the scope where the identifiers such as variables, class, functions are declared.

Q.4)What are tokens in C++?

keyword, identifier, literal, constant, and symbols in C++ are collectively called tokens.

Q.5)What is std?

Std is the default namespace used in C++.

Q.6) What are access specifiers in C++?

Public: Accessible from anywhere. Private: Only accessed within a class. Protected: Accessed within the class and by a derived class.

Q.7) What is the difference between an array and a list?

An array is a collection of homogeneous elements while a list is a collection of heterogeneous elements.

Array memory allocation is static and continuous while List memory allocation is dynamic and random.

Q.8)What is the friend function?

A friend function is a function that is not a member of the class but can access the private and protected member of the class provided it is listed within the class.

Q.9) What is this pointer?

This pointer holds the address of the current object.
Vmware Interview Question
By: Vipul Gupta
Tags: Coding, Knapsack Problem, Interview Questions, Vmware, Java

This is the question recently asked for the Vmware MTS-2 Position from me.

You will be given a list of articles with their page lengths and intellectual value coefficients. Given a limit to the number of pages you can read in a day, determine the maximum intellectual value you can achieve during one day.

For example, your articles are of lengths articles =[2,2,3,4] and they are of intellectual value iv =[2,4,4,5]. If you can read p=15 pages in a day, what should you read? You have to read each article twice to gain value.Associating 2*articles[i] with iv[i], The maximum combined length of articles read twice is14 pages and there are two ways to get there: readarticles[0], articles[1] and articles[2] for a total intellectual value of 2 + 4 + 4 = 10 or read articles[2]and articles[3] for a total of 4 + 5 = 9. Our maximal learning is 10 intellectual value points.

Complete the function maximum learning. The function must return the integer value representing the maximum intellectual value you can get in one day of reading.

This is the simple question of 0–1 Knapsack.

Below is the implementation.

public static int maximumLearning(List<Integer> iv, List<Integer> articles, int p) { int size = articles.size(); int[] art = new int[size]; int[] ivs = new int[size]; for(int i=0;i<size;i++){

art[i] = articles.get(i)*2;

ivs[i] = iv.get(i);

}

return knapSackTopDownCode(ivs, art, p, size);

} public static int knapSackTopDownCode(int[] val, int[] wt, int W, int n) { int mat[][] = new int [n+1][W+1]; for(int i=1;i<n+1;i++) { for(int j=1;j<W+1;j++) { if(i==0 || j ==0)

mat[i][j] =0;

else if(wt[i-1]<=j) {

mat[i][j] = Math.max(val[i-1]+ mat[i-1][j-wt[i- 1]],mat[i-1][j]);

}

else {

mat[i][j] = mat[i-1][j];}

}

}

return mat[n][W];

}

}

Happy Coding!!
Verizon spring boot interview questions
By: Online Interview Questions
Tags: Verizon, Interview Questions, Spring Boot

About Verizon

Verizon is one of the largest cell phone carriers companies in the USA. They run their business with Cellco Partnership using the name Verizon Wireless.

Here we have listed some Verizon spring boot interview questions that are asked in Company.

1. What is Spring boot?

Spring Boot is an open-source Java-based framework used to create a micro Service. It is developed by Pivotal Team and is used to build stand-alone and production-ready spring applications.

2. What are Actuator in Spring Boot?

Spring Boot Actuator. Spring Boot Actuator is a sub-project of the Spring Boot Framework. It contains the actuator endpoints (the place where the resources live). We can use HTTP and JMX endpoints to manage and monitor the Spring Boot application.

3. Can you use jquery with Spring boot?

Yes, we can use Jquery with Spring boot Applications

4. What is the Spring Boot Initilizr?

Spring Initializr is ultimately a web application that can generate a Spring Boot project structure for you. It doesn’t generate any application code, but it will give you a basic project structure and either a Maven or a Gradle build specification to build your code with.

5. What is Spring Boot CLI?

Spring Boot CLI is a command-line abstraction that allows us to easily run Spring micro-services expressed as Groovy scripts.

6. What are Annotations Spring Boot?

Spring Boot Annotations is a form of metadata that provides data about a program. In other words, annotations are used to provide supplemental information about a program. It is not a part of the application that we develop. It does not have a direct effect on the operation of the code they annotate.

7. What is thymeleaf?

Thymeleaf is a modern server-side Java template engine for both web and standalone environments.

Further Reading: 30 Best Spring Boot Interview questions
How to optimize your Knowies profile
Tags: Bookmarks, Social Media, Network, Knowies, Knowledge

First of all we would like to say that Knowies is here to support you regardless of whether your goals are business, personal, public or private. As a user, we want to leave you completely free in this choice.

However, a complete Knowies profile, can generate a boost for your personal and / or business development. The more you complete your profile, the more we are able to help you find the right content and people and help you to be found.

To make your profile as complete as possible, there are a number of actions that we advise you to do.

First we advise you to enter or change your full name and pitch and add a profile picture, adding a profile photo gives a direct boost to your profile.

Both can be found under your avatar / profile picture on the left side of your screen. By selecting the pencil icon a pop-up will appear in your screen.

After you completed the first steps it is time to fill in your resume, you can find your resume on your profile page by clicking on your profile picture. Halfway through your profile page you will find your resume and 3D dynamic profile where you can make adjustments in your resume and 3D dynamic profile by clicking the pencil icon. To edit your resume select Edit Bio as shown in the image.

To take full advantage of your experience, we recommend that you complete your profile as much as possible.

Last but not least, form your personal unique 3D dynamic profile. At Knowies we are convinced that you have much more interests and qualities than you can show in your standard resume. Based on the public content that you post on Knowies, we create a 3D dynamic profile for you.

So what do you have to do to create this dynamic profile? Simple, start collecting and sharing content, we take care of the rest.

You can adjust this profile to a limited extent on the basis of the tags that match your profile. To adjust your 3D dynamic profile once again click the pencil icon and select Edit tag cloud.

You can remove tags here and add other tags later. Please note, this concerns tags that we suggest for you, it is not possible to create tags yourself. Important to know is that we do not display content that you save as private in your profile.

Knowies Chrome Extension: https://chrome.google.com/webstore/detail/knowies/pkkmmclebdkjeogkjgpfhplogpgdhcnn

Knowies Firefox Extension:

https://addons.mozilla.org/nl/firefox/addon/knowies/
How to personalize your Knowies dashboard
Tags: Bookmarks, Social Media, Network, Knowies, Knowledge

You can fully personalize your Knowies Dashboard on the desktop version, so you can decide for yourself what you will get to see on your homepage. Changes will also be visible in the mobile APP. For now it is not yet possible to personalize your dashboard via the mobile APP.

Personalizing your dashboard can be done on the home page by clicking on “Personalize dashboard” in the top right of your screen, shown under the arrow in the image.

Once you select Personalize dashboard you can sort the various elements and put them in the order you want by dragging them or by clicking the arrows. You can also remove elements with the cross icon.

If you want to add elements (collections, community’s, topics and people) to your dashboard you can select the add new button on top of the screen. After you select the button can select different options to add to your dashboard.

After any change you make you have to press the save button on the right top of the page.

Go create your own perfect dashboard and please let us know if you have any suggestions!

Knowies Chrome Extension: https://chrome.google.com/webstore/detail/knowies/pkkmmclebdkjeogkjgpfhplogpgdhcnn

Knowies Firefox Extension:

https://addons.mozilla.org/nl/firefox/addon/knowies/
An analogy to explain OS detection by NMAP
By: Divyansh Bhatia
Tags: Namp, Fingerprinting, Scanner, Operating Systems, Network

When you use NMAP to scan machines, there is an option to try and detect the OS of the target machine. How does it work? Here’s a helpful analogy.

Imagine you are playing with two mammals, a chimpanzee, and an orangutan. You are conducting this experiment in a double-blind format. You throw a ball towards each. The balls are of the same make. They both throw the balls back. If we examine these balls, they have fingerprints on them. These fingerprints can help identify which animal thew the ball back.

You see, it doesn’t depend on the information you send. It depends on what information the target machine sends back. NMAP sends a ping to the target machine with the intention of identification. The target machine responds by sending a ping back to NMAP. Now, every OS crafts ICMP ping packets very differently. The construction of these packets can help identify the target OS. NMAP has a database of a lot of operating system responses. NMAP uses this database to support the identification process.

Some operating systems have a similar make. Take, for example, Debian and Ubuntu. At their core, both these operating systems are Linux. Therefore NMAP can confuse them for each other.

Another interesting point to note here is that an OS evolves and changes. While Windows 10 1903 and 10 2004 are very similar in how they handle networks, they return different fingerprints.

In the end, NMAP proves to be very useful in helping identify operating systems.
Barkis Network 2.18–3.03 Biweekly Report
By: Barkis Network
Tags: Public Chain, Network, Blockchain, Blockchain Development, Blockchain Technology

Thanks for your understanding and company all the time. Barkis Network aims to build a distributed business application value network based on blockchain technology. It is convinced that Barkis community will develop better with your participation.

Here is the Barkis Network progress between 2.18–3.03:

Progress in public chain development

1. Upgraded Barkis mainnet to support issuing custom token function.

2. Performance optimization.

Progress in wallet development

1. Android wallet upgrade, together with the public chain upgrade, now supports custom token viewing and transfer.

2. Android wallet supports issuing custom token.

Blockchain browser update

1. Upgraded of blockchain browser to support the issuance and browsing of custom tokens.

2. Bug fixes.

Progress in MasterNodes Plan development

1. Delegated (voting) functionality for MasterNodes was released.

Barkis Network will continue to be a responsible project as always, and create more value for users and the industry in the future. The future has come, let us shout for the Barkis Network!
Dynamic Business Environment Backing the Mobile Virtual Private Network (VPN) Sector
By: Punit Shah
Tags: Virtual Private Network, VPN, Network, Mobile, Mobile Vpn

With the rising usage of smart devices, such as smartphones, tablets, and laptops, business entities are focusing more on mobile security and mobility solutions. The key factors driving the growth of the mobile virtual private network (VPN) sector are the changing business environment, increasing cyber-attacks, emerging concerns over data loss, and the indispensable need to meet the desired standards.

Further, MVPN-powered remote accessibility offers flexibility to employees in a company, which can be a prominent factor in improving productivity and communication. These days, companies need centrally-managed and simplified remote offices, which help them provide secure and reliable data access to their employees at low costs. Mobile VPN has transformed the conventional method of accessing data by replacing laptop with pocket-sized devices. These devices combine small computers with the cellular phones that are compatible with common office applications, such as word processing, e-mail, and presentations.

Research Relevant Queries@ http://bit.ly/2Y4xaRm
Why you cannot have subnet with less than 5 ips in AWS ?
By: Rohit Garg
Tags: Cloud, Network, AWS, Vpc

Why you cannot have subnet with less than 5 ips in AWS ? Rohit Garg Apr 9·2 min read

To add a CIDR block to your VPC, the following rule apply:

The allowed block size is between a /28 netmask and /16 netmask

Since AWS Reserves 5 ip addresses from your subnet you cannot have /30 or /31 as your subnet as that have less than 5 address .

/29 is valid can be used but you are left with 3 address for you Setup.

Please check below table

SUBNET

The first four IP addresses and the last IP address in each subnet CIDR block are not available for you to use, and cannot be assigned to an instance. For example, in a subnet with CIDR block 10.0.0.0/24 , the following five IP addresses are reserved:

10.0.0.0 : Network address.

: Network address. 10.0.0.1 : Reserved by AWS for the VPC router.

: Reserved by AWS for the VPC router. 10.0.0.2 : Reserved by AWS. The IP address of the DNS server is the base of the VPC network range plus two. For VPCs with multiple CIDR blocks, the IP address of the DNS server is located in the primary CIDR. We also reserve the base of each subnet range plus two for all CIDR blocks in the VPC. For more information, see Amazon DNS server.

: Reserved by AWS. The IP address of the DNS server is the base of the VPC network range plus two. For VPCs with multiple CIDR blocks, the IP address of the DNS server is located in the primary CIDR. We also reserve the base of each subnet range plus two for all CIDR blocks in the VPC. For more information, see Amazon DNS server. 10.0.0.3 : Reserved by AWS for future use.

: Reserved by AWS for future use. 10.0.0.255 : Network broadcast address. We do not support broadcast in a VPC, therefore we reserve this address.

If you create a VPC or subnet using a command line tool or the Amazon EC2 API, the CIDR block is automatically modified to its canonical form. For example, if you specify 100.68.0.18/18 for the CIDR block, we create a CIDR block of 100.68.0.0/18 .

Reference:
Connections
By: Ananya Ashok
Tags: Connection, Togetherness, Humanity, Survival, Network

Photo by Matus Karahuta on Unsplash

Essential to our survival as individuals, as a race are — Connections.

Like hangs a spider, from its threads of gossamer

So, do we, in our lives suspend through connections.

In this world constantly changing — swiveling as I write,

Perhaps its temperature saw an infinitesimal rise.

Our shard of existence scales just to a moment

For the Universe and for us, fills entire lifetimes.

Like waves shaping a sandy shore —

rising, giving and withdrawing,

We see also changes in us —

the way we speak, and the way we live.

Our brains still wired to our tribes wanting to sleep side-by-side.

Yet, like uprooted plants, we are missing our quorum senses,

And trying to find soil in an ocean floating uncertainty at its abyss.

To weather this change, one must find connection –

To another human, another soul, and maybe even to a cyborg,

A plant, an animal, and why exclude an android?

Woven in this web where not all threads are seen

As beings, we won’t be wrong

To find connections that help survive.

Taking fragile to reach strong.

As unexpected as may seem, there is comfort;

In an old recording of voice or in Alexa finding your song

And in listening to a tree speaking the language of the wind.

There is connection —with a crab scurrying across the sand.

With the cat curled up in a corner,

And with the stranger across the street —

You’ve but exchanged mere glances, an occasional smile.

Through such connections, we survive.
Announcement on updating NerveNetwork to V1.6.0
Tags: Binance, Cryptocurrency, Updates, Nerve, Network

Dear NerveNetwork community,

After launching NerveDEX and implementing cross-chain with the NULS and ETH networks, we are thrilled to announce that NerveNetwork has successfully opened up the heterogeneous cross-chain function with Binance Smart Chain (BSC). The new version was officially released on the NerveNetwork main-net on November 16, 2020 15:00 (UTC +8).

The new function will take effect at the height of 5,600,000 , Estimated November 19, 2020 02:00（UTC+8 ).

About the V1.6.0 version update

Support BSC network cross-chain.

Open up the ETH and BSC assets cross-chain channel and enable access for mutual transfer between the networks.

Open up the BSC and NerveNetwork assets cross-chain channel and enable access for mutual transfer between the networks.

Open up the NULS and BSC assets cross-chain channel and enable access for mutual transfer between the networks.

The virtual banks need to recharge BNB to the package addresses.

2. Support BNB/HT/OKB price feeding.

3. Support BNB/HT/OKB immediate staking

(The total amount of BNB is 100,000, HT and OKB is 200,000)

4. Dynamic service fees for heterogeneous cross-chain transactions：

Pay service fees based on the actual cost of cross-chain transactions.

All the service fees are given to the processing node.

When the set service price is lower than the current network average, the transaction will be delayed.

5. Increase the red card penalty buffer time to avoid node owners not having enough time to deal with the issues.

6. Reduce the creation service fee of DEX trading pairs from 2000NVT to 200NVT.

7. Reduce the cross-chain transaction fee among the ecosystem projects, from 0.3NULS to 0.1NULS
How Sensors Improve Transmission and Distribution Network Management
By: Applied Technology Review
Tags: Technews, Networking, Network, Technology, Sensors

While distribution and transmission network inspection has largely been a manual process, electric utilities are using sensor technology to achieve improved levels of speed and accuracy.

FREMONT, CA: Power delivery systems are among the most important and most diverse, remotely located investments. There are several challenges that electric utilities face with their cable and distribution assets. The industry is in its effort to deploy sensor technologies and therefore the associated innovations needed to assist electric utilities in addressing challenges associated with transmission and distribution.

The implementation of sensors within the cable and distribution networks will leave the monitoring and communication of kit conditions continuously. Knowing that a cable or distribution asset is within the risk of failure will allow actions to be taken to deal with the security of both utility personnel and staff. as an example , with sensor-based monitoring, the interior discharge activity of transformers might be detected and communicated, allowing barriers to be put in situ to scale back the danger for the personnel until maintenance action is taken.

Improved knowledge of transmission and distribution equipment conditions and stresses that they’re subjected to will allow asset managers to manage the distribution network better. Sensor data are often used with performance information, failure database, and operational data to allocate resources better. The rating of transmission components is influenced by several factors, including weather , loading history, and component configuration. to deal with this complexity, sensors are often used, and utilities can gain real-time knowledge of the component condition.

After an occasion takes place, investigating teams often have less information to know the basis cause. This limits the power to deal with similar situations or to enhance strategies. But sensor deployment in transmission and distribution networks could provide the knowledge needed to spot the basis cause and even help understand the patterns in order that the strategy are often modified to stop future occurrences.

By quickly identifying potential problems, electric utilities can address areas in transmission and distribution where safety concerns are most imperative, and therefore the infrastructure might be in danger otherwise. These proactive initiatives will allow utilities to successfully kick starter numerous efforts to enhance the resiliency and reliability of their distribution and transmission networks.

Follow us In Social Media

https://twitter.com/AppliedReview/
Node Embeddings
By: Till Richter
Tags: Artificial Intelligence, Getting Started, Graph, Network, Machine Learning

Embedding Techniques

We followed embedding techniques, that besides the popular Graph Neural Networks, lie foundation for most of the novel methods in node embeddings. For comparison, we abstain from modern methods for tuning the models even more. This work therefore provides comparison for underlying techniques of node embedding. The models are subdivided in different similarity scores, metrices that show proximity of nodes in the graph.

Image 1: Loss for Node Embeddings, Image by Author

Bernoulli (4 Models)

For the Bernoulli models a similarity score of the true graph is given in the form of the adjacency matrix. Thereby an entry is 1, if the two nodes are connected, and 0 else. The decoder gives the similarity score in embedded space, which can be a sigmoid, exponential, gaussian or distance-based embedding. Therefore, we model the loss to generate the adjacency given the embedded matrix

Bernoulli Likelihood, Image by Author

Where the kernel can be either

Sigmoidal, Image by Author

Exponential, Image by Author

Gaussian (also RBF Kernel), Image by Author

Distance based #2, Image by Author

To train the model, ie. let the embedding be as close as possible to the original graph, the log likelihood is maximized.

Bernoulli Likelihood, Image by Author

KL Divergence (3 Models)

KL divergence is a metric how different a probability distribution is from another. In our case, the graph is modelled as a probability distribution, ie. The rows of the graphs matrices sum to one. Different models for capturing the true graphs characteristics in a probability distribution are used, namely Personalized Page Rank, Sum of Power of Transitions and the Transition matrix. Of course also the graph in embedded space needs to be a valid probability distribution in order for KL divergence to make sense, therefore Softmax is applied on the embedded nodes. For the embedded graph to be as proximate to the original graph, or more precisely to the graphs characteristics captured in the respective encoders, the KL divergence is minimized.

KL Divergence, Image by Author

SVD (7 Models)

In the Singular Value Decomposition the well-known method is applied on different matrices that can capture the graph’s characteristics. With that, the matrices are embedded in lower dimensional space.
Implement global loading and error state with redux, thunk, routine and TypeScript
By: Thor Chen
Tags: Redux Thunk, Typescript, React, Redux

Implement global loading and error state with redux, thunk, routine and TypeScript

When dispatching async actions with redux-thunk , we usually have three actions for each thunk: REQUEST , SUCCESS and FAILURE . Imagine we have a thunk to fetch data, we would dispatch FETCH_DATA_REQUEST before we send the API request, then dispatch FETCH_DATA_SUCCESS when the request succeeds or dispatch FETCH_DATA_FAILURE when the request fails.

To store the loading state, we probably have a isFetching in our redux state tree as shown in the redux documentation and we change this state when we receive the REQUEST , SUCCESS and FAILURE actions.

If you have followed this way to implement the loading state, you probably already find that it is really tedious to write the boilerplate code again and again for each thunk.

Luckily, we now have a shiny small library called redux-thunk-routine (https://www.npmjs.com/package/redux-thunk-routine) to remove those boilerplate code that defines and dispatches actions while having better static type check at the same time (when using TypeScript).

But how about the isFetching state? Do we still need to write those repetitive code in reducer? Let’s have a look at a more elegant solution and take more benefits from using redux-thunk-routine — action names are defined in a standard pattern you can safely rely on.

For each routine, the library defines three actions by appending standard suffixes to the routine name. Let’s say we implement “fetch data” thunk using redux-thunk-routine : it will define three actions for by default: FETCH_DATA/REQUEST , FETCH_DATA/SUCCESS and FETCH_DATA/FAILURE .

Assume that all our actions are defined by redux-thunk-routine , then we can reduce them in a centralized manner to set isFetching state. Actually, to make the state more flexible, we will declare the loading state as a dictionary-like object — the routine name is the key, and the value(as boolean) indicates whether the routine is loading.

To express it in TypeScript, we write the type definition below:

Listing 0: Type Definition of Loading State

Then we can write the reducer to catch and handle all actions from the loading state perspective:

Listing 1: Reducer for Loading State

To use the state, we have the selectors below:

Listing 2: Selectors for Loading State

As we can see, the design of the loading state and selectors make it super flexible whenever we want to know if A GIVEN , ANY or SOME routines are loading.

Amazingly, the same principle also applies to the global error state. This time, let’s have a look at the implementation of all related parts in one file (using ducks):

Listing 3: Ducks for Error State

Again, you can find the demo code on GitHub and try the demo app online.

Thanks for reading :)
React-Redux-Saga Fish model
By: Ashish Kirodian
Tags: React, Redux, Redux Saga, Front End Development

Can you please “dumb down” this and explain again?

I have come across this request many of the times when i had to explain the technology to someone who was from different background. Here dumbing down was basically, making them understand a specific topic by superimposing the process of how a technology works with the words or phrases that they can easily grasp.

For ex, If you had to explain a back end developer what Redux is, you will dumb down the explanation and tell him, “Redux is like a smaller and simpler version of database”.

The reason i am writing this article is, I wanted to dumb down the entire framework in use for front end development. I use React, Redux and Redux-Saga as the core technologies in my framework. Whenever I used to explain my colleagues and junior the same, I used to draw the diagram on a whiteboard.

During this process, i went a little creative and came up with “React-Redux-Saga Fish model”.

Trust me.. It looks like a fish to me

So, what i see is, The blue dotted area represents the face of the fish. The green area represents all other organs like brain, digestive system etc. And the orange area represents the tail.

Here, the Redux store is compared with the brain, react components with the face and redux saga with the tail of the fish.

See…. it looks like a fish!!

Now let us break the technologies and see what they are.

React:

So, React is a library which helps you in creating UI components using JavaScript. Here, an entire Web page is built by combining various smaller components which can be reused in some other page as well. The main reason, why React is loved by everyone is that it is comparatively faster than any other libraries out in the market. The reason for its speed is, the Reconciliation algorithm and Virtual DOM. The virtual DOM (VDOM) is a programming concept where an ideal, or “virtual”, representation of a UI is kept in memory and synced with the “real” DOM by a library such as ReactDOM. This process is called reconciliation.

That is the main reason i picked React to be the face of the fish.

Redux:

Redux is a global state management system. Here all kind of computation happen whenever you click a button or load a page. Redux kind of serves as a small database to all the components in your web page.

Redux-Saga:

Redux-Saga is a middleware that is used between react and redux. Redux Saga helps in capturing all the async HTTP request and responses that are bundled with the entire application and then divert it into Redux actions.

Thus, completing the fish anatomy i believe i have helped my colleagues and juniors to understand how the framework works.

If there are any mistakes in the above concepts, I am open for suggestions. If you have any doubts we can discuss as well.

I will be writing a detailed version of how these technologies interact with each other to form a framework.

K.Thanks.bye
Gear reducer selection method
By: Wei Zhao
Tags: Redux

The selection of gear reducers is a problem that many manufacturers have to face. To meet the actual needs and to reduce the production cost is a problem they must consider. Then Xiaobian is here to popularize the gear reduction for everyone. Machine selection knowledge.

1. The function and performance of the gear reducer:

First understand the model specifications, functional characteristics, protection type, rated voltage, rated current, rated power, power frequency, and insulation level of the gear reducer. These contents are important reference for users to correctly use, maintain and select the gear reducer.

2. The use environment of the gear reducer:

Mainly refers to the user needs to know the environmental conditions that the gear reducer will use, such as normal temperature, high temperature, high cold, corrosion degree, vibration, sand, altitude, electromagnetic pollution.

3. Practical application of gear reducer:

The user needs to know the characteristics of the gear to be used in the gear reducer. It should be selected according to actual needs, such as fans, pumps, air compressors, lathes, oil field pumping machines and other different machines have different characteristics, then the required gear reducer It is also different.

4. Control system of gear reducer:

In general, the gear reducer control modes include manual, automatic, local control, remote control, stand-alone operation, and centralized control of the production line. The startup mode includes direct, buck, star triangle, frequency sensitive varistor, inverter, soft start, etc., and the user needs to be clear about this.

Portal：https://www.zwgearbox.com/
Gear reducer common faults and solutions
By: Wei Zhao
Tags: Redux

Gear reducers are commonly used in a variety of mechanical equipment, and have been widely used in many industries. In actual production, some gear reducers may have abnormal malfunctions such as noise, wear and oil leakage. How to solve these faults?

In the long-term operation of the gear reducer, there are often faults such as wear and leakage. The most important ones are:

1. The bearing chamber of the gear reducer wears, which in turn includes the wear of the bearing housing, the bearing housing of the housing, and the bearing housing of the transmission.

2. The shaft diameter of the gear reducer is worn, and the main wear parts are in the shaft head and keyway.

3. The bearing position of the gear reducer drive shaft wears.

4. The gear reducer joint surface leaks.

For the wear problem of the gear reducer, the traditional solution of the enterprise is repairing after repair welding or brush plating, but both have certain drawbacks. For example, the thermal stress generated by the repair welding high temperature cannot be completely eliminated, which may cause damage to the material, resulting in bending or breaking of the gear reducer components.

Brush plating is limited by the thickness of the coating, and it is easy to peel off. The above two methods use metal to repair the metal, which can not change the “hard to hard” coordination relationship. Under the combined action of each force, it will still cause re-wear. Therefore, pay attention to the following items when using and maintaining the gear reducer.

1. The gear reducer adopts 460# medium load industrial gear oil, and the working environment temperature is 0~40°C.

2. After using the gear reducer for the first time for 100 hours, the inner cavity should be cleaned and replaced with new gear oil, and the oil should be changed every 2000 hours.

3. When disassembling the gear reducer, try to avoid hammering to avoid damage to normal parts.

4. If it is found that there is oil leakage in the shaft extension or joint of the gear reducer during use, the seals such as the skeleton oil seal should be replaced in time.

In short, most of the common faults of gear reducers are related to daily improper operation and maintenance. Therefore, in order to reduce the occurrence of gear reducer failures, in addition to purchasing high-quality products, it is also necessary to use them reasonably, and it is necessary to periodically perform gear reducers. Overhaul, cleaning and lubrication.

Portal：https://www.zwgearbox.com/
Redux introduces Hooks support
By: Rajesh Naroth
Tags: JavaScript, React, Redux, Hooks

And the world celebrates!

IMHO Redux is one of the best state management frameworks for React out there. My only problem with it? The bolierplate-y mapStateToProps, mapDispatchToProps and the connect function. Container components looked like a jumble of wires and connections. When I started with Redux, this was my biggest pain point. I loved the concept of Reducers and actions. But wiring up props like this never felt right. Well, worry no more.

// TodoListContainer.js

import TodoList from ‘./TodoList’ function mapStateToProps(state) {

const { todos } = state

return { todos }

} export default connect(mapStateToProps)(TodoList)

This is a simple example of a Container passing props to the components. And now you can do this:

// TodoListContainer.js

import TodoList from ‘./TodoList’

import { useSelector } from 'react-redux’ const TodoListContainer = () => {

const todos = useSelector(state => state.todos);

return <TodoList todos={todos} />

}

The developer experience is fabulous now. You know exactly what is happening. And yes, it is in fact returning a component. <TodoList todos={todos} /> beats connect(mapStateToProps)(TodoList) any time of the day. The magic is in these hooks:

useSelector(state => state.todos)

useDispatch()

useSelector() takes a mapping function that returns a part of the state tree.

How about an example that also wraps the dispatch around the actions and passes it along to connect()?

import TodoList from ‘./TodoList’

const mapStateToProps = (state) => {

return { todos: state.todos }

} const mapDispatchToProps = dispatch => {

return {

addTodo : () => dispatch ({ type: ‘add-something’ })

}

} export default connect(

mapStateToProps,

mapDispatchToProps)(TodoList)

This can be replaced with:

import TodoList from ‘./TodoList’

import { useSelector, useDispatch } from 'react-redux’ export const TodoListContainer = () => {

const todos = useSelector(state => state.todos)

const dispatch = useDispatch()

const addTodo = () => dispatch({ type: ‘add-something’ }) return <TodoList todos={todos} onClick={addTodo} />

}

useStore() is another hook that returns the whole store. It is not recommended.

So that’s it. Two hooks to improve your code readability. More details here:

Redux team immediately retired useActions() and useRedux() hooks after publishing it initially. This is still an alpha release. And I think we got it right. Let us summarize what we need to do to use Redux,

Define your action objects, action creators, write your reducers, combine them and create a store.

reducers = combineReducers(data1, data2)

store = createStore(reducers)

2. Wrap your app with the store provider

<Provider store={store}>

3. To access your reducer, use the hook in your functional component

data1 = useSelector(state => state.data)

4. To dispatch an action

dispatch = useDispatch()

dispatch(action)

Just five things to remember. Two of those you just set it once. Here is an example of the todos Redux app converted to Hooks.

https://codesandbox.io/s/00wk44rjxl
Themeable react native (Part 2) — Changing themes
By: Munene Evans
Tags: React Native, Styled Components, React, Redux

In Part one, we created a theme with base themes and various colour themes. We were able to serve the theme through redux and use styled-components to apply the theme.

Here, we are going to use redux to change the theme of the app to bring the app full-circle.

We will make changes to the login page to allow the user to select the theme they prefer. We will add two Pickers, one for the base theme and another for the colour options.

Actions

We first set up two action creators. The first receives a base theme object and sends a dispatch of type “CHANGE BASE THEME”. The second receives a colour theme object and also fires a dispatch of type “CHANGE COLOR THEME”

Reducer

The reducer discards the current theme object in the initial state and combines the theme object in the action payload with the parts of the theme that do not change

Login

Now we need to tweak the login page to allow the user to change the theme.

We import the theme objects from the store and the two action creators as well. Using mapDispatchToProps, we can access the functions from the Login Component.

We now add two selection inputs and populate them with the base theme and colour theme options respectively. When the user taps any option, we trigger a function that invokes the relevant action creator.

Conclusion

Users love products that they can make their own. Small customizations such as colour can go a really long way