teleren/devto huggingface dataset:
Draw all shapes with Python Turtle
Tags: python, turtle
Published: 2019-07-08 13:22:28

---
title: Draw all shapes with Python Turtle
published: true
description: python, turtle
tags: python, turtle
cover_image: https://thepracticaldev.s3.amazonaws.com/i/pzeds56w9j7vkmefl4kz.png
---
You can draw all possible shapes with Python Turtle. Turtle is a Python module to draw.

To do so, take 360 degrees and divide it by the number of sides. That how many turns the turtle will make. 

With 1 side, it will draw a line. With 3 sides, it will draw a triangle. With 4 sides a square and so on.

![](https://thepracticaldev.s3.amazonaws.com/i/pzeds56w9j7vkmefl4kz.png)

In code that looks like this:

    #!/usr/bin/python3
    def draw_shape(sides):
        t.pensize(3)
        t.pencolor("black")
        for i in range(sides):
            t.right(360/sides)
            t.fd(200/sides)


So the shape is 360/sides. What is 200/sides? That's the size of the shape. Naturally the shape  gets bigger with each increment in sides. So shrink it based on the sides. The more sides, the less steps the turtle takes.

Now in order to not draw everything on top of each other, the turtle needs to move on the space. We simply use x,y movement to put every space in a unique position.


    #!/usr/bin/python3
    
    import turtle as t
    t.setup(800,600,200,200)
    
    def draw_shape(sides):
        t.pensize(3)
        t.pencolor("black")
        for i in range(sides):
            t.right(360/sides)
            t.fd(200/sides)
    
    x = -400
    y = 200
    for i in range(0,100):
        t.up()
        t.goto(x,y)
        t.down()
        draw_shape(i)
        x = x + 80
        print(x)
        if x > 400:
            x = x - 800
            y = y - 100
    t.done()
        
Whew, that was fun :) You see how all these shapes are related. Only the number of sides changes a line into a triangle, square, circle. Interesting isn't it?

Related links:
* <a href="https://pythonbasics.org">Python Tutorial</a>
* <a href="https://pythonbasics.org/exercises/">Exercises for Python</a>
* <a href="https://pythonprogramminglanguage.com">Python articles</a>
UI, Logic, Refactor
Tags: react
Published: 2019-07-08 13:12:01

---
title: UI, Logic, Refactor
published: true
description: Know where to begin
tags: #react
---

Before I begin creating a new react component. I first start off by drawing the UI on my yellow pad with mongol 3 pencil and then translate it into code using HTML & CSS. Therefore I can see the overview of what I'm trying to build hmmmm... maybe this is something like a blueprint to my component 🤔. Then I add the logic to that UI using state and stuff in React. Then I'm going to delete that new component file. Yeah delete it, uhhm hmm. You know why? I figure out that there is already an existing package from npm waiting to be install on my codebase.

saved my time. Yes!!

The lesson I've got from this is that I should never re-invent the wheel because the best code in your codebase is not your code it's other people's code and I'm going to value that by not re-inventing their wheel instead just reverse engineer it and learn from it and also maybe build something new out of it. As a result before I begin in doing things by myself. I must first need to know where to begin.



Salamat.
Introduction to GraphQL
Tags: beginners, graphql, api, webdev
Published: 2019-07-08 13:01:32

---
title: Introduction to GraphQL
cover_image: https://thepracticaldev.s3.amazonaws.com/i/kgnl5j8qsy25t27hrv2p.png
published: true
description: A very basic and complete intro for beginners with props and cons.
tags: beginner, graphql, api, webdev
---

## What is GraphQL?
**GraphQL** is a query language for API. It fulfils the client's need on runtime. It gives the client power to decide the API data format, dataset.

## History behind the awesome GraphQL
The awesome GraphQL was invented by **Facebook** in 2012. At that time Facebook internally used it. Later on, 2015 Facebook decided to make it open source. Now it's maintaining by GraphQL community.

## Props
#### * Single endpoint API service
GraphQL is capable of serving huge data in single endpoint. For example, you need a list of all users and all products of the system. In REST you need atleast two endpoint to achieve this. But in GraphQL it just in one API.
**A basic GraphQL query example:**
```graphql
query getCustomData {
  getUsers {
    name
    username
  }
  getProducts {
    name
  }
}
```

