fabiochiu/medium-articles huggingface dataset:
How to Generate Typescript Types for GraphQL in React Project
By: Ron Liu
Tags: React, GraphQL, Apollo Client

GraphQL codegen office logo

GraphQL is cool, it exposes the exact contract between frontend and backend in details.

However, when you try to use it, there is still gaps between GraphQL and the host programming language. For example, mostly frontend project is using typescript, while GraphQL is strong typed contract but still not typescript.

This situation is like when we develop SQL based application by using Java. At that time, we have ORM, stands for Object Oriented Mapping, which is a standard tool mapping object structure and sql relationship, and allow developer to access SQL database by knowing only JAVA or other object oriented languages. Do we have similar tool to map between GraphQL and typescript or other languages?

The answer is yes, it is graphql-codegen. (Although there are other tools for this goal, but graphql-codegen is definitely the most flexible and advanced one.

In this article, I am going to tell you what is graphql-codegen, and how to use graphql-codegen to generate typescript types and react GraphQL query/mutation hooks by using an example.
Tech Startup Interviews 101
By: Florian Ernoult
Tags: Recruiting, Startup, Technology, Hiring, Interview

Get to know the company

When it comes to knowing the company, ignorance is not bliss.

I can’t count the number of times I’ve asked an interviewee, “So what do you know about our company? Have you had a chance to get on our Website and start a free trial of our tool?” …

…to which she confidently replies: “Hm. No. I didn’t have the time with all those interviews I’m doing lately. But I think that you ***do something with email automation***, is that right?”

Ouch. That’s like being on a first date saying “Hey, you’re John right? Oh, Steve, sorry I didn’t have time to check your name, with all those dates I have lately… you know how it is!”

Poor Steve has no idea how it is, In fact, in preparation for this meeting, he:

Sent several well-thought messages beforehand to convince you that meeting him was the right thing to do.

Prepared himself for this dinner.

Had great expectations about your relationship.

Was willing to spend his precious time talking with you hoping that there’ll be a shared interest!

Yes, we’re Steve when this happens. Kind of shocked and definitely hurt. Consider your interview over at this point.

To avoid this in your next interview, take the time to get to know the company. Check their website and try their product if it’s possible. If you can’t try the product, search for screenshots of the interface or video tutorials, to have a good enough idea of what they’re doing. Most SaaS startups have support resources nowadays, so you could even browse them to get a grasp of the business and the customers needs.

Or go onto a review site like G2Crowd or Capterra to learn about the tool, read user reviews, and see who the tool’s competitors are.

Show that you care! You’ll make a wonderful first impression.
Why Your iPhone is Slow
By: Julie Elise
Tags: Technology, iOS, Productivity, iPhone, Phone

#3. Check the Memory Usage

The phone may be performing slow if the amount of free memory is low. If you’ve had the iPhone for over a year, take a lot of photos, or have a lot of apps installed, checking the memory usage periodically is good practice. Unused apps and photos that take up a lot of memory should be deleted. The iPhone storage can be managed by going to:

Settings > General > iPhone Storage

Image provided by author

Delete unused apps

As shown above, the iPhone storage screen provides a breakdown of the memory usage per app. If you choose to delete an app, select it from the list and press the Delete App option.

Image provided by author

2. Delete Messages, Photos and Music

Messages, photos and music all contribute to the overall iPhone storage usage. Selecting Messages from the iPhone Storage list gives the top conversations, photos, and GIFs/Stickers that can be deleted. Selecting Music displays all of the songs and memory size, with the option to delete. Photos will need to be deleted through the Photos app.

3. Clear “Other”
DreamTeam Digest #28
Tags: Apex Legends, Gaming, Esports, Startup, Game Development

Here’s a quick DreamTeam update. Since the release of our last digest, we’ve added a new game to the platform, DreamTeam has been named the “Best Blockchain Startup”, and has been mentioned in several crypto publications.

Check out the details below.

DreamTeam adds Call of Duty: Modern Warfare to the platform

We know the gaming world has been waiting for Call of Duty: Modern Warfare to drop for a long time. And it’s finally here! With that, DreamTeam is thrilled to announce that CoD has been added to the DreamTeam family and is now live on the platform! Read exactly what players get with DreamTeam CoD here.

DreamTeam wins the EASAwards regional round

DreamTeam has been named “The Best Blockchain Startup” on the regional round of the EASAwards. In the regional round, DreamTeam competed against startups from Euroasian countries: Armenia, Azerbaijan, Belarus, Georgia, Moldova, the Russian Federation, and Turkey. See winners here.

Esports and Cryptocurrency Payments

As gamers are typically tech-savvy, crypto and esports go hand in hand. Check out CoinPoint’s view on esports, crypto, how they are made for each other, and how DreamTeam fits into the equation here.

Crypto and Esports

Can tech-savvy gamers help push crypto into mass adoption? Hedgetrade.com seems to think so. Find out what was written about DreamTeam and which other projects are helping make the push here.

Sincerely,

The DreamTeam Crew

About DreamTeam:

DreamTeam — infrastructure platform and payment gateway for esports and gaming.

Stay in touch: Token Website|Facebook |Twitter|LinkedIn|BitcoinTalk.org

If you have any questions, feel free to contact our support team any time at token@dreamteam.gg. Or you can always get in touch with us via our official Telegram chat.
The Stock Market Is a Ponzi Scheme
By: Tim Denning
Tags: Society, Business, Life, Money, Economy

The Stock Market Is a Ponzi Scheme

The stock market is built on non-dividend paying companies and this is a real problem, according to financial expert Tan Lui.

Illustration by therealdeal.com / LexiPilgrim

I am a huge believer in buying stocks. I’ve always seen the stock market as my best friend. But as I look at my Amazon stocks that have increased in price by 70% since I bought them not long ago, I’m questioning my beliefs.

Questioning your beliefs and assumptions is a powerful practice.

It pays to challenge your beliefs if you want to make more money, so you can buy back time, relax and work less.

So I’m asking myself this question:

Is the stock market one giant Ponzi Scheme?
Create PDF viewer in React js
By: Manish Mandal
Tags: Reactjs, Pdf, React

So today let us see in this tutorial how to create a PDF viewer to view our internal and external .pdf files. At some point in time, we need to load some pdf files to be viewed by our visitors but we don’t know how to display all those pdf files in our React js application. So here comes a handy react module to make our life Easy. @phuocng/react-pdf-viewer is a great module to create a PDF viewer in our React project. It is very easy to implement compared to other modules available. So let us see how to implement that in our project.

Requirements

Create and open your React js project.

yarn create react-app yourprojectname

cd yourprojectname

2. Install @phuocng/react-pdf-viewer and pdfjs-dist to your project.

yarn add @phuocng/react-pdf-viewer pdfjs-dist

3. Now open your app.js file and import Viewer, Worker, and CSS file from @phuocng/react-pdf-viewer. We will first load our pdf file from an internal source (Local file) so also import that pdf file.



import '

import filePDF from './dummy.pdf' import Viewer, { Worker } from ' @phuocng/react-pdf-viewer ';import ' @phuocng/react-pdf-viewer /cjs/react-pdf-viewer.css';import filePDF from './dummy.pdf'

4. Now we will use those Viewer and Worker tags. Paste the below code in your app.js file.

Here we have loaded the pdfjs-dist worker file inside the Worker tag. This is compulsory for the viewer to work. My current version of pdfjs-dist is 2.5.207 It might change in the future so load only the latest version of the pdfjs-dist worker file. Now call our pdf file inside the Viewer tag as fileUrl prop and then start your application yarn start and refresh the browser. The file will load fine.

This was pretty simple to load our local pdf file but what if we want to load pdf file from some external source? If we try to put our external pdf file directly inside the fileUrl prop of Viewer tag we will receive a CORS error. So how do we load that file? If the external file source is coming from some backend which we can control like in node or PHP we can set up a proxy to load the file but if we don’t have access to the source of the file there is this one website which can solve our CORS error https://cors-anywhere.herokuapp.com/ All you need is to put your external pdf link after the corsanywhere link https://cors-anywhere.herokuapp.com/your-pdf-file-link.com/file.pdf In our case it’s https://cors-anywhere.herokuapp.com/http://www.africau.edu/images/default/sample.pdf

Now let us add some CSS to make the pdf viewer look more professional.

That’s it for today. Below are the live codes and GitHub repository for your reference.
Introducing Bitfolio 4
By: Francesco Pretelli
Tags: Apple, iOS, Cryptocurrency, Apps, Bitcoin

It seems yesterday that we launched Bitfolio 3 for iOS, with the ability to sync exchanges.

We kept adding exchanges over the year and we started working on Bitfolio 4 when we realised we needed something more.

After months of hard work, we are very please to introduce a new, redesigned, reimagined Bitfolio! 🎉

What’s new

The big change you will notice is no more tabs.

Everything is now part of a customizable dashboard and we think you are gonna love it.

At the moment the dashboard includes tickers, portfolios, exchanges, coingecko and news, but we have plans to add more sections over the coming months.

Every section can be enabled or disabled, and you can rearrange them as you please, so that your most important information are where you want them to be.

But it’s not all, we also redesigned the portfolio screen of Bitfolio.

Now you can view your historical profit and loss on a beautiful line chart or bar chart.

You can also sort the assets so that it’s easier to keep track of them.

The iPad version is also updated and taking advantage of the screen estate.

Lastly, we decided to make everything available in the free version! There will still be some ads but we removed all the annoying full screen videos, ads will now be less intrusive (you can still remove them with an in app purchase).

What’s coming

As stated above, we are planning on adding new sections to the dashboard but that’s not all.

We will keep adding exchanges and improving the compatibility, soon you will be able to see your active orders, your past trades and (depending on the exchange) also create new orders.

We are also planning to improve the news section so that you can customize it with your favourite feed and add more insights to your portfolio transactions.

The Android version is also being updated, while we are working on it, the current Play Store version is free, with all features unlocked.

As usual, if you have any feedback or suggestions, please let us know, we are always looking for ways to improve the app.

And much more, check out the Bitfolio roadmap on trello, you can vote on your favorite feature and keep an eye on the development. 👍

Useful Links

Thank you ❤️

We’ve received a lot of feedback and we love it, please keep it going, keep sending feature requests and if you see a bug or an issue, send a complaint! (but please don’t be rude 😉).

Please consider sharing Bitfolio with your friends and coworkers, it would help us tremendously.

Again, thank you ✌️

The Bitfolio Team
Stuck in Slumpland? Tips for my fellow NaNos.
By: Goivanna Irelund
Tags: Writing Tips, Writing Life, NaNoWriMo, Authors, Writing

NaNoWriMo participants around the world, congratulations on making it to the precipice of the halfway mark. By now, your protagonist(s) should have survived many painful obstacles you’ve thrown their way, your antagonist(s) has/have emerged, even if your protagonist(s) have no idea who their true enemies are yet. Notorious for tripping up budding and seasoned writers alike, the middle of your manuscript is prime real estate for Slumpland writing (if you’re managing any at all).

Slumpland writing covers everything from poor dialogue to excessive flashbacks to the dreaded cliche dream sequence. Cliches often plague the middle, as do worn-out tropes and the sensation that your protagonist(s) is/are treading water. You know where they’re supposed to be going but they seem not to get anywhere over page after page. Other common mistakes here: detailing every action a character does or slowing the action down to tune in on every random thought they have and each time they change emotions.

The good news is, if you keep putting your butt in the chair and your hands on the keyboard, your stay in Slumpland won’t last forever! If you need some inspiration for how to escape, I have some ideas:

Watch YouTube videos on how to improve your craft. Warning: You should give yourself a time limit for this activity and stick with it, or else a rabbit hole will open and your fellow Nano participants may never see you again. A few personal favorite YouTubers to learn from include: Abbie Emmons, Merphy Napier, Alexa Donne, and Brandon Sanderson.

Even if you’re a hardcore Pantser (been there) or a Nano Rebel, consider writing an outline or adding to the one that exists. When I’m dancing around the Slumpland border, adding to my outline helps me keep my protagonists on the paths to their destinies.

Avoid falling into the yawning abyss which dominates the center of Slumpland: The Pit of Premature Editing. Its appeal is undeniable, but you can resist its charms. The best way to do so, in my opinion, is by finding a buddy or many, and by meandering over to the Nano forums at least once per day to mingle with your fellow Nano writers. Buddies and groups are great for asking the questions, offering the prompts and feedback, and giving you the support you need to stay out of Slumpland, or to help you escape if you’re already there. You can find me on the Nano site under the username GeekMamacita, if you want to connect. I’m always happy to help. We are in this together!

Happy writing, and if you like my emerging blog, please give me a clap or a follow. I’ll post again soon.
How to Embed React Apps in WordPress Sites
By: Natasha Butt
Tags: WordPress, React, Nodejs, Programming, JavaScript

Create a New React Application

React is a JavaScript library for building user interfaces. To create a new React project, we will use create-react-app. You will need to have Node.js >= 8.10 installed on your local development machine. Once you have it installed, open your command prompt/terminal, go to the directory where you would like to create the project, and run the following line of code:

cd path/to/directory

Note that you should put your own path/to/directory here (on my Mac, I will often just drag a folder from my Finder into the command line). Then we will run the following line to create the project:

npx create-react-app crossword-app

crossword-app is the name of my project, so you can go ahead and change that to whatever you like. Next, we will simply open the project directory in our terminal again using cd and run our newly created app in development mode with the following line:

npm start

If you now open http://localhost:3000, you should see a landing page with the React logo and some text with a link to learn React. If you’ve gotten this far, well done! If not, you may have some debugging to do/conflicting dependencies, so check out the create-react-app documentation.
San Francisco’s 1970 Study for Urban Design
Tags: 1970s, Architecture, Design, Urban Planning, San Francisco

I love a bit of design history. Whilst in the Mission yesterday I picked up this gem from 1970 at Farnsworth Mercantile on Valencia. It’s part of an urban planning study that was carried out by the city in the late 60s and early 70s, eventually being adopted in 1972. There were 8 reports and this is Preliminary Report №5 Urban Design Principles for San Francisco (July 1970) by Thomas R. Aidala. When I saw it I couldn’t resist it. Square format, that beautiful big 5 on the cover and most of all it’s about design principles.

It looks like it belonged to one of the consulting or committee architects; Henrik Bull of BSA Architects as there is a newsletter from 1999 tucked inside address to him containing an article on the study.

Here’s a few spreads from the report. I love the spiral binding (although it’s a little tight) and the heavier paper section divides.
People Need People
By: Dena D Hobbs
Tags: Depression, Friendship, Mental Health, Anxiety Disorder, Therapy

I woke up feeling sad today.

I don’t know if it is the culmination of bad news I have heard this week or the grey skies left in the wake of a recent tropical storm.

But I am sad. Mopey sad. Sit in a room alone and listen to Billie Eilish kind of sad.

One of the cruelties of mental health issues is they tend to make you isolate yourself. Since I am an introvert, even a hard day makes me want to pull away from other people and lick my wounds alone. But a dive into anxiety and depression really makes me isolate from others.

Is it the shame? The exhaustion from fighting the fear and dread? The plain fact that I feel bad?

Photo by Noah Silliman on Unsplash

Whatever the reason, my mental health struggles have typically lead me to retreat from people when I need them most.

Because yes, People do need People.

Especially when we are struggling.

This lesson in moving towards people when I am anxious and depressed has been one of the hardest in my journey towards healing. It is possibly the most challenging thing I have had to learn but also one of the changes that has helped me the most.
How to Perform Fraud Detection with Personalized Page Rank
By: Antoine Moreau
Tags: Machine Learning, Data Science, Data Mining, Big Data

Fraud detection is a major field of interest for data science. As fraud is a rare event, the main challenge is to find a way to bring to light abnormal behavior. That is why graph analysis is a useful approach to perform fraud detection. Many algorithms exist to extract information from graphs. In this article, we will study one of them: the Personalized Page Rank algorithm. To manipulate our graphs and compute this algorithm we will use the python package Networkx.

Page Rank Algorithm

Page Rank is a well-known algorithm developed by Larry Page and Sergey Brin in 1996. They were studying at Standford University and it was part of a research project to develop a new kind of search engine. They then successfully founded Google Inc.

This algorithm assigns a numerical weighting to every node of a connected network. This measure represents the relative importance of a node within the graph (its rank).

To compute Page Rank a random walk is performed. This random walk is defined as follow :

The walker starts at a random node in the graph.

At each iteration, the walker follows an outgoing edge to one of the next nodes with a probability α or jumps to another random node with a probability 1-α.

The PageRank theory holds that the imaginary walker who is randomly walking on links will eventually stop. The probability, at any step, that the person will continue is called the damping factor α.

As an example, for Google, the network is composed of websites that point to each other through links. The page rank measure of each web page is then the probability that a person randomly surfing on the internet would finally arrive on this specific page.

In mathematical terms, The Page Rank of a node is the stationary measure of the Markov Chain described by the random walk.

Page Rank measure of a node in the graph

On the animation below you can visualize a Random Walk performed on a connected graph with a damping factor set to 0.85.

Random walk on a graph — (α = 0.85)

On the above example, one would predict that the node ‘c’ is the one with the higher rank. This is the most central node. On the contrary, the node ‘h’ is more likely to have a low rank.

Page Rank measure for each node of the graph

How to compute Page Rank with Python and Networkx

The python package Networkx gives the possibility to perform graph analysis. A lot of algorithms are implemented in this package (community detection, clustering…), pagerank is one of them.

With the python script below, thanks to Networkx, we will first generate a random graph and then apply pagerank function.

Personalized Page Rank Algorithm

We have seen that the Page Rank is a representation of the importance of nodes within a network. Personalized Page Rank gives the possibility to bring out nodes in a graph that are central from the perspective of a set of specific nodes.

…

Read the full article on Sicara’s blog here.
The Rain Song
By: Priyanka Srivastava
Tags: Poetry, Rain, Muse, Nature, Writing

The Rain Song

A poem about the noise which awakens me

Photo by Alex wong on Unsplash

Will you believe me, if I tell you that today I collected sound?

I trapped raindrops which were pattering on the roof.

My own words knocking against the nerves and the raindrops somehow rhymed together, I blended the noise and wrote few poems.

I healed my heart.

Will you believe me if I tell you tomorrow it will be cuckoo song?
Inverting an Image using NumPy’s Broadcasting method
By: Sameeruddin Mohammed
Tags: Image Processing, Numpy, Programming

In this article, we will learn how to invert an image using NumPy. To get some gist of this, let’s we have two values 0 and 1. Here 0 represents Black and 1 represents White. When we apply inversion to these values, we get:

0 → inversion → 1

1 → inversion → 0

The above only works when we two values. 0 for low and 1 for high. If we were to relate the same with the Binary Image whose pixel values are just 1’s and 0's. The inversion would be reversed. To put it in words we can say from White and Black to Black and White.

Broadcasting

Unlike lists, if we want to add a number to the values of the list. We iterate through each element and add the number. Whereas, in NumPy, we need not iterate through each element and add. Instead, we can treat the array list as a single element and add the number. NumPy automatically adds that number to all the elements of the array list. This technique is called broadcasting.

The broadcasting technique is applicable to both matrices and arrays. It is very fast when compared to normal loops.

>>> import numpy as np

>>> M = np.array([1, 2, 3, 4, 5, 6])

>>> M = 3 + M

>>> M

array([4, 5, 6, 7, 8, 9])

>>>

Let’s see the demonstration for a random matrix.

White — Black

A simple demonstration of the White — Black matrix and the image can be seen below.

1 is visualized as White

0 is visualized as Black

>>> import numpy as np

>>> image_b = np.array([

... [1,0,1],

... [1,1,0],

... [0,1,1]])

>>> image_b

array([[1, 0, 1],

[1, 1, 0],

[0, 1, 1]])

>>>

If we visualize the above matrix, we can see something like the below.

Image by Author

Black — White

A simple demonstration of the Black — White matrix and the image can be seen below.

1 is changed to 0 → Black

0 is changed to 1 → White

>>> # Broadcasting

>>> image_i = 1 - image_b

>>> # image_i = ~ image_b

>>> image_i

array([[0, 1, 0],

[0, 0, 1],

[1, 0, 0]])

>>>

If we visualize the above matrix, we can see something like the below.

Image by Author

To convert a matrix into an inverted matrix we can also use the operation ‘~’. It works in the same way.

If you want to know specifically how to convert an image into binary, you can refer to my article where I explain the procedure for both colored and grayscale images.

The above implementation worked since the images are already binarized. What if we wanted to apply this for a colored and non-binarized image? The scenarios will be different. Let’s find out what we can do for those.
7 Underrated Quotes That Helped Me Become More Productive
By: Mathias Barra
Tags: Quotes, Self Improvement, Productivity, Habits, Inspiration

“Pleasure is an important component of the quality of life, but by itself, it does not bring happiness.” — Mihaly Csikszentmihalyi

Mihaly Csikszentmihalyi is well-known for his work on the experience of flow. He even published a book about the topic 30 years ago.

The whole premise of his research was that we need to create more flow experiences to accomplish more. He goes into great detail about different mindset changes to make but also mentions the concept of pleasure.

He believed pleasure was important but not enough to bring happiness. Now, it’s been proven. We need pleasure as a component to reach happiness.

After I read this quote, I began controlling my urges more. I love going to coffee shops but did I need to go 6 times a week? I enjoy smoking but wasn’t it breaking my flow experiences as I had to go out to smoke? Did I really need to party 5 times a week? I chose to be more mindful of how often I indulged in pleasure.

We need pleasure but we should never make it the priority.
[Week 1] 5 Articles to Keep You Updated on Blockchain
By: Chinmay Patil
Tags: Venture Capital, Blockchain, Development, Cryptocurrency, Bitcoin

[Week 1] 5 Articles to Keep You Updated on Blockchain

Weekly newsletter from Bangalore Blockchain Application Development

Word Cloud via Word Art

Nilesh Christopher via Economic Times

After banning the banks to transact with crypto operated businesses, Reserve Bank of India(RBI) is checking whether it is feasible to issue a digital currency backed by Indian Rupee(INR).

via The Economist

Skepticism about blockchain has never been denied and this article gives a good insight into why it has been that way!

Mark Rogowsky via The Block Crypto

Who doesn’t love a good banter! This article is a response to the above article by The Economist allegedly claiming that Bitcoin and other cryptocurrencies are useless.

Seema Mody via CNBC

‘Andreessen Horowitz’ is perhaps the biggest name in VC sector. This investment comes at the time when the market has been in bear mode for few months and it is significant to the future of Blockchain.

Mohammed ElSeidy via ZK Capital

Every startup wants to ride the Blockchain hype and tries to incorporate Blockchain into their products. But do all these solutions really require blockchain ? This article tries to answer when to use Blockchain, if at all?
Young, Gifted, @ Risk and Resilient
By: National Center For Institutional Diversity
Tags: Resilience, Mental Health, Series, Toolkit, Students

Mental health among college students has become a national priority. Students of color in particular experience unique circumstances, such as racial/ethnic discrimination, disparities in mental health services, and marginalization. These experiences can contribute negatively to their mental health and well-being and impede both academic performance and college satisfaction.

This video series features scholars and practitioners from across the country who provide evidence-based information for faculty, staff, and providers to foster a positive learning environment and support the mental health and well-being of students of color.

Scholars and practitioners have informed this effort through a holistic approach. Understanding the space and place in which students of color operate provides us with a lens to examine the multiple dimensions of students’ academic and social contexts on and around their campuses. This includes not only the physical components of campus climate, but also the virtual contexts that impact students’ sense of belonging.

Scholars have also highlighted the formal and informal relational contexts among students of color and their faculty, student peers, staff, families, and communities, in order to understand the strengths and contributions that relationships can have on the well-being of students of color. Considering the barriers and strengths (including structural, social, cultural and personal) of students can help advocates and supporters identify students’ assets and support them as college campuses adapt to better serve students of color. Scholars and practitioners have introduced innovative interventions to address the complex challenges facing students and institutions, and guidance on best practices to implement, scale up, and advance rigorous research on this topic.

This video series is a product of a collective effort between scholars and practitioners across the country. We hope you will join us as we increase awareness and understanding about the experiences of students of color and consider how to best support them so that they may be successful and thrive in the educational environment.
Reshape Pandas Data Frames
By: George Pipis
Tags: Python, Data Transformation, Data Cleaning, Data Science, Pandas

Reshape Pandas Data Frames

A walk-through example of how you can reshape pandas data frames

Image on Unsplash

We will provide some examples of how we can reshape Pandas data frames based on our needs. We want to provide a concrete and reproducible example and for that reason, we assume that we are dealing with the following scenario.

We have a data frame of three columns such as:

ID : The UserID

: The UserID Type : The type of product.

: The type of product. Value: The value of the product, like ‘H’ for High, ‘M’ for Medium and ‘L’ for Low

The data are in a long format, where each case is one row. Let’s create the data frame:

Create the Pandas Data Frame

import pandas as pd df = pd.DataFrame({'ID':[1,1,1,1,2,2,3,3,3,4],

'Type':['A','B','C','E','D','A','E','B','C','A'],

'Value':['L','L','M','H','H','H','L','M','M','M']}) df

Aggregate the Data by ID

Let’s say that we want to aggregate the data by ID by concatenating the text variables Type and Value respectively. We will use the lambda function and the join where our separator will be the | but it can be whatever you want.

# Aggregate the data by ID df_agg = df.groupby('ID', as_index=False)[['Type','Value']].agg(lambda x: '|'.join(x))

df_agg

As we can see now we have 4 rows, one per each ID.

Reshape to a Long Format

Our goal is to convert the “ df_agg “ to the initial one. We will need some steps to achieve this.

Convert the Columns to Lists

We will need to split the Type and Value columns and to transform them into lists.

df_agg['Type'] = df_agg['Type'].apply(lambda x: x.split("|"))

df_agg['Value'] = df_agg['Value'].apply(lambda x: x.split("|")) df_agg

Create a list of tuples from the two-column lists

We know that the elements of each list appear in order. So, we need to do a mapping between the Type and the Value list element-wise. For that reason, we will use the zip function.

df_agg['Type_Value']= df_agg.apply(lambda x: list(zip(x.Type,x.Value)), axis=1)

df_agg

Exlpode the list of tuples

Now, we will “explode” the Type_Value as follows:

df_agg = df_agg.explode('Type_Value') df_agg

Split the tuple into two different columns

Now we want to split the tuple into two different columns, where the first one is referred to the Type and the second one to the Value.

df_agg[['New_Type','New_Value']] = pd.DataFrame(df_agg['Type_Value'].tolist(), index=df_agg.index) df_agg

Now we will keep only the columns that we want and we will rename them.

df_agg = df_agg[['ID','New_Type', 'New_Value']].\

rename(columns={"New_Type": "Type", "New_Value": "Value"}).\

reset_index(drop=True) df_agg

Check if the Data Frames are identical

As we can see we started with a long format, we reshaped the data, and then we converted it back to the initial format. Let’s verify if the initial data frame is the same as the last one that we created.

df_agg.equals(df)
A New Way to Write Conditional Statements in Kotlin
By: Siva Ganesh Kantamani
Tags: AndroidDev, Kotlin, Android, Software Engineering, Programming

A New Way to Write Conditional Statements in Kotlin

Make your code more readable using “when” in Kotlin

Photo by Scott Graham on Unsplash.

Ever since Kotlin was born, it has been one of the preferred languages to develop apps for Android devs around the globe. People love Kotlin for various reasons: extension functions, ease of doing things, less boilerplate code, cross-platform support, and more.

Yet there are many of us who overlook the potential of little things in Kotlin. For example, I still see many of my teammates use if and else if nested statements occasionally.

With Kotlin, we can have a unique yet simple solution that can deal with multiple problems. For example, the when statement can replace all the conditional statements in any Kotlin project if you’re smart enough to use it.
Building vegetable gardens and other innovations transform lives in South Sudan
Tags: South Sudan, Innovation, Agriculture, Development, Africa

People in Mangok Amuol in South Sudan used to struggle to get enough food to eat, surviving off wild foods such as water lilies and collecting firewood to sell. Akol Deng remembers how she lived hand-to-mouth, earning barely enough to feed her children much less ever send them to school.

But since a project to change people’s lives called Building Resilience Through Asset Creation and Enhancement — Phase II (BRACE II) has strengthened the village, those tough days appear at least to be behind her and her family.

BRACE II is a multi-year project implemented by the Food and Agriculture Organization of the United Nations (FAO) and the World Food Programme (WFP), with financial support from UKaid.

For three years, targeted households receive food assistance while they create assets that build their resilience to climate shocks. FAO provides seeds and tools to food insecure families while WFP provides a monthly cash transfer during the annual hunger season that coincides with the peak agricultural period. This ensures that people have enough energy to cultivate their land.

In Mangok Amuol, BRACE II participants recognized hunger as their main problem, followed by seasonal flooding which prevents children from reaching school and sick people from being able to receive treatment. At a community meeting, they agreed to establish a vegetable garden to grow their own food and a dyke road so their children could access school all year round.

“We now have vegetables which were never here before!”
Leashed
By: Laura Misener
Tags: Poetry, Mental Health, Poem, Anxiety, Scrittura

Leashed

Sometimes it’s the same person at both ends of the leash.

Photo by engin akyurt on Unsplash

Anxiety holds a retractable leash.

Most times keeping the leash short, other times offering finite slack. It taunts by dangling freedom just out of reach.

Resisting thrashing pulls and mournful howls, always at the ready to reel and send reeling.

The leash, firmly grasped, too thin to see from afar but capable of imprisoning even the strongest men.

Hostages at the end of their rope.
The Art Of Flight
By: Sarah E Sturgis
Tags: Poetry, Flight, Leaves, Nature, Writing

Rustling leaves in shady trees

Sailing in the wind-

Gliding, diving down

To settled earth

From green to red their colors spread

Like butter on bread-

Shapes of puzzle pieces

Maneuver in the air

The art of flight, a friendly fight

To gracefully display,

Wings of paper

Thin as wafers

Branches clothed in shades of gold,

Of red and white and green-

Weighing heavy

To the ground
A Letter to Santa From A UXer
By: Motivate Design
Tags: Memories, UX, Design

Dear Santa,

I know you’re a real busy guy this time of year, what with all that toy making, but I hope you would spare a moment to hear a little constructive feedback on how to improve the user experience of Christmas.

Every year I mail my Christmas list to you (still haven’t got that hot dog roller, by the way) and I never have any idea if you’ve received my letter. If you have the ability to see me when I’m sleeping and know if I’ve been bad or good, at least send a delivery confirmation for goodness sake. How will I know if a full year’s worth of good behavior is even worth it if I don’t know if you’re receiving my list? Without the confirmation, it feels a little like I’m just mailing letters to some mythical being who wears a lot of red and is at risk for type II diabetes.

Also, how do I know if I am on the naughty or nice list? It’s 2015 Santa. A single year-end review is pretty antiquated. Routine performance reviews are the new standard. It would be nice if there was an app where I could track my behavior and list status. Perhaps complete with tips and improvement plans? I mean, banking has been online for 15 years Santa, what’s the holdup? Even a text every few months would go a long way. For example:

“Dear Nick,

Shape up or ship out.

Best, Santa Claus”

One more thing, (and this is just a nice to have) but it would be really great if you provided a window of when you plan on arriving Christmas night. I know you won’t come unless I’m asleep but life is unpredictable and I don’t wanna miss out just because I stayed up too late watching Home Alone and eating a sicko amount of figgy pudding. My cable company at least provides me with a window of when they plan on arriving (which they NEVER miss).

I know you’re immortal and all, but a little bit of modernizing could do you a lot of good. Remember Santa, give holiday cheer with the end user in mind.

Thanks for taking the time to read this Santa, I really appreciate it.

Sincerely,

Nick, age 27

To learn more about how we define UX , read our white paper below and let us know your thoughts. You can also follow Motivate Design on Twitter here and say “Hello!” on Facebook.
Ansible and Google Calendar Integration for Change Management
By: Nicolas Leiva
Tags: Automation, Ansible, Software Engineering, Programming, Change Management

Is anytime a good time to execute your automation workflow? The answer is probably no, for different reasons.

If you want to avoid simultaneous changes to minimize the impact on critical business processes and reduce the risk of unintended service disruptions, then no one else should be attempting to make changes at the same time.

In some scenarios, there could be an ongoing scheduled maintenance window. Or maybe there is a big event coming up, a critical business time, a holiday, or you prefer not to make changes on a Friday night.

Whatever the reason is, we want to signal this to our Automation platform and prevent the execution of periodic or ad-hoc tasks on specific time slots. In Change Management jargon we are talking about blackout windows when change activity should not occur.

Calendar in Ansible

How can we accomplish this in Ansible? While there is no Calendar function per se, however, Ansible’s extensibility will allow us to integrate with any Calendar application that has an API.

The goal is this: Before we execute any automation or change activity, we execute a pre-task that checks whether there is something already scheduled in the Calendar going on or soon enough, or to confirm we are not in the middle of a blocked timeslot.

Let’s pretend a fictitious module named calendar exists, and that it can connect to a remote calendar, like Google Calendar, to determine if the supplied time has been marked as busy. Then we could write a playbook that looks like this:

Ansible facts will give us ansible_date_time which we pass to the calendar module to verify the time availability. We register the response ( output ) to use in subsequent tasks.

If our calendar looked like this:

Then the output of this task would highlight the fact this timeslot is taken ( busy: true ).

Preventing tasks from running

Next, Ansible Conditionals will help us prevent the execution of any further tasks. As a simple example, you could use a when statement on the next task to enforce that it runs only when the field busy in the previous output is not true .

Conclusion

Like we mentioned in the previous post, Ansible is a framework to wire things together, interconnecting different building blocks to orchestrate an end-to-end automation workflow.

In this opportunity, we looked at how your Playbooks can integrate or talk to a Calendar application to check availability. However, we are just scratching the surface! For example, your tasks could also block a timeslot in the calendar… the sky is the limit.
5 Ways to React When a Younger Person Leaves You In the Dust
By: John Mashni
Tags: Entrepreneurship, Leadership, Self Improvement, Life Lessons, Inspiration

5 Ways to React When a Younger Person Leaves You In the Dust

It’s about respect, not jealousy.

Photo by Victoire Joncheray on Unsplash

“There goes Jeff Bezos,” a man said.

Comedian Kevin Hart was in a room with well-known and successful business owners and individuals.

Then, Jeff Bezos walked in.

Instantly, Kevin said to his friend, “I’m going to go say what’s up to him. I would love to pick his brain. That’s an interesting individual.”

His friend said, “Don’t do that! Why do you want to do that? Don’t look like the dude that’s thirsty.”

“Just chill. Just relax,” the friend repeated.

What do you do when you meet someone more successful than you?

Do you relax? Do you tighten up?

Kevin Hart had to choose how he would react when he was in the presence of someone massively more successful than him.

Listening to Kevin Hart describe his reaction reminded me of my own choice when I ran into someone I had not seen in a few years.

He was significantly younger than me. Yet he had achieved a level of success that I am striving for. A few years ago when we last spoke, we were pretty even in our results — similar homes, cars, and lifestyle. But he had passed me.

A flurry of emotions started to simmer. What do I say to this guy? How do I react?

I thought through each of my options. Some were not healthy. Others were much better. I thought of five ways to react.
Kotlin vs Swift: The Init Construction
Tags: Mobile App Development, Android App Development, Kotlin, Swift, iOS App Development

Learning Kotlin and Swift

Kotlin vs Swift: The Init Construction

Explore Kotlin and Swift together and learn their differences

Photo by Mason Kimbarovsky on Unsplash

In Mobile development, the 2 major programming language to learn is Swift and Kotlin. They look very similar, but there are subtle differences.

Let’s look at the one called during construction, the init that exist in both Kotlin and Swift.

The init function

In Swift, init is the constructor and is called before the parent is constructed.

In Kotlin, the init is not really a constructor, and it is called after the parent is constructored.

More details below.

In Swift

The init function can have parameters to form a constructor for the class. Cannot have more than one init() function in the class (i.e. empty parameter constructor) The init function is called before the parent constructor is called i.e. the parent object is not yet formed. The init function cannot call the class member function unless it’s a static function. The reason is because the parent is not constructed yet, so the child object is not constructed yet.

class Base {

private let someString: String

init(someString: String) {

print("In Base init")

self.someString = someString

}

} class Child: Base {

init() {

print("In Child init")

super.init(someString: ChildClass.localStaticFunction())

} static func localStaticFunction() -> String {

print("In local static function")

return "something"

}

}

The result of the above code will be

In Child class init

In local static function

In Base init

In Kotlin

The init scope cannot have parameters to form a constructor for the class. The constructor is the actual constructor function that can have parameter. Can have more than one init scope in the class. The execution order dependent of the order where it is placed The init scope is called after the parent constructor is called i.e. the parent object is already formed. (note, the constructor function is also called after the parent is constructed) The init scope can call the class member function .The reason is because the object has been constructed.

open class Base {

private val something: String

constructor(something: String) {

this.something = something

println("In Base constructor")

}

init {

println("In Parent Init")

}Base} class Child: Base {

constructor(something: String): super(something) {

println("In Child Constructor")

}

init {

println("In Child Init")

localFunction()

}

private fun localFunction() {

println("In Local Function")

}

}

The result of the above code will be

In Base Init

In Base constructor

In Child Init

In Local Function

In Child Constructor

Summary

To summarize, I have put them side by. side for easier comparison.
Uncomplicating
By: Joseph Emmi
Tags: Personal Growth, Challenge, Journal, Self Improvement, Writing

I got so used to write this daily entries that I practically and unintentionally left aide my other publications and interests.

As I’ve been trying to get back to my technology publication I have to admit that it’s been hard, feeling blocked and not knowing how to start or finish a story, like it has been delated from my mind.

Today I decided to just do it, go through it, to start again, but most importantly, to make it simple. It doesn’t matter how elaborated the idea in my head might be, avoid the complications, tell the story and share the perspective, then rest will follow with time and practice until getting back to where I used to be.

When in doubt, always keep it simple.
Parsing JSON in Dart/Flutter
By: Mariano Castellano
Tags: Flutter, Json, Google, Software Development, Dart

Hi everybody!

There are many ways to parsing json from request. In this post we are going to code how to parse json using http package in Flutter and Dart.

At first, we need to add http dependency in pubspec.yaml

http: ^0.12.2

We are going to make a request, it’s take a long time. That’s why, we need to use asynchronous programming. Otherwise, user interface will be frozen waiting response from request. We don’t want that!.

Dart provides two different way to asynchronous programming: future and the async and await keywords. We are going to use both of them to code this example.

Note: in futures post we can talk about asynchronous programming. In this post we are going to focus in parsing json.

Let’s code!.

Imagine we need to get Flutter repositories from Github. So, we need to create a model which represents this repository.

Repository model

We can code using async and await keywords and it looks like this:

Parse response using async and await keyword

Let’s analyse point by point:

1- get(url) is a function from http package which response a Future<Response> but we used await keywords it returns just Response .

2- Response contains body which is a string. Json could be parsed by json from Dart package. import ‘dart:convert’; to List<dynamic> .

3- We need to iterate each element from List and map to our Repository .

Use await keyword to get completed results of an asynchronous expression. Use async keyword before a function’s body to mark it as asynchronous.