teleren/devto huggingface dataset:
LeetCode Explained: 50. Pow(x, n) - Logarithmic Exponentiation (medium)
Tags: computerscience, algorithms, python, mathematics
Published: 2021-07-26 13:26:26

## Problem Description

The task of the problem at hand is quite clear: implement an exponentiation function, **pow(x, n)**, that raises **x** to the power of **n** (**n** is an integer). [Original link here.](https://leetcode.com/problems/powx-n/submissions/)

Constraints:  

- -100.0 < x < 100.0
- -2^31 <= n <= 2^31-1
- -10^4 <= x^n <= 10^4

Example 1:

- input: x = 2.10000, n = 3
- output: 9.26100

Example 2:

- input: x = 2.00000, n = -2
- output: 0.25000

## Let's talk about solutions

It is obvious that we can of course multiply the number **x** by itself **n** times (and in the case of **n** being negative, multiply **1/x** by itself the corresponding number of times). This approach takes O(n) time and is not the fastest one.

The optimal approach is obtained by making a simple statement: 
![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5fb18xhbo4m3j9a5gj0y.png)

And then:

![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4wgs12el4aesvrn7shwy.png)

We can then calculate **x** to the power of **n** by calculating **x^2**, then **x^4** (by multiplying **x^2** by itself) and so forth, until we get to **x^n**.

The algorithm looks like this:
- if **n** is negative, we make **x** equal **1/x** and **n** equal **-n** and take a dump variable, **a** to equal 1; **a** will help us later.
- as long as **n** is greater than 0:
    1. if we find an odd **n**, we multiply **a** by **x**.
    2. we multiply **x** by itself and store the result in **x**.
    3. we divide **n** by 2 and store the result in **n**.
- when **n** becomes 0, the result will be in **a**, because there will always be a case when **n** will be odd; the motivation for this can come from the prime factorisation of an arbitrary number - 2 is the only even prime factor, and if we continue to divide by it we will get to a point at which there will be no 2s left in the prime factorisation of the number.

For this approach to factorisation, we have to perform **log n** operations. If **n** doubles, then the operations performed only grow by 1, as opposed to the first approach, in which the number of operations performed will double if **n** doubles.

This is a very basic implementation of the algorithm:

{% gist https://gist.github.com/KruZZy/5e3cc1fdbbc2b8e9442582609ae3b659 %}

This approach is called logarithmic exponentiation and an examples where it proves useful is computing recurrence relations. I provided a more detailed description of the matter in [this article I wrote some time ago](https://dev.to/kruzzy/the-magic-of-the-fibonacci-numbers-why-we-love-computing-them-part-3-4ce7), which explains how to compute Fibonacci numbers using fast matrix exponentiation.


That concludes today's solution. I'll be back with other LeetCode solutions (including harder ones!) for the **LeetCode Explained** series, so don't forget to subscribe!
Form Validation Errors – don’t embarrass your users
Tags: ux, formvalidation, microcopy
Published: 2021-07-26 13:15:23

---
title: Form Validation Errors – don’t embarrass your users
published: true
//description: 
tags: ux, formvalidation, microcopy
cover_image: https://i2.wp.com/blog.jezmckean.com/wp-content/uploads/2021/07/neonbrand-Cmz06-0btw-unsplash-scaled.jpg
---

**Does it seem fair to scold the user for the errors they make while filling in a form? Are they even “errors”?**

The term “Error” and the usual associated red colouring is remarkably negative. Almost like accusing the user of spilling blood by making a typo or misunderstanding a field’s intended purpose. Okay, perhaps that’s a little extreme, but it’s certainly not a fluffy “_oopsie, shall we try again toghether?_“

To work towards better UX we need to be compassionate, to be empathetic. If the user, who you want (nay, _need_) to be on-side, makes a mistake when filling in your form, there’s nothing to be gained by making them feel daft or at fault.

This is a wonderful opportunity to improve the UX; simply by changing the tone of form validation messages from blame to guidance, your users are more likely to stick around.

Some systems, especially internal systems for staff, may have the slightly troubling luxury of being mandatory for the users, but that shouldn’t excuse a poor experience.

It’s important not to go so far into the fluffy language to appear patronising, and that can be a balancing act, so it’s worth working with copy editors, or even a small cross-section of the users, to land on appropriate messages.

Contrast “_That’s not an email address!_” with “_Please confirm your email address._“. Indeed, compare the message “_Your Order Reference must not contain spaces_” with code that just ignores the spaces – avoiding the messages in the first place can hugely improve users’ experience, which can increase engagement and goodwill and sales.

We’re fortunate that we’re no longer writing things in stone. However uncomfortable it may feel to change something which exists already, we should use the freedom we have in software and web development, and make improvements wherever and whenever they’re identified.

---

Originally posted at https://blog.jezmckean.com/form-validation-errors-dont-embarrass-your-users/
Day 153
Tags: 100daysofcode, programming
Published: 2021-07-26 13:02:43

Day 153/200 of #200DaysOfCode #100DaysOfCode 

- Solved three problems on Codewars.

1 - Is Integer Array? (6 kyu)
2 -  Prefill an Array (6 kyu)
3 -  Difference of 2 (6 kyu)
Crase 🆚 Teclado ABNT
Tags: vscode, abnt, crase, beginners
Published: 2021-07-26 13:00:07


Esses dias tive que enviar meu teclado pra assistência, e estou programando no teclado do próprio notebook.

Uma coisa que vem me dando preguiça é ter que toda hora alterar o teclado para o padrão americano, ou no padrão brasileiro digitar duas vezes a crase("backtricks") pra que ela apareça de fato na tela.

Como estou estudando #JavaScript diariamente, e escrevendo resumos de livros em Markdown, o uso de crase pra usar `${templateString}` ou `inline code` no Markdown tem sido intenso.

Achei uma solução paliativa onde agora seleciono o texto no VSCode e digito um comando para ele envolver o texto entre as crases. Caso você se interesse, segue passo a passo:

1. Digite <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd> no VS Code e no campo busca escreva Open Keyboard Shortcuts e escolha a opção JSON

![Atalhos VSCode](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eeiu8kkqv4ytoeu7a170.png)
2. Se seu arquivo JSON estiver vazio, copie e cole o texto abaixo e salve o arquivo:
```
[
  {
    "key": "ctrl+shift+i",
    "command": "editor.action.insertSnippet",
    "when": "editorTextFocus",
    "args": {
      "snippet": "`${TM_SELECTED_TEXT}$1`$2"
    }
  }
]
``` 

![Arquivo Json de Atalhos 01](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/blbgcqzww08hjnb5cbch.png)

Obs.: escolhi o atalho <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>i</kbd> porque estava setado para exibir breadcrumbs dos arquivos abertos, que é algo que eu não preciso.

3. Caso já tenha algo no seu `keybindings.json` faça desta forma:
    * logo após o fechamento da última chave `}` e antes do fechamento do último colchete `]`
    * digite uma vírgula `},` e pressione <kbd>Enter</kbd>
    * copie e cole o código abaixo
```
  {
    "key": "ctrl+shift+i",
    "command": "editor.action.insertSnippet",
    "when": "editorTextFocus",
    "args": {
      "snippet": "`${TM_SELECTED_TEXT}$1`$2"
    }
  }
``` 
Como deve ficar seu JSON neste caso:

![Arquivo Json de Atalhos 02](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j79zduc4rjtg61s9t0ch.png)

Agora você poderá selecionar um texto qualquer e digitar o comando <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>i</kbd> e **voilá!** the magic just happened!


![Gif de seleção de texto](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f464onyilxakbwxzpgtn.gif)
.NET Core project .gitignore file
Published: 2021-07-26 12:50:52

A default .NET Core project .gitignore file - or just type `dotnet new gitignore`. By github.com/vmandic

```
# From .NET Core 3.0 you can use the command: `dotnet new gitignore` to generate a customizable .gitignore file

*.swp
*.*~
project.lock.json
.DS_Store
*.pyc

# Visual Studio Code
.vscode

# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/
msbuild.log
msbuild.err
msbuild.wrn

# Visual Studio 2015
.vs/
```
How can custom software development help your business?
Published: 2021-07-26 12:50:18

Optimal software solutions have helped business platforms grow over the past few years, so it will sound outdated to discuss only their necessity. In this article, we will learn in detail about software development programs and their impact on business platforms in real time. Before we begin, it is very important for you to learn about the prevailing specialized software solutions.

Among commercial organizations, custom software development has become the latest trend. The reason it calls is because this software is capable of solving the most specific business requests. A bespoke software company can develop the most specific and customized applications for your platform to meet the needs of viewers or customers.

What's so compelling about custom software development?

There are a number of applications with a different set of functions. It is not necessary that the one that matches any other match will work for yours. Customization in software development meets your requirements and ensures that you get the best platform for growth. Even during the development stage, you will have ample opportunity to include a number of tricks in the program for your reliability. You can order software development from specialists https://djangostars.com/services/bespoke-software-development/

Among the range of expectations for software development solutions, efficiency and reliability remain unchanged, even if it is a personal or business platform. Below are some reasons that provide strong evidence for custom software development. In addition to the benefits for you, there are a number of utilities such as:

Supports data processing
You get the highest quality result
Increases speed
Saving money, time and resources without a doubt
With fully functional features, it provides better support
You get real access to business processes
Enhance GIT Experience
Tags: github, programming, webdev, design
Published: 2021-07-26 12:49:16

These days there are plenty of trendy ways to improve your programming skills and knowledge.

Why Learn About Git?

Git's codebase is an incredible resource for intermediate developers to further their programming knowledge and skills.

Here I am listing some tutorials which is useful.

1. [Chrome extensions I use to enhance my GITHUB experience](https://cmsinstallation.blogspot.com/2021/04/chrome-extensions-i-use-to-enhance-my.html)

2. [Boost Your Programming Skills by Reading Git's Code
](https://www.freecodecamp.org/news/boost-programming-skills-read-git-code/)

3. [5 Git workflows and branching strategy you can use to improve your development process](https://zepel.io/blog/5-git-workflows-to-improve-development/)

4. [Why Git for your organization](https://www.atlassian.com/git/tutorials/why-git)

5. [Learn Git, Enhance Your Development Workflow](https://www.groupeneos.com/en/learn-git-enhance-development-workflow/)
Low-code and data silos
Tags: lowcode
Published: 2021-07-26 12:19:32

---
title: Low-code and data silos
published: true
description: Don't dismiss low-coders; they are often innovators
tags: lowcode
//cover_image: https://direct_url_to_image.jpg
---

I saw [this article](https://venturebeat.com/2021/07/24/low-code-a-promising-trend-or-a-pandoras-box/) the other day, in which the author warns of the risk in allowing low-code solutions to develop in (large) organisations. The argument made was that it encourages "data silos" that don't connect to the rest of the corporate structure, resulting in inefficiency, fragmentation and loss of control.

While there's some truth in this, an important point is being missed:

> _Innovation doesn't always come from the center_

In top-down, hierarchical organisations, innovation doesn't just happen at the center; in fact, it often doesn't happen there at all. The focus there is more on holding onto a rigid structure at all costs to prevent it from fragmenting. Central IT departments don't in general value input from non-professionals elsewhere in the enterprise; they certainly don't go out actively looking for it.

A low-code solution will spring up in some random corner of an organization, where a problem needs to be solved quickly and for which no solution is forthcoming from the center. The people on the ground who identify the problem are not professional programmers and they don't have connections to the IT department, so they reach for whatever solutions work for them.

In some ways, these local initiatives work in the same way as a skunk-works. The difference is that the latter is set up as deliberate corporate policy, given an often quite vague brief then left to get on with it unchallenged. Low-code is an enabling technology that allows much the same to happen, but in an unoffical way. Provided the extra effort doesn't impact on normal performance it can do little harm.

The people who embark on such projects are usually highly motivated but are frustrated by their inability to get anyone to listen to their complaints or suggestions. Low-code allows them to create local solutions using their existing skills, without the need to learn new ones. This is nothing new. In the early days of the microcomputer revolution (mid-1970s), IT departments were manned by professionals using minicomputers such as PDP-11 (remember them, anyone?). If we proposed the use of microprocessors (8080, 6800, etc) we were laughed out of the room. So we went away and did the job in our spare time using these new devices and without telling anyone until it was all finished. Tell me, who was right?

The answer is not to decry such attempts from a position of lofty superiority, but to actively seek them out, encourage them and work with them. Yes, they will sometimes be disruptive, but the ideas they reveal will often be ones that can be of massive benefit to the organization.
Elasticsearch in Action (2e)
Tags: elasticsearch
Published: 2021-07-26 12:07:33

I am absolutely delighted and humbled to announce my upcoming book [Elasticsearch in Action (second edition)](https://www.manning.com/books/elasticsearch-in-action-second-edition?utm_source=mkonda&utm_medium=affiliate&utm_campaign=book_konda_elasticsearch_7_23_21&a_aid=mkonda&a_bid=edbc50d4). It is available for early access at Manning.

In the current digital world, search is the new normal. Elasticsearch is a multi-faceted popular search engine with a ton of advanced features and many bells and whistles. A humongous task was bestowed upon me to create a new In Action book on a complicated technology that is ever-changing at a rapid rate.

Elasticsearch in Action (second edition) is a completely rewritten hands-on guide to developing fully functional search engines with Elasticsearch and Kibana. It's an example driven, straight to the point book that explores Elasticsearch’s high-level architecture and walks through the search and analytics capabilities of numerous Elasticsearch APIs.

In this book you will learn:

* Installing, configuring and running the Elasticsearch and Kibana
* Working with document operations such as indexing, reading, updating and deleting
* Understanding the text analysis and mapping schema features
* Developing a multitude of search queries
* Enabling search results with sorting and pagination functionality
* Writing and working with advanced search queries
* Working with analytics and aggregations
* Developing high level visualizations in Kibana
* Configuring and scaling the clusters, and tuning performance

You’ll quickly progress from the basics of installation and configuring clusters, to indexing documents, advanced aggregations, and putting your servers into production. By the time you’re done, you’ll be ready to build amazing search engines for your clients that take advantage of Elasticsearch’s modern features.

The code for the book is available at my [GitHub](https://github.com/madhusudhankonda/elasticsearch-in-action) repository. 

This book is a hand-holder for anyone who's either starting up on the journey of Elasticsearch or learning the ropes. My aim is to provide an easy to understand example-driven page turner. Hope I'll succeed in that.

I am pretty happy to hear your feedback, so please let me know how you find the book so far. I will do my best to shape this book into a must-have book with your help.

It was always my dream to write an "action" book for Manning - and here that dream coming true! Team at @manningbooks are amazing and so grateful for their humongous support and help!

Looking forward to hearing your views and reviews!
Today's Daily Humor For Devs - Daily Developer Jokes
Tags: jokes, dailydeveloperjokes
Published: 2021-07-26 12:00:16

---
title: "Today's Daily Humor For Devs - Daily Developer Jokes"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
published: true
tags: #jokes, #dailydeveloperjokes
---

Hi there! Here's today's Daily Developer Joke. We hope you enjoy it; it's a good one.

![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e125969479bf.png)

---

For more jokes, and to submit your own joke to get featured, check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/). We're also open sourced, so feel free to view [our GitHub Profile](https://github.com/dailydeveloperjokes).

### Leave this post a ❤️ if you liked today's joke, and stay tuned for tomorrow's joke too!

_This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit._

<!--
Joke text:
___Q:___ What did XHR say to AJAX when it thought it was being a Mean Girl?

___A:___ Stop trying to make fetch happen!
 -->
Should I learn php when there are tools like WordPress? 
Tags: wordpress, php, webdev
Published: 2021-07-26 11:56:04

I usually get this question from alot of new developers in the field. Every one feels like it's a waste of time to learn php now that certain CMS like WordPress is around which can build basically any website you want it to build. Well, I won't say any website because we humans are full of creativity and we can come up with different website ideas or features which we might want to include in our websites.
 
 These our imaginations might not be found in any WordPress plug-in directory or theme directory and we might have to build one yourself in order to make that dream a reality.
This is where programming comes in as you can build your entire imaginations from scratch and host it anywhere you like.

 In terms of the monetary value of php, even if it is seen as the dying language by most developers it's still a must learn because the entire WordPress was built using php and it made provisions for programmers like us to create extra functionality (plugins) which can be sold in several WordPress theme markets and serve as a side job for you. Remember that php is still powering 70 percent of the web and majority of these 70 percent websites were built using WordPress. This means that your plug-in or theme is open to more than a billion websites on the web which is a good market for most php developers. I've written down alot of reasons on benefits of php and I'll suggest you check out [why php is worth learning](https://www.charmingdesk.com.ng/2021/06/03/is-php-still-worth-learning-in-2021/) and give me your feedback.

Happy coding♥️
What’s the problem with metadata?
Tags: privacy
Published: 2021-07-26 11:41:17

A friend asked me over the weekend: "What’s wrong with WhatsApp?" 

If messages are encrypted, what’s the big deal? That’s a fair question. The answer reveals a larger problem. The problem with companies (in this case, Facebook) collecting metadata _around_ your data.

Let's see why this is dangerous.

## What’s a metadata anyway?

Data-hungry companies often defend themselves with this misleading statement: "It's OK, it's just metadata."

Well, what's a metadata? It's data that's about other data. For example: In a chat app, if the message is the primary data, then the metadata could be:

- The time of the message
- Who you're talking to.

Something like "Ben sends 1 message to Jack today at 18.33"

It's not OK at all.

## Why are metadata dangerous?

Metadata collection is harmful to privacy. One single metadata may be harmless, but the more metadata you have, the more complex and precise a picture of you emerges. Let's not forget, metadata come from a variety of sources.

Let's go back to our example

"Ben sends 1 message to Mark today at 18.33"

That's pretty innocuous, right ?

But when Ben sent the message, WhatsApp (and by extension, Facebook) collected its location. If Ben sent 5 messages over 10 minutes without changing location, Facebook knows Ben isn't moving too much.

It turns out, Ben is sitting in a waiting room. Waiting to see a discernment counsellor. That's a therapist for people _thinking_ about divorce. Ben wants to work on himself to save his marriage.

Facebook knows who Ben is married to already. They know it from an Instagram story of the wedding posted by one of Ben's contacts (even if Ben himself isn't on Instagram).

Now, from this piece of metadata (his location), Facebook can guess that Ben's marriage isn't doing well.

Before Ben even left the waiting room, his wife Sarah received an ad[^1] for a divorce lawyer. 15 minutes later, Sarah sees another ad for a dating app.

[^1]: Facebook sells information to advertisers everywhere on the Internet, not just on its platform. So Ben's wife can see the ad anywhere on the Internet, even if she's not on Facebook.

You see, even a series "simple metadata" can reveal a lot about you.

This is not limited to Facebook. Anyone with metadata about you can run very complex algorithms and profit from it.

If your bank starts speaking about "sharing data with trusted partners," you should opt-out. Immediately. Now you know how they can make money from your location and card purchases.