#### * Control data fetching
From the last example you already aware about data query. In GraphQL we can let server know what I really needed.
**Let's modify the query**

```graphql
query getCustomData {
  getUsers {
    name
    username
    email
    ... anything you have
  }
}
```

#### * Modern Design
GraphQL has very much modern design of API making. It helps development easy and less maintaining for different different client software. For example, You have a desktop client, a mobile client and a web client obviously for a product name "x". Mobile app doesn't need all the data that your web client and desktop client needed. In that case, either you needed to expose different API each client or serialize all the fields. Then, you one of the client will fetch extra/unnecessary data. Now think about very slow network. I hope you understand the pain of slow loading. So, the primary and smart solution is writing GraphQL API.


### Cons
#### * No built-in caching support
Unfortunately or fortunately GraphQL doesn't have caching support. As REST api have multiple endpoints. So, traditional http call caching works well. Unlike REST it has single endpoint to fetch data. Data depends on query. So, there is no way to cache from http request. 

#### * No specific error code
This is not a big issue. We can backdoor the problem. Unlike REST it doesn't have different error codes. It always returns 200. The way to indentify an error is the key `errors` in response data.


**Conclusion:** My personal opinion GraphQL is awesome, smart and modern. But don't use it unless you need it.
Preferred notification method for blogging platforms?
Tags: discuss, webdev
Published: 2019-07-08 12:53:34

---
title: Preferred notification method for blogging platforms?
published: true
description: RSS, Email, Twitter? What do you prefer?
tags: discuss, webdev
---

In building up my blogging platform I'm curious as to how readers prefer to be notified of new posts.  

Does anyone have experience as an independent blogger they would like to share?

Or, as a reader how do you like to get notified?  Do people still like and use RSS? 

Should I be collecting emails for something like ConvertKit?  Even with all of the privacy concerns and GDPR requirements it is worth it?  Additionally, there is some cost with this for something that doesn't make me any money currently.

Is cross posting to places like Dev.to and Twitter enough?

Or just do them all? 💖
Angular 9|8 NgFor Directive Tutorial with Examples
Tags: angular, angular98, angular98ngfordirective, ngfor
Published: 2020-01-31 21:33:45

---
title: Angular 9|8 NgFor Directive Tutorial with Examples
published: true
tags: Angular,  Angular 9|8,Angular 9|8 NgFor Directive ,ngfor
canonical_url: https://www.positronx.io/angular-8-ngfor-directive-tutorial-with-examples/
---

