teleren/devto huggingface dataset:
Bad loop/good loop in Python
Tags: python
Published: 2020-05-13 18:53:25

Python is a powerful language with a fast learning curve. However, there are some traps.

## Bad loop

Loops can be tricky, especially in Python. I've tested some existing scripts, and, most of the time, it's working fine, but sometimes it's quite slow.

The culprit is often a lousy loop. There are multiple ways to write loops in Python, e.g., with [for](https://wiki.python.org/moin/ForLoop).

There are mutable and immutable objects, and it's quite essential to understand the difference. Unlike lists, strings are immutable, so if you make some hazardous operations involving strings inside your loop, and you have a lot of items, the execution time might be terrible.

The following is bad:

```python
concat = ''
for d in data:
    concat += d
```

Assuming that the list `data` is extracted from a .csv file, it could be 1 million rows, especially if you are manipulating some public Government data. With this code, you are recreating your variable for each row. It could take a lot of time to execute!

## Good loop

A better approach could be:

```python
concat = []
for d in data:
    concat.append(d)
result = '' . join(concat)
```

It takes only a few seconds to process billions of rows. With a manual concatenation (first example), it takes minutes!

Imagine that you have to tweak your code several times to make it work, it becomes a nightmare to test it with the first example. It's even worse with nested loops.

## But wait, do you always need a loop?

Most of the time, you write loops to extract information or to concatenate things. Unfortunately, the best tricks are often counterintuitive.

Besides, fewer lines make the code more readable.

There are fantastic tools such as [itertools](https://docs.python.org/3.6/library/itertools.html) with a lot of functions you can use, which prevents you from reinventing the wheel.

## Make functions

Functions are great. It allows you to restructure your code into reusable blocks (Single responsibility principle):

```python
def looper(d):
    # you can make other treatments here
    return d

concat = [ looper(d) for d in data ]
result = '' . join(concat)
```

## Wrap up

Love Python, make functions and don't overuse loops.
How to Download & Install PHP 7.4.6 Manually on Windows 10
Tags: php7
Published: 2020-05-13 18:47:36

---
title: How to Download & Install PHP 7.4.6 Manually on Windows 10
published: true
description: How to download and install PHP 7.4.6 (64 bit) on Windows 10 manually, verify php version with command prompt and run inbuilt PHP development server and then pull phpinfo() method in the browser.
---
- To download php 7.4.6, launch your prefered web browser and pull up http://php.net and click the **Downloads** button
- Then click **Windows Downloads**
- Check your system type (64 bit/ 32 bit) by pressing (Windows + Pause/Break) togather.
- Under thread safe section click the zip link to start download for your specific system type.
- Once download completes, unzip the PHP zip folder 
- Copy this unzipped folder and paste in your desired drive (C or D)
- Rename the folder name 
- Open this php folder and look for php.ini-development file 
- Make a copy of this file and rename it to php.ini
- Open php.ini file with your prefered text editor
- Uncomment **PHPIniDir "ext"** and save this file

### Learn PHP & MySQL
[LEARN PHP and MySQL](https://tidd.ly/39501MO) from Highly Rated Experts one-to-one $5 an hour.

## SET PHP to PATH
Copy the php folder path with your prefered drive and add it to system environment variable path 
## Verify php -version with your command prompt
 `php -version`
## Test PHP Development Server
- Create a folder on your desktop 
- Create a php file in this new folder
- Type `<?php phpinfo() ?>` and save it
- Navigate to this folder with your command prompt 
- Run php development server
` php -S 127.0.0.1:8080 `
- Launch your browser and try to pull up `localhost:8080`

## Additional Resources
If you would like to upgrade your PHP to PHP 8 on your windows and also would like to set up WordPress theme development environment; follow the links below.

[Install PHP 8 on Windows 10](https://tubemint.com/php-8/)

[WordPress Theme Development](https://tubemint.com/wordpress-theme-development/)

{% youtube zxphxTaXVMk %}
How to deploy Python / Flask Web Applications?
Tags: python, webdev
Published: 2020-05-13 18:42:12

I was trying to figure out steps involved in deploying a typical Flask framework based Python web application in a production environment. This writeup has details of my findings.

Flask framework does have a built-in server. But it is suitable only for development purposes and cannot be used in a production environment as it does not scale well. So to deploy a Flask based web application in production,  we need to pick a **WSGI** compliant server.

<h3>What is WSGI?</h3>

**WSGI** stands for **W**eb **S**erver **G**ateway **I**nterface. It is a standard specification that the web server has to implement to run a Python web application. A typical web server does not have the ability to run Python web applications. Historically, Apache server's module implementation called mod_python used to be the only web server option for running Python web applications. The Python community recognized the need for standardization around this and came up with the WSGI interface. With this WSGI standard, web servers have to implement the server side of the WSGI interface and Flask application object is the actual WSGI application. Flask derives WSGI application functionality from Werkzeug which is a comprehensive WSGI web application library.   

Below illustration shows what happens when a user makes a request to a Python web application hosted in a production environment:

![Python Web Request Flow](https://dev-to-uploads.s3.amazonaws.com/i/dkxaybsqtrbs6qs9z8b6.png) 

<h3>Deployment Options:</h3>
There are several WSGI compliant server options to choose from to host Python web applications. Also, both hosted and self-hosted options are available. Below link from Flask documentation website has a list of deployment options along with their deployment steps.

https://flask.palletsprojects.com/en/1.1.x/deploying/
Serve Static File with GraphQL Yoga 🧘
Tags: graphql, node, javascript, graphqlyoga
Published: 2020-05-13 18:29:00


I love the **[Prisma GraphQL Yoga ❤️](https://github.com/prisma-labs/graphql-yoga)** because it's from the future, and all the features you might see today from the **[Apollo Server](https://github.com/apollographql/apollo-server)** are inspired by it. <small>([ for more about yoga and apollo](https://github.com/prisma-labs/graphql-yoga/issues/449) 👀)</small>

So, I'd like to share how to solve a problem that encountered me when I tried to __serve static files__ under `graphql-yoga`.

Before starting there are some terms that should be clarified for newcomers.

  - **`GraphQL`** is a query language for APIs and a runtime for fulfilling those queries with your existing data. GraphQL provides a complete and understandable description of the data in your API, gives clients the power to ask for exactly what they need and nothing more, makes it easier to evolve APIs over time, and enables powerful developer tools.

  - **`GraphQL Yoga`** made by *Prisma* team, is fully-featured GraphQL Server with focus on easy setup, performance & great developer experience. It provides an abstraction on top of Apollo’s <small>(`apollo-server-express@1.x.x` and other graphql tools)</small>.


Through GraphQL Yoga you have access to Express by `server.express` but you haven't access ❌ to the static method ~~`server.express.static()`~~.
Therefore, most developers have tended to adding Express as a dependency then use it like this.

```js
// yarn add express or npm i express

// import express form 'express';
const express = require('express');

// server here is a GraphQL Yoga server
server.express.use('/uploads', express.static('uploadsDir')); // ✔️
``` 

Personally, I think this method is somewhat confused. Why do I add Express as a dependency ? And I can solve this problem without that in few linges.

```js
server.express.get('/uploads/*', (req, res, next) => {
  // here you can use your way to get the path dir ..  
  const pathDir = path.join(__dirname, `../uploads`);

  res.sendFile(pathDir);
}); // ✔️🚀
```

If you want to turn a blind eye on the entrypoint, you can use '*' and add a small logic.

```js
server.express.get('*', (req, res, next) => {
  // small logic .. 
  const routes = [
    '/graphql',
    '/subscriptions',
    '/playground'
  ];

  if(routes.includes(req.url)) {
    return next();
  }

  // here you can use your way to get the path dir ..  
  const pathDir = path.join(__dirname, `../uploads`);

  res.sendFile(pathDir);
});
```
Free customized learning pathways for your journey as a web developer (idea)
Tags: webdev, startup, codenewbie
Published: 2020-05-13 18:07:40

Yesterday evening I came up with this idea: to collect free online web development learning resources and organize them into learning pathways.

There’s so much content out there, but it’s difficult to find good materials that match your skill level, or tools that enable you to create what you want.  (Of course, documentation is always there, but we don’t always feel like reading it - right??)

I’m thinking of building a website containing these organized learning pathways.  All that would need to be done is content organization/curation.  No new material would need to be written.  

On the site, users could choose to start with either:

1. **A pathway**.  Say someone wants to learn frontend, or discover more about Kubernetes, or maybe even just dip their toes into headless CMS solutions.
 - *Examples:  “Frontend Web Development”, “Laravel”, “ReactJS”, “Exploring Cloud Services”, “Exploring Headless CMS Options”, etc.*
 - For Frontend Web Development, for example, users could first learn the basics of HTML & CSS, then responsive web design, followed by JavaScript.  Resources could be from sites such as FreeCodeCamp, Udacity (their short courses are free), and Codecademy.  Afterwards, users could explore responsive design libraries (Bootstrap, TailwindCSS, Tachyons), JavaScript animation, jQuery, and AJAX.
2.  **A project goal**.  I learned web development by trying to create projects.  I’d explore a bunch of tools and libraries I felt could help me create the result I wanted, then pick and choose the ones I liked.  I learned literally *all* of my current web dev skills through this process.
 - Example:  “Create a Personal Portfolio”, “Create an eCommerce Site”, etc.

What do you guys think?  Are there any similar projects going on?  Is this something useful you would use (or would’ve used if it existed when you needed it)?  What paths/project goal choices would you like to see?  I’d love to hear your thoughts on this.
Carilo, un lugar de en sueño
Tags: carilo, alquilercarilo, turismo
Published: 2020-05-13 18:00:15

Visite carilo, despues de la pandemia, recomendamos a cariloimagine, un lugar para alojarse y pasar las mejores estadias

<a href=”http://www.cariloimagine.com.ar”>Carilo Casa alquiller</a>
API Testing Resources | Postman Tutorials FREE | 30 Days of API Testing | Day 13
Tags: testing, beginners, tutorial, webdev
Published: 2020-05-13 17:54:16

🚀Mastering API Testing(Full Course) -  https://www.learnapitesting.com

> In this video of 30 Days of API Testing Challenge, We are going to discuss the top API Testing Resources and FREE Postman Tutorials

🚀 Day 13 Task: Contribute to the list of API automation tools over on The Club.

[![30 Days of API Testing](https://i.imgur.com/SEuvU5G.png)](https://youtu.be/LaZVGxqSKWc "30 Days of API Testing")


🚀 Task 13. :  https://scrolltest.com/api/day13

🚀 All Task List: https://scrolltest.com/api/task

--
Be sure to subscribe for more videos like this!

[![ TheTestingAcademy](https://dev-to-uploads.s3.amazonaws.com/i/r7vcy6wbvyjbk1y1uu0o.png
)](https://www.youtube.com/TheTestingAcademy?sub_confirmation=1 "TheTestingAcademy")
Simplifying the mental model of Immediately-invoked Function Expressions in JavaScript
Tags: javascript, language, codenewbie
Published: 2020-05-13 17:53:37


I'd like to breakdown how Immediately-invoked Function Expression (IIFE) works.

Let's start with some basics.

if I run this code what happens?

```js
(undefined)
```

the value that is returned from `(undefined)` is `undefined`.

what if we replaced that?

```js
(1)
```

`(1)` becomes `1`

what we're doing is taking a (wrapped) value and returning it.

`(x) === x`

when passing a function as a value, we can call it.

```js
(function add(x) { return x + x })
```

becomes

```js
function add(x) { return x + x }
```

so, if we do

```js
(function add(x) { return x + x })(2)
```

Our value is a function, and we called that function with the arguments of `2` which the IIFE evaluated to `4`.

if we didn't use the parentheses, we'd have to write our code like this:

```js
function add(x) { return x + x }

add(2);
```

the parentheses handle a step for us, we can define and call a function on 1 line, but if we don't, it results in a syntax error:

```js
function add() { }() // Uncaught SyntaxError: Unexpected token ')'
```

practical use cases I've seen for IIFE's are:

1. kicking off the start of code.
2. invoking a function to get a value to use later.

I'd love to hear your feedback on if this was helpful to you.

Have a good day!
How do y'all get ideas for new blog posts?
Tags: discuss, motivation
Published: 2020-05-13 17:33:20

Booyah, friends! 🎉🍻

I was wondering how everyone else comes to an idea for writing a new posts for your blog. 

Personally, I am more into learning these days so I note down whatever the heck I get stuck at or feel uncomfortable with, and give it a deadline to understand completely. Later I post about what I learned from that. 

This honestly drives me to learn more and as you might already know **To Teach is to Learn Twice**. ✌🏻
Wird auch Zeit
Tags: reklamierung, zitate, instapaper
Published: 2020-09-24 12:08:58

---
title: Wird auch Zeit
published: true
date: 2020-05-13 17:31:27 UTC
tags: Reklamierung,Zitate,instapaper
canonical_url: http://drikkes.com/?p=14303
---

Aus dem leidlich selbstreflexiven Artikel „[Konsum: Brauch‘ ich das?](https://www.zeit.de/wirtschaft/2020-05/konsum-kapitalismus-coronavirus-wirtschaftskrise-globalisierung)“ dreier Zeit-Redakteure. Darin finden sich noch mehr lesenswerte Sätze wie diese beiden:

> Das Kaufen unnötiger Gegenstände war ja von jeher ein mystischer Akt und deshalb auch etwas fragil, kein natürlicher Impuls, sondern ein produziertes Bedürfnis, eigentlich nur möglich, solange es eben alle anderen auch taten und solange man nicht groß darüber nachdachte. Oder das Denken der Werbung überließ, die zwar jeweils nur zu einem Produkt verführen will, in der Summe aber fürs Konsumieren als solches wirbt, die täglich, sekündlich einen ökonomischen Phantomschmerz erzeugt.

Wenn man sich vor Augen führt, daß sowas ja für eigene Leserschaft (sprich: Zielgruppe) geschrieben wird, dann passt es wieder halbwegs. Was das dann mit dem ~~Claim der neuen~~ [neuen Claim der](https://www.new-business.de/medien/detail.php?rubric=MEDIEN&nr=755498) Zeit zu tun hat, weiß ich allerdings nicht.
How To Take A Screenshot On A Mac
Tags: android, computerscience, java, opensource
Published: 2020-05-13 17:13:06

Mac OS X lets you easily take a screenshot of your computer's desktop or an active window. You can use different ways to make a specific screenshot according to your needs. No matter if you are using Mavericks, Mountain Lion, or other versions of the Mac operating system, you will find a good summary of all the methods you can use to take your screenshot on your iMac, MacBook, MacBook Pro, and Mac Air/mini.

How to take a Mac screenshot?
1. Take a Mac Screenshot of your entire screen by simultaneously pressing Command - Shift - 3
2. Take a screenshot of the selected area with the keys Command - Ctrl-Shift - 3
3. Take a partial photo of your Mac screen with Command - Shift - 4
4. Take a screenshot of a specific application window using the Command - Shift - 4 - Space keys
5. Take a good Mac OS X Screenshot using Grab Utility

1. How to take a screenshot of your entire screen
This method is one of the most common for taking an entire screenshot of your Mac. This type of Screenshot allows you to capture everything that is displayed on the computer. Please make sure that the display on the screen is exactly what you want to take a picture of. Then press the Command and Shift buttons at the same time, and then Press the number 3 button. The screenshot will automatically be saved to your Mac desktop.

How To Take A Screenshot On A Mac

2. How to take a screenshot of the selected area
This screen capture option for the selected area is not immediately saved as a file on your Mac. Instead, it is saved to the clipboard. You can do this by pressing the Command - Ctrl-Shift - 3 keys simultaneously; Then by pasting it into another program to be able to modify it later.

How To Take A Screenshot On A Mac

3. How to take a partial screenshot of your screen
You can make a Screenshot of any part of the screen on your Mac with this method. First, make sure that the screen you want to capture is on top of all the other screens displayed on your computer. Then press Command - Shift - 4. After that, your cursor will turn into a small crosshair. You can use it to select the area of ​​which you would like to take a photo, for that, click from a given point and hold the button while dragging the cursor to the other end of the desired part. When you release your mouse, the screenshot will be automatically saved to the desktop.
<a href="http://www.techieankit.in/2020/05/how-to-take-screenshot-on-mac.html">Read More..... </a>
Feedback from users of Alpine and Stimulus
Tags: javascript, frontend
Published: 2020-05-13 17:07:51

---
title: Feedback from users of Alpine and Stimulus
published: true
description: Anyone out there have experience with Alpine and Stimulus? Which do you prefer and why?
tags: javascript, frontend
---

I’m looking for a new frontend one that can support server side rendered content in languages other than node. So far the two lone contenders seem to be Stimulus and Alpine. I’m looking to see what people’s experiences with each of these has been like.
What is golang good for?
Tags: go
Published: 2020-05-13 17:00:20

golang is a general-purpose programming language. Which means you could do almost anything in golang.

It can be used in different areas. Go is often used for:

* **Concurrent systems:** Go has built-in support for concurrency paradigms
* **Networking:** built-in <a href="https://golangr.com/#Concurrency">concurrency</a> support and powerful standard library
* **System apps**

Go can offer you stability, concurrency, and performance

In fact, Tobias Lütke from Spotify said “Go will be the server language of the future.”

## Why Go?

You can use Go in your chat system, your webserver, your JSON API, your web site and many other things.  As you don’t need hard real-time capabilities, it can be used.

It's syntax is similar to that of C or C++. That's why it may look familiar to you.

Go comes with lots of perks:

* Go is really easy to install on your machine.
* Creating projects in Go is very simple.
* Go provides efficient compilation
* Easy and understandable control- flow and functions
provides aid while building an application. Control-flow statements are 
*  Golang attempts to reclaim the memory occupied by objects that are no longer in use by the program, making it a very memory efficient language.  (looking at you C)
* Multiple programs can run simultaneously on it
* Golang also provides users with many utilities
* Go provides a light-weight interface to connect with the database. In go you use database/SQL package to use SQL or SQL-like database
* Go is a cloud based language, easily deploy your application on cloud-servers.

It has these features:

* Compiled
* Concurrent
* Statically-typed
* Garbage-collected
* Efficient
* Scalable
* Readable
* Fast
* Open-source

More about Golang:
* <a href="https://golangr.com/">Golang tutorial</a>
* <a href="https://golang.org/">Download Golang</a>
Made my first PORTFOLIO SITE
Tags: webdev, webmonetization, javascript, html
Published: 2020-05-13 16:43:42

Hello Guys,
As you all know I was making my very first portfolio site. By the sake of God, it has been completed few minutes ago. And, I must share with you guys.

https://bit.ly/3fN12eM

Give your feedback. This time please have a detailed look, So that I can learn something more and get some more knowledge.
I know I'm been weird but litterly It is my inner happiness that I today completed my very first site.

              *Thanks You Whom So Ever Has Helped Me In Learing*
What are the pros and cons of versioning in web apps?
Tags: discuss, webdev
Published: 2020-05-13 16:40:53

---
title: What are the pros and cons of versioning in web apps?
published: true
description: 
tags: discuss, webdev
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/ibety4x3zk3198fvv0c0.jpg
---

Is it a good idea to have versions for your web application? Why or why not? How would that affect your DevOps and the maintainability of the codebase in the long run?
Feedback SaveTech landing page (I'm backender)
Tags: help, beginners, feedback, rails
Published: 2020-05-13 16:34:27

Hi everybody,

Together with a colleague we are building [SaveTech](https://www.save-tech.uno/). We needed a toolbox for all the posts, repos, etc that we find while researching for any given tech. 

In order to do that, we usually have used bookmarking apps like Pocket or Raindrop, which are great for their purpose but they are thought for a read-later app, rather than a toolbox 🛠

I'm mainly backend developer and wanted to try my luck with frontend too, so I coded the landing page within the Rails platform instead of letting Webflow save my day again.

I would be delighted if someone with more UI/UX taste (99% of the presents here) could drop a line with the main sins that I could have committed.

[Site](https://www.save-tech.uno/)

Thanks 🙂

P.S: We are waiting for Google's feedback on the extension in order to launch the Alpha, that's why the link to the chrome store doesn't work.
Haters gonna hate
Published: 2020-05-13 16:27:41

Hello!

These are tips I can give when dealing with an hater.

___

PAIN: People sometimes let off steam because they have problems in their lives, and they may have nothing to do with you.

REFLECTION: What a hater says is a reflection of himself and is not about you. 
Who feels good does not need to drag the others down.
I still remember a guy calling me "gay" as an insult in high school, and he secretly was. The worst thing about this is that homosexuality should be respected and not used as an insult. I am happy that finally, he found peace

IGNORE: You want to respond to that negative comment, but don't do it. Of course, if that is a threat, then you can report this to a lawyer 

BLOCK: A simple thing you can do: just block him/her. Remember to take some screenshots, and if needed report this to the platform

RESPECT: Yes, you should respect your hater, even if he/she doesn't deserve that. It is important because by doing this, you demonstrate that you are in control of your emotions and that you are not let down by negativity, which is what he/she wants.

SUPPORTERS: Ask for help. A real or virtual friend can help you in this situation, and the hater is gonna feel more isolated if there is a bunch of people protecting you from his/her attacks

BE YOURSELF: Don't change who you are because someone stopped you with a bad comment. Be yourself and keep going.
___

I hope I have been of help to you my friend.
You are awesome!