teleren/devto huggingface dataset:
Using 🎭Playwright in python:alpine
Tags: playwright
Published: 2021-08-10 13:41:26

---
title: Using 🎭Playwright in python:alpine
published: true
description: Introduces how to use playwright-python on Alpine Linux.
tags: Playwright
cover_image: ""
 
---

[playwright-python](https://github.com/microsoft/playwright-python) is a really awesome library for browser automation.

However it doesn't support running on Alpine Linux.
https://github.com/microsoft/playwright-python/issues/234

Most web developers would use Alpine based Docker images, and actually playwright-python internally has a capability of running scripts in Alpine.

## Why playwright-python cannot run on Alpine?

![image](https://github.com/YusukeIwaki/playwright-python-playWithWebSocket/blob/main/docs/current.png?raw=true)

playwright-python comes with a browser downloader. As we know, browsers requires many dependencies. The deps are not compatible with Alpine.

This might be a main reason why playwright-python deny running on Alpine.

By the way, we already know Selenium Remote driver (Selenium Grid), it separates script runner and browser environments communicating with HTTP port (default: 4444).

## How to separate script runner and browsers

![image](https://github.com/YusukeIwaki/playwright-python-remote/raw/main/README/structure.png)

playwright-python is just a Python client library of Playwright. Playwright server communicates with browser via WebSocket or other protocols, and playwright-python communicates with the server via **pipe** by default.

However playwright-python already introduced **WebSocketTransport** for the API `BrowserType#connect()` in Playwright v1.11 and later. It can be also used for Playwright connection between client and server.

### Try it!

I created a tiny library.
https://github.com/YusukeIwaki/playwright-python-remote

This library provides a Playwright initializer (ContextManager) just replacing PipeTransport with WebSocketTransport.
https://github.com/YusukeIwaki/playwright-python-remote/blob/main/playwright_remote/sync_api/sync_playwright_remote.py

Playwright Server can be prepared very easily with Docker like this:

```Dockerfile
FROM mcr.microsoft.com/playwright:focal

WORKDIR /root
RUN npm install playwright@1.12.3 && ./node_modules/.bin/playwright install
CMD ["./node_modules/.bin/playwright", "run-server"]
```

Now we can enjoy playwright-python on Alpine:

```python
from playwright_remote.sync_api import sync_playwright_remote

with sync_playwright_remote('ws://127.0.0.1:8080/ws') as playwright:
  browser = playwright.chromium.launch()
  try:
    page = browser.new_page()
    page.goto('https://github.com/YusukeIwaki')
    page.screenshot(path='YusukeIwaki.png')
  finally:
    browser.close()
```

---

I also tried it on Heroku: https://zenn.dev/yusukeiwaki/scraps/3ad5f8ed536720 (Sorry, Japanese only...)


## Conclusion

playwright-python is really awesome, it runs on Alpine actually.

Note that WebSocketTransport (introduced in this article) is internal class and can be changed in future releases.

Just expect the feature is officially supported. Let's upvote
https://github.com/microsoft/playwright/issues/4687 :+1:
Variables
Tags: ocaml, newbie, howto, tutorial
Published: 2021-08-10 13:31:56

It's an expression and ;; says to ocaml treats this line as expression

```ocaml
3 + 4 ;;
```

And heres variable declaration or `let binding`

```ocaml
let x = 3 + 4 ;;
(** val x : int = 7 *)
```

After a new variable is created, the toplevel tells us the name of the variable (x), in addition to its type (int) and value (7).

Also with let you can define a function

```ocaml
let square x = x * x ;;

(** val square : int -> int = <fun> *)

square (square 2) ;;

(** - : int = 16 *)
```

Function in ocaml is a first class citizen. 

> Note: `;;` is required only in repl, not in your source code.
Should you transition to Golang?
Tags: discuss, go, frameworks, watercooler
Published: 2021-08-10 13:21:00

---
title: Should you transition to Golang?
published: true
description: I'm curious how you feel, do you think services should be rewritten in Golang?
tags: discuss, golang, frameworks, watercooler
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jg8hxhoja7fgjigbzuh2.jpeg
---
*Cover image by Bjørn Erik Pedersen, CC BY-SA 4.0, via Wikimedia Commons*


Late last year AWS announced that their Lambda compute service would [bill by the microsecond](https://aws.amazon.com/blogs/aws/new-for-aws-lambda-1ms-billing-granularity-adds-cost-savings/), this change didn't matter much for those who were developing in Java or .NET, after all a run of 12 or 25 seconds wouldn't be that much cheaper divided into microseconds, but it *did* matter for those working in Go. Since Go starts and runs so quickly, suddenly runs of a Lambda function written in Go could cost half as much as before.

Golang is fast, and compared to some other web development languages it performs tasks using less memory and CPU, so it *seems* obvious that Go should be used for almost everything. 

But ask yourself how often the limiting factor for a web service is actually RAM.

The selection of a programming language is based on a number of factors, and changing languages even for a lone developer is a difficult, expensive process. For a large team it's possible to lose a year trying to retrain or rehire the expertise you need to build features.

So I'm curious how you feel, do you think services should be rewritten in Golang?
Tips to Develop Role-Playing Mobile Game
Tags: gameappdevelopment
Published: 2021-08-10 13:20:32

---
title: Tips to Develop Role-Playing Mobile Game
published: true
description: Games are the most downloaded app on the App Stores. Undoubtedly, role-playing games top the list
tags: gameappdevelopment
//cover_image: https://www.apptunix.com/blog/wp-content/uploads/sites/3/2019/02/blog.jpg
---
Games are the most downloaded app on the App Stores. Undoubtedly, role-playing games top the list. However, if you’re also a game fanatic aiming to develop a super engaging game for users like you, we have some mind-blowing secrets of building a unique role-playing game. 

Above all things, you have to be very sure about the type of game you’ll put out for your users. So first, we recommend you create a clear & concise scope of work. Next, create a very concrete storyline that you can give to the [mobile game development company](https://www.indianappdevelopers.com/mobile-game-development-company.html).

Further, create an atmosphere; take the example of PUBG, where they have created a battleground. Think of a very appealing background and, yes, of course, match it with the storyline. Don’t forget to keep it classic & professional. Hire a mobile game development company that excels at creating enchanting games.

The main factor in any role-playing game is the character, so let your users create a character. Give them numerous options based on the storyline. Good-looking characters are the most preferred by gamers, so make sure to develop it that way. A secret that you should incorporate - Artificial Intelligence. AI is a powerful tool to create a decisive role-playing game. AI adds a dash of realism to the character through the behavioral effects, which attract the audience immensely. Adding villains or villains can work as an excellent benefit for you. Negative feelings in the game make users indulge in the game more actively.

Another vital secret is to add a powerful soundtrack to the gameplay. Ask your mobile game development company to add immersing soundtracks that can work as a great source in leading your users to engage in the game. Finally, yet importantly, using good RPG developmental tools, no compromise in that.

So, these were few secrets that you shouldn’t miss out on. Missing out on these crucial guidelines means losing out a majority of gamers. All the best, we know your RPG is going to top the App Stores.
Just Ask
Tags: philosophy, life, advice
Published: 2021-11-09 23:43:08

---
title: Just Ask
published: true
date: 2021-06-25 16:49:00 UTC
tags: philosophy,life,advice
canonical_url: https://ivans.io/just-ask/
---

I had an interesting phone call with a hotel chain the other day, where I called to politely express some concerns I had with my experience. There was a massive voltage surge that fried all the lights, so I had to move out by flashlight late at night into a different room.

The conversation went roughly like this:

> Me: Hi, my name is Ivan and I had some concerns about my recent stay {list concerns here}. Could I get some rewards points for the inconvenience?

> Rep: Sure, let me look into that. {after a 15 minute hold} Hi there, we can give you X points.

> Me: Thank you, that's very kind. Given the nature of the concern, could you do more?

> Rep: Since you asked, the max I can do is 1.5X. Here you go.

And that was that. I earned a fairly significant volume of reward points for a hotel chain that I enjoy, simply by being polite. The biggest showcase here is that second question:

> Can you do more?

Most people never even ask the first question. I know many folks who will complain or boycott the hotel. Yet, it always amazes me when those same people don't call and ask for points or other perks.

**If you never ask, the answer is always no.**

It's incredible how often a simple ask, followed by a humble clarification if this is the most that is possible, leads to incredible results.

**It's important to never be entitled or expect anything.** Most service reps that you chat with are underpaid and working long hours. Coming into the conversation with compassion and politely asking for the benefits that you would like has a surprisingly high success rate.

I have called and used this technique many times. Just asking one question has been enough to double my signing bonus, get tickets to sold out shows, and so much more. It doesn't always work - sometimes there really is no leeway. But, by calling and politely asking you are already doing more than most.

Don't be afraid of rejection - the worst that happens is that some call center representative you will never talk to again says "no". If you are polite, you are not imposing on them. They are trained for this and want to help you out and make things better.

**Just ask.**
Installation of utop
Tags: ocaml, newbie, howto, tutorial
Published: 2021-08-10 13:18:11

Install some of required libraries for next sections 

Utop -  is an easier-to-use version of OCaml’s standard toplevel (which you can start by typing ocaml at the command line).

```
opam install base utop
```

Remark on this from real world ocaml

![Screen Shot 2021-08-10 at 5.14.31 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l4qbv0dz5qrw93pn02pi.png)

Write utop in terminal and here we go!

```
utop
```
Free web dev resources/links
Tags: webdev, css, html, javascript
Published: 2021-08-10 13:13:10

#Free resources and links for web developers.

Hey, I thought I would share some of my bookmarked sites with free content for all of web developers around here. I use many of them and they saved me a lot of time.

**1. React Slideshow**

https://www.npmjs.com/package/react-slideshow-image

Simple slideshow for React with straightforward implementation. I've used it before on some of my projects. Looks good and can be customised.

**2. Ionicons. Free open-source icons**

https://ionic.io/ionicons

Beautiful icons to use on your projects. Many different icons for a lot of uses and even some logos too. One of the best icons websites in a sea of many.

**3. Haikei. Patterns generator**

https://app.haikei.app/

Useful pattern generator for backgrounds and shapes. Customise to your own needs and then download in PNG or SVG.

**4. CSS Gradients**

https://cssgradient.io/

A great website to generate your CSS gradients. Pick colors, degrees and more then the code gets generated just below for you to use!

**5. Free for devs**

https://free-for.dev

Last but not least, a websites with TONS of free resources. From BaaS to hosting and more. This website is a goldmine.


**That's it for now, I hope there's people who find this useful.**

My personal website:

https://stylidis.io

Drop a follow on Twitter and connect with me!

https://twitter.com/AStylidis
Crack The Coding Interview With Me:DFS
Published: 2021-08-10 13:05:03

# 📚 Theory:

{% youtube PMMc4VsIacU %}
{% youtube cWNEl4HE2OE %}

<a title="Mre, CC BY-SA 3.0 &lt;https://creativecommons.org/licenses/by-sa/3.0&gt;, via Wikimedia Commons" href="https://commons.wikimedia.org/wiki/File:Depth-First-Search.gif"><img width="256" alt="Depth-First-Search" src="https://upload.wikimedia.org/wikipedia/commons/7/7f/Depth-First-Search.gif"></a>
# 👩‍💻 Code:
{% gist https://gist.github.com/olg200492/b4d5423c2df307bdbc31580019a5c0d7 %}





## 🗃 Interview Questions
* [GeeksForGeeks](https://www.geeksforgeeks.org/top-10-interview-question-depth-first-search-dfs/)
* [techiedelight.com](https://www.techiedelight.com/dfs-interview-questions/)
* [medium.com](https://medium.com/@codingfreak/depth-first-search-dfs-interview-questions-and-practice-problems-3862d9cd26f)
Cool Stuffs About Programming I Wish I Knew Earlier
Tags: javascript, webdev, beginners
Published: 2021-08-10 12:58:55

Hey guys, have you ever stumbled upon cool tricks when programming and wondered how you lived without them? In this article, I'll show you a couple of cool tricks you might now know.

###[1] Add Item To Beginning of Array in JavaScript
Using spread operator right? No. Turns out there's a cleaner way to add item to beginning of an array which is by using unshift method.
```javascript
const arr = [2, 3, 4, 5];
const newArr = arr.unshift(1);

console.log(newArr); // output is [1, 2, 3, 4, 5]
```

###[2] Select Colors Like A Pro
To be honest with you, people judge your app heavily based on the UI and the color scheme you use (a lot of them don't care if you used message queue or sharded your database although these are important to build apps at scale). There's a site called Coolors (coolors.co) which generates you a lot of cool color palettes in no time so you don't have to pick random colors manually for your app which eventually you will mess up. 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ucsb9bakr9ydo39u7z1t.PNG)

###[3] Don't Call API Directly
Calling APIs directly might not be the best idea because it pollutes the codebase. Based on the frontend language/framework/library you're using, find out a way to create a generic function to call API and handle response/error from it. Here's an example of reusable Hook to call APIs in React Native (using Apisauce):
```javascript
import { useState } from "react";

export default useApi = (apiFunc) => {
  const [data, setData] = useState([]);
  const [error, setError] = useState(true);
  const [loading, setLoading] = useState(false);

  const request = async (...args) => {
    setLoading(true);
    const response = await apiFunc(...args);
    setLoading(false);

    setError(!response.ok);
    setData(response.data);
    return response;
  };

  return {
    data,
    error,
    loading,
    request,
  };
};
```
<a href="https://www.buymeacoffee.com/mohmedishak" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>
Understanding Dependency Inversion principle
Tags: solid, architecture, php
Published: 2021-08-10 12:55:13

*"Depend upon abstractions, [not] concretions."*

Dependency Inversion is the "D" of the [SOLID](https://en.wikipedia.org/wiki/SOLID) principles promoted by [Robert C. Martin](https://en.wikipedia.org/wiki/Robert_C._Martin).

There are a lot of articles talking about it, but I want to explain it as easily as possible through an example.

When you create a new service, create first its `interface`, then implement it in a `class`.

## Example

A service that calculates the average of two numbers.

Interface has the contract that will always be respected

```php
interface AverageCalculator
{
    public function calculate(float $first, float $second): float;
}
```

Then, the implementation (which can be anything... a call to an external API, package, your own implementation...)

```php
use AverageCalculator;

class InMemoryAverageCalculator implements AverageCalculator
{
    public function calculate(float $first, float $second): float
    {
        return ($first + $second) / 2;
    }
}
```

When you inject it in a controller, never inject the class, inject the interface. Let `Service Container` resolve it.

```php
use AverageCalculator;

class Somewhere
{
    private AverageCalculator $calculator;

    public function __construct(AverageCalculator $calculator)
    {
        $this->calculator = $calculator;
    }

    public function __invoke(float $first, float $second): float
    {
        return $this->calculator->calculate($first, $second);
    }
}
```

`Service Container` knows what is the implementation (InMemoryAverageCalculator) so we just need to configure it if required.

## Benefits

There are several benefits of this approach:

- You force yourself at first step to define a contract (interface) knowing what you want.
- You can change the implementation at any time without having to change everywhere it is used.
- Concretions will not affect to the design of your application because your interface rules the inputs / outputs.

## Conclusion

When injecting an interface, you are depending upon an abstraction, you don't set the class that implements that logic but yo define what to expect from that class.

This brings a lot of flexibility and adaptation to changes.

Remember:

*Abstraction === Interface*
*Concretion === Class with implementation*
Bookmark Catatan Belajar dan Referensi
Published: 2021-08-10 12:51:58

## Frontend Dev
* [Bezier curve generator](https://cubic-bezier.com/#.17,.67,.83,.67)

## Unix/Linux
* [Globbing](https://stackoverflow.com/questions/28176590/what-do-double-asterisk-wildcards-mean/28199633)

## Coding Interview Weapon
* [Data Structure Visualization](https://visualgo.net/en)
* [Competitive Programming reccomendation from errichto](https://cses.fi/book/book.pdf)

## Misc
* [Create symbol with just HTML](https://www.htmlsymbols.xyz/unicode/U+2714#:~:text=%E2%9C%94%20%2D%20heavy%20check%20mark%20(U%2B2714)%20%2D%20HTML%20Symbols)
* [Compare library on github](https://www.githubcompare.com)
* [Public API's](https://github.com/public-apis/public-apis)
* [To Create Regex](https://regex101.com/)
* [Makefile tutorial](https://makefiletutorial.com/)
* [Divider Each Section](https://www.shapedivider.app/)
* [Divider and SVG's](https://app.haikei.app/)
* [How to write resume and cover letter](https://ocs.fas.harvard.edu/files/ocs/files/hes-resume-cover-letter-guide.pdf)
* [DDL, DML, TCL, DCL](https://www.geeksforgeeks.org/sql-ddl-dml-tcl-dcl/)
Doctave.com opens to public beta
Tags: showdev, writing, agile
Published: 2021-08-10 12:45:19



We are excited to announce that Doctave.com is now in public beta. Doctave.com is the best place to host your docs-as-code documentation, and it’s available for everyone starting today.

## What is Doctave.com?

At the end of last year we created [Doctave](https://www.github.com/Doctave/doctave), a batteries-included static site generator. But there are many features that a documentation site generator cannot provide that are important for larger teams. If you have 50 different repositories, you would end up with 50 disconnected documentation websites to manage and configure. No standardization, nothing to link the docs together.

Today we are making available [Doctave.com](https://www.doctave.com) to solve these issues, making it the best place to host your technical documentation.

By using Doctave.com for your documentation you get:

* A private space for all your organization’s documentation
* Visual diffs of changes
* GitHub Pull-Request integration
* Search across all projects at once
* Option for public-facing documentation

And most importantly: no lock-in. Your docs are just Markdown files in your Git repository, rendered by Doctave.com.

Let’s take a look at some of these features closer.

## Visual diffs

One piece of feedback we heard many times was that it was hard to see what actually changed in the documentation looking at a raw Git diff. People wanted to see a visual diff of the documentation rendered normally.

So we built it.

![visual diff preview](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/icwoqyfqi7nupr6r50zn.png)

This is a preview of changes for our [public-facing](https://docs.doctave.com/Doctave/Doctave/) documentation. For each pull request you can see exactly what changed, rendered on Doctave.com.

## GitHub integration

For many software engineering teams a lot of our work happens on GitHub. This is why it was important for us to make sure Doctave.com works well with Pull Requests. When you push your documentation to Doctave.com, we annotate your commits with links to preview your updated docs.

![doctave github integration example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kwx7ak76qq06w964945f.png)

Your documentation deserves the same attention as your tests, and Doctave.com helps you to never forget to update the docs.

## We’re just getting started

We have a long list of features we are excited to build to make writing and maintaining quality documentation even easier. Here’s a quick sneak preview of things we are planning:

* Documentation linters that verify your docs on every push
* Analytics to help you see what docs people are reading
* Feedback mechanisms to help improve your documentation

And much more…

## Want to try it out?

Sign up for a free trial [here](https://docs.doctave.com). No credit card required. If you have any questions, feel free to email me at nik@doctave.com.

Happy documenting!
🎬Clock App | Vanilla JavaScript⏱️
Tags: javascript, css, beginners, webdev
Published: 2021-08-10 12:43:28

Hey DEVs In today's episode, we will create from scratch a “Clock App | Vanilla JavaScript”,  will also are gonna use this new and popular trend Glassmorphism on it…

---
{% youtube KcLTSfAqGl8 %}
---

---

Essentially, the main aspect of this trend is simple:
* we need a semi-transparent background
* A sublime shadow and border.
* We also have a blur on it so that whatever is behind the background is beautifully "morphed" into the element itself.

 It’s a quite simple project to do, but at the same time it will teach you a lot of cool things in css and also JavaScript.

---

📚Resources
Pic used in this Project:
https://bit.ly/37xJH6G

---
Cómo validar que un correo existe usando PHP
Tags: validación, correo, php
Published: 2021-09-16 12:02:49

---
title: Cómo validar que un correo existe usando PHP
published: true
date: 2021-08-10 12:32:00 UTC
tags: validación, correo, php
canonical_url: https://academy.leewayweb.com/como-validar-que-un-correo-existe-usando-php/
---

Seguramente alguna vez te habrás topado con la necesidad de registrar correos electrónicos de los visitantes de tu sitio, ¿cierto? Usualmente esto se hace para mantenerlos al tanto de las novedades. Claro que, aunque vos tengas las mejores intenciones, es entendible que la gente sea un poco escéptica con tanto spammer dando vueltas, por lo […]

La entrada [Cómo validar que un correo existe usando PHP](https://academy.leewayweb.com/como-validar-que-un-correo-existe-usando-php/) se publicó primero en [Leeway Academy](https://academy.leewayweb.com).
Day 16 - Container With Most Water
Published: 2021-08-10 12:17:05

Back to Leetcode after a week. I am doing a Spring Microservices course in parallel which is going to take more of my challenge time.

However, wanted to do something different today.

### Day 16 - Container With Most Water

Problems and my solutions can be found in my GitHub repo along with all other problems I have solved till date.

[Leetcode](https://leetcode.com/problems/container-with-most-water)
[GitHub link to problem and solution](https://github.com/abh1navv/leet-code/tree/master/container-with-most-water)

If you want to check my updates for the past 7 days, you can check my Twitter. It could be interesting for Java developers trying to find a roadmap to Spring.

You can connect with me at &nbsp;
[LinkedIn](https://www.linkedin.com/in/abh1navv)
[Twitter]
(https://www.twitter.com/abh1navv)