The post [Angular 8 NgFor Directive Tutorial with Examples](https://www.positronx.io/angular-8-ngfor-directive-tutorial-with-examples/) appeared first on [positronX.io](https://www.positronx.io).

In this Angular 8 tutorial, we are going to understand how useful **NgFor directive** is. The NgFor is a built-in structural directive, and it is used to loop over a data list and arrays to show the result on front-end. 


[Click here to read more](https://www.positronx.io/angular-8-ngfor-directive-tutorial-with-examples/)
It's here! The 'Women Learning To Code Infographic 2019'
Tags: womenintech, codenewbie
Published: 2019-07-08 12:21:31

Finally!! I've released an infographic titled "Women Learning To Code", which presents data on 99 women who are preparing for careers in coding (but haven't landed a job yet).

I want to say a very special thank you to @ben and the entire DevTo team and community for helping me promote the survey from which I got my data.

I created a very simple website for displaying the infographic:

https://womenlearningtocode.ga

I welcome all comment, critique and praise. This was a huge undertaking for me, and I'm very proud! I'm even prouder of the 99 women who shared their learning-to-code experiences so transparently.
Draw stars with Python Turtle
Tags: python
Published: 2019-07-08 11:42:23

---
title: Draw stars with Python Turtle
published: true
description: python
tags: python
cover_image: https://media.giphy.com/media/SYXo0GITROlEs/giphy.gif
---
Turtle module lets you draw. Its a module for kids, that lets a turtle move and leave a trail.

Its like a piece of paper, in which you can move a pen. By default the pen is on the paper.

Lets draw stars, the program below has 5 sides. 

    #!/usr/bin/python3
    import turtle

    def main():
        count = 1
        while count <= 5:
            turtle.forward(300)
            turtle.right(144)
            count = count + 1
            print(count)
        turtle.exitonclick()

    if __name__ == "__main__":
        main()

Then

![](https://thepracticaldev.s3.amazonaws.com/i/zci0yph1mpg6333aiufb.png)

So that's a star with 5 sides. What about 6 sides? It can be made with 2 triangles. Because they are not connected triangles, the pen needs to be moved up and down. 

    #!/usr/bin/python3
    import turtle
    
    def main():
        count = 1
        while count <= 3:
            turtle.forward(300)
            turtle.right(120)
            count = count + 1
            print(count)
    
        turtle.penup()
        turtle.goto( turtle.pos() + (0,-160) )
        turtle.pendown()
    
        count = 1
        while count <= 3:
            turtle.forward(300)
            turtle.right(-120)
            count = count + 1
            print(count)
    
        turtle.exitonclick()

    if __name__ == "__main__":
        main()

Then:

![](https://thepracticaldev.s3.amazonaws.com/i/gyltcijr5x82qh46n3wr.png)

That's how you can draw stars with turtle. If you want a challenge, try to draw it with a different amount of lines.

Python resources:

* <a href="http://pythonturtle.org/">Turtle website</a>
* <a href="https://pythonbasics.org">Python tutorial</a>
* <a href="https://pythonbasics.org/exercises/">Python exercises</a>
Finding Vets Who Code
Tags: javascript, webdev, learning, veterans
Published: 2019-07-08 11:34:28

When I started my journey into Web Development it started like many others, with a simple Google search, “How to become a Web Developer.” Google instantly returned my query with millions of results in about half a second. I knew shortly after that I needed guidance to navigate the scores of languages, career paths, and resources. Having a military background led me to seek out others with the same values and work ethic as me, inevitably leading me to Vets Who Code. I submitted my application and completed the pre-work. Shortly after I was accepted to the program, but not all was sunshine and rainbows from there.

I did the work but things just weren’t clicking. Any other organization would have drug me along behind them until I got through and sent me on my way. But the leaders at Vets Who Code sat me down and had a blunt conversation with me, the kind of honest, kick in the butt conversation that only comes from people close to you, like friends you have had for years or family. Basically I was told the work I was doing wasn’t cutting it and I needed to change something and change it fast.

As soon as that conversation was over I was back at it, studying, watching videos, listening to those in the industry, and most importantly doing, eventually graduating the program and getting my first developer job as a Mid Level Frontend Web Developer.

Without Vets Who Code taking the time to not only teach me how to code, but also teach me how to learn, I could have been stuck in the realm of mediocrity.
ShopurGrocery - On Demand Grocery Delivery App Development
Tags: php, laravel
Published: 2019-07-08 11:32:05

Growth of on-demand grocery delivery software and app is pretty much linear. On-demand marketplaces have explored the intense possibilities of the world’s demands.  On-demand grocery delivery is not an exception as well. With an efficient on-demand grocery delivery software and app, one can choose whatever groceries they need and further, they can pay and get your product delivered before long. ShopurGrocery is an online grocery ordering and delivery software which is enriched with all the necessary features. Talk to us to know more about our product updates and best pricing plans.

Main Highlights - 100% Source Code, Fully Customizable, Free Support and Bug Fixing, No Coding Skills, Your Own App

For more - https://www.shopurgrocery.com/
ELI5: Why self-host a compiler?
Tags: explainlikeimfive, beginners, compilers
Published: 2019-07-08 11:30:23

What benefit is gained from making your new language's compiler self-hosting?  To me, it seems this only adds complexity to your build.  If it can generate code for your language, why does it matter what it's written in?

I understand that a compiler is a good proof-of-concept program.  They're generally dependency-free and will put your language through its paces.  The exercise of writing a compiler in your new language is a good idea, I'm not arguing that point.  I'm less clear on why making that self-hosted compiler the canonical version of your language is beneficial.  Wouldn't keeping your compiler written in something like Haskell or OCaml make it more extensible and flexible, and quicker to build?
Most valuable WordPress plugins you need to know
Tags: wordpress
Published: 2019-08-22 14:16:37

---
title: Most valuable WordPress plugins you need to know
published: true
tags: WordPress,wordpress
canonical_url: https://kevinhq.com/most-valuable-wordpress-plugins-you-need-to-know/
---

There are myriad of plugins. Every one of them served one or more specific needs. Among them, there are the most valuable ones, which you need to know. Those plugins were essential for most WordPress sites. Please note that the list of plugins category below is not representing any hierarchy or any importance. Cache I… 

[Read More »Most valuable WordPress plugins you need to know](https://kevinhq.com/most-valuable-wordpress-plugins-you-need-to-know/)
What's better, Wordpress, any other CMS or making a custom CMS as you can make one to start your own blog.
Tags: discuss, blog, cms, meta
Published: 2019-07-08 10:31:35

---
title: What's better, Wordpress, any other CMS or making a custom CMS as you can make one to start your own blog.
published: true
description: What's better Wordpress, any other CMS or making a custom CMS as you can make one.
tags: discuss, blog, cms, meta
---

I guess you all understood the question...
Parallelism and ordering
Tags: parallel
Published: 2019-07-08 10:29:39

---
title: Parallelism and ordering
published: true
description: Parallelism and ordering
tags: Parallel
---

One of the disadvantages of microservice event based architectures is that there is lot of parallel processing of a single entity across multiple modules.
There are many cases we want the parallelism but at the same time, want the messages to be processed in ordered manner.

There are several design pattern to solve this problem:

* Kafka solves this through [partitions](http://kafka.apache.org/090/documentation.html). A topic can be split into partitions. Messages are gauranteed to be in order within a single partition. You can have multiple consumers consuming from each partition separately providing for scalability and ordering. This design assumes that each consumer is single threaded and processing the messages one after other. In practical, scenarios this is usually not the case.

* One of the solution is to use SEDA queue. [Camel](https://camel.apache.org/) has a dedicated page on [Parallelism and ordering](https://camel.apache.org/parallel-processing-and-ordering.html)

* There is whitepaper titles [A Scalable Architecture for Ordered Parallelism](https://people.csail.mit.edu/sanchez/papers/2015.swarm.micro.pdf)
  I havn't gone thorugh it yet.

  Are there other methods to handle the ordering while processing the messages in parallel? Let me know in the comments...
GSoC report. Week 6
Tags: opensource, perl6, gsoc
Published: 2019-07-08 10:20:01

---
title: GSoC report. Week 6
published: true
description: This has been my work the 6th week of GSoC 2019.
tags: #opensource #perl6 #gsoc
series: GSoC 2019
cover_image: https://thepracticaldev.s3.amazonaws.com/i/efz8oj2vdq41j61djv17.png
---

## First release is coming!

Here I am another week! This week I have made a lot of progress in the project! [Perl6::Documentable](https://github.com/antoniogamiz/Perl6-Documentable) now has a command line version with a lot of options to customize the build process or only generate the parts you want to.

I also want to release the `1.0.0` version of this module`. In order to that, I made a [project in GitHub](https://github.com/antoniogamiz/Perl6-Documentable/projects), to manage the related issues, where you can see a detailed report of my work this week. 

But, why do I want to make a release? Because now it only contains the current logic, without any changes (well, there are some, but they do not change the final result), including the errors. So now it's the time to fix those errors, modify the current behavior and start to keep track of the changes. When that's done, we will have a stable system where we will be able to move towards the [new documentation system](https://github.com/perl6/doc/wiki).

Those errors/problems are described [here](https://github.com/perl6/doc/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3Abuild+) and [here](https://github.com/perl6/doc/issues?q=is%3Aissue+is%3Aopen+label%3Asite). You can see there is a considerable amount of them. My intention is to fix them while I upgrade the initial version, releasing several patches (`1.x.x`).

In addition, I have started a [wiki](https://github.com/antoniogamiz/Perl6-Documentable/wiki) in the repo to explain more deeply some functionality, because in the README I have only added the API docs. At this moment it only contains one post about how `Perl6::Documentable::Registry` is initialized and what kinds of `Perl6::Documentable` objects you will find there. I will complete it with the following pages:

- Working with the registry: some examples about how to use `lookup` or `grouped-by` to fully understand what's going on under the hoods.
- Attributes: if you take a look at `Perl6::Documentable` you will see a lot of strange attributes like `categories`, `kind`, `subkinds`, etc. In the API docs is described how they are set but not what they mean or why they are chosen like that.

And that's all for this week! Among others things, the results of the Perl 6 annual survey has already been published [here](https://github.com/perl6/p6survey/blob/master/processed-data/data-2018-2019.csv), check them out!

### Thanks for reading

Don't be shy, let me know what you think of this project in the comments ☺️.
Which books have had the biggest impact on your career?
Tags: discuss
Published: 2019-07-08 10:11:53

So I'm interested in which books you've read that have potentially been crucial in your development or given you huge insight/perspective that you didn't have prior! (Not strictly programming books)

Here's my top 3:

1. Clean Code - Robert C. Martin (Uncle Bob)
2. How to win friends and influence people - Dale Carnegie
3. The Complete Software Developer's Career Guide - John Sonmez
Redux-less context-based useSelector hook that has same performance as React-Redux
Tags: react, javascript, redux
Published: 2019-07-08 09:29:56

##### Super easy useTrackedState hook is also recommended

### Introduction

React-Redux provides [hooks API](https://react-redux.js.org/api/hooks)
with nice abstraction. Especially, `useSelector` is probaly less misused than `mapStateToProps`.

[react-tracked](https://github.com/dai-shi/react-tracked) is a library for global state without Redux. This library provides almost compatible hooks API to React-Redux. It's developed with performance in mind, and it should be as performant as React-Redux, even though it utilizes only React context. See the GitHub repo for more information.

https://github.com/dai-shi/react-tracked

This post shows benchmark results to convince that it actually is performant in one scenario.

It's worth mentioning that react-tracked, as the name implies, has another `useTrackedState` hook that has capability of state usage tracking. Unlike `useSelector`, developers don't need to define selectors for this hook.

It's also worth mentioning that another library [reactive-react-redux](https://github.com/dai-shi/reactive-react-redux) provides the `useTrackedState` hook for Redux. See the GitHub repo for more information.

https://github.com/dai-shi/reactive-react-redux

We compare all hooks described above.

### Benchmark tool

To benchmark different frameworks, [js-framework-benchmark](https://github.com/krausest/js-framework-benchmark) is used.

Checkout [the forked repo](https://github.com/dai-shi/js-framework-benchmark/tree/55fb0b4e4a283cfc49970900b6685ea10fe5eb64) if you want to reproduce the benchmark result at your end.

### Benchmark results

- react-tracked-useTrackedState: `useTrackedState` in react-tracked v0.4.0
- react-tracked-useSelector: `useSelector` in react-tracked v0.4.0
- reactive-react-redux-useTrackedState: `useTrackedState` in reactive-react-redux v4.0.0-beta.0
- reactive-react-redux-useSelector: `useSelector` in reactive-react-redux v4.0.0-beta.0
- react-redux-hooks: `useSelector` in react-redux v7.1.0

![screenshot1](https://blog.axlight.com/posts/benchmark-react-tracked/screenshot1.png)

![screenshot2](https://blog.axlight.com/posts/benchmark-react-tracked/screenshot2.png)

![screenshot3](https://blog.axlight.com/posts/benchmark-react-tracked/screenshot3.png)

### Closing notes

The benchmark code for `useSelector` is almost identical among three libraries. The code for `useTrackedState` is also identical between two libraries. However, the code for `useSelector` and the code for `useTrackedState` is a bit different and they are optimized separately. Hence, be reminded when comparing with different hooks.

I hope these results encourage developers to try my two libraries.

----

Originally published at [https://blog.axlight.com](https://blog.axlight.com/posts/benchmark-react-tracked/) on June 16, 2019.