teleren/devto huggingface dataset:
Press a key without actually pressing it 
Tags: android, todayilearned, editext, ux
Published: 2020-06-11 14:02:28

Story Before 

So I had this feature to build where a user is (let's say) writing his tweet. And just below the EditText I have provided with two buttons which allow the user to enter a "#" and a "@". 

Issue

An easy job right(that's what I thought), just use `editText.append("@"/"#")` and the required character will be appended to the end of the text . 
Well that's where I came across an issue . If the user changes the cursor position manually and presses one of the buttons, still the "#" or "@" is added at end of the text (instead of at the cursor position )BAD UX 

Solution

In comes the `BaseInputConnection`'s `sendKeyEvent` method .

```
EditText editText;
BaseInputConnection inputConnection = new BaseInputConnection(editText, true);
inputConnection.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_POUND));
```

It will give the desired result.
FREE 5-day Angular Security Mini-Academy
Tags: angular, javascript, webdev, security
Published: 2020-06-11 13:49:29

---
title: FREE 5-day Angular Security Mini-Academy
published: true
description: Free 5-day online training gives you over 2 hours of practical video lessons on the full-stack security of your Angular applications!
tags: angular, javascript, webdev, security
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/e3trmph0sx24noqqursx.png
---

It's available now! FREE **Angular Security Mini-Academy**!
> OVER 2 HOURS OF FREE LESSONS!

💥 Client-side security boundaries
💥 OWASP Top 10 explained
💥 Cross-site scripting attacks
💥 JSON Web Token (JWT) Hacking
💥 Role-based access control design

[JOIN FOR FREE](https://angular-academy.lpages.co/mini-security-academy/)
The Great Improvement of dbForge SQL Complete v6.5
Tags: sql, ssms, visualstudio, database
Published: 2020-06-11 13:35:14

---
title: The Great Improvement of dbForge SQL Complete v6.5
published: true
description: Devart introduced the new version of its flagman solution, dbForge SQL Complete, which is packed with brand-new and significantly improved core features. 
tags: Sql, SSMS, VisualStudio, Database
---
*Devart introduced the new version of its flagman solution, dbForge SQL Complete, which is packed with brand-new and significantly improved core features.*

Devart, a recognized vendor of professional database management software for developers and DBAs, released the new version of its flagman solution – [SQL Complete v6.5](https://www.devart.com/dbforge/sql/sqlcomplete/). The popular add-in for SSMS and Visual Studio is packed with improvements, and the main one is **full support for SQL Server 2019**.

The release also includes such key enhancements as:

- **SQL Complete New Edition.** The vendor expanded the range of SQL Complete editions with SQL Complete v6.5 Standard Edition. The special edition offers full Intelligent SQL Completion and T-SQL Formatting capabilities. However, for those users who need more, there's still Professional Edition featuring advanced Productivity and Code Refactoring options as well as SQL Formatting command-line interface support.
- **Microsoft SQL Server Management Studio v18.5 integration.** The Devart team strives to keep its finger on the pulse of software development, thus the new SQL Complete can now be easily integrated into the latest version of SSMS.
- **Suggest properties for built-in metadata functions.** In SQL Complete v6.5,  properties for built-in metadata functions (SERVERPROPERTY, FILEPROPERTY, DATABASEPROPERTYEX, etc) are now prompted, allowing users to make full use of the system catalog to find out more about a database.
- **Temporary tables suggestion**. Based on user demand, Devart brings the suggestion of temporary tables variables and columns regardless of the database specified in the USE statement.
- *OPENJSON objects suggestion.** SQL Complete v6.5 can now boast suggestions for SQL server objects when working with OPENJSON SQL Server table-valued function.

At the same time, the Devart team has supported a bunch of new functions and statements, as well as expanded the support for a couple of existing ones. Learn more about these and other SQL Complete updates at the Devart official blog – https://blog.devart.com/take-full-advantage-of-sql-server-2019-with-sql-complete-v6-5.html.

**About Devart**

Devart is one of the leading developers of database tools and administration software, ALM solutions, data providers for various database servers, data integration and backup solutions. The company also implements Web and Mobile development projects.
For additional information about Devart, visit https://www.devart.com/.
What is the CORS?
Tags: security, cors, attack, owasp
Published: 2020-06-11 13:35:04

Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources on a web page to be requested from another domain outside the domain from which the first resource was served.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/6kmk14wggek1blwfinsa.png)
## WHY IS CORS NECESSARY?

The CORS standard is needed because it allows servers to specify not just who can access its assets, but also how the assets can be accessed.

Cross-origin requests are made using the standard HTTP request methods. Most servers will allow GET requests, meaning they will allow resources from external origins (say, a web page) to read their assets. HTTP requests methods like PATCH, PUT, or DELETE, however, may be denied to prevent malicious behavior. For many servers, this is intentional. For example, it is likely that server A does not want servers B, C, or D to edit or delete its assets.

With CORS, a server can specify who can access its assets and which HTTP request methods are allowed from external resources.
CSRF attack
Tags: security, csrf, attack, owasp
Published: 2020-06-11 13:10:49

## What is CSRF
CSRF attacks are also known by a number of other names, including XSRF, “Sea Surf”, Session Riding, Cross-Site Reference Forgery, and Hostile Linking. Microsoft refers to this type of attack as a One-Click attack in their threat modeling process and many places in their online documentation.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/yps6hcc8m05e30tq24oo.jpg)
## How to Prevent Cross-Site Request Forgery Attacks
Just add somethings that attacker doesn't know
An attacker can launch a CSRF attack when he knows which parameters and value combination are being used in a form. Therefore, by adding an additional parameter with a value that is unknown to the attacker and can be validated by the server, you can prevent CSRF attacks. Below is a list of some of the methods you can use to block cross-site request forgery attacks.
Daily Challenge #257 - Halving Sum
Tags: challenge
Published: 2020-06-11 13:08:32

---
title: Daily Challenge #257 - Halving Sum
published: true
series: Daily Challenge
description: Iterate on n/2 and then add all these numbers together. 
tags: challenge
//cover_image: https://direct_url_to_image.jpg
--- 

Given a positive integer n, calculate the following sum:
`n + n/2 + n/4 + n/8 + ...`

All elements of the sum are the results of integer division. Continue dividing the number until you reach a decimal (no decimals allowed in final answer).

*Example*
25  =>  25 + 12 + 6 + 3 + 1 = 47

*Tests*
halvingSum(25)
halvingSum(127)

***
_This [challenge](https://www.codewars.com/kata/5a58d46cfd56cb4e8600009d) comes from Belia on CodeWars. Thank you to [CodeWars](<https://codewars.com/>), who has licensed redistribution of this challenge under the [2-Clause BSD License](<https://opensource.org/licenses/BSD-2-Clause>)!_

_Want to propose a challenge idea for a future post?  Email **yo+challenge@dev.to** with your suggestions!_
Containerize a .NET Core Web API Project
Tags: docker, container, webapi
Published: 2020-06-11 13:01:45

Hey, As the world is moving towards lighter things so the software's.

In this article you are going to learn, how we can create an image of an basic .net core web API application and run that in a container.

**Prerequisites**
1. Docker installed
2. .net core SDK 

**Verify that environment is ready by executing below commands in cmd.**

```
dotnet --version 
  3.1.101

docker --version
  Docker version 19.03.8, build afacb8b

```
Before creating the image of an application. Let us create .net core web API application using below command.

  ` dotnet new webapi -n TestWebAPI `


 Once the application is created, navigate to folder under which application is created

   ` cd TestWebAPI `


 Before adding the .NET Core app to the Docker image, first it must 
   be published.

   ` dotnet publish -c Release `

 We are ready with Application which needs to be created as a image.

 Create a file named Dockerfile in directory containing the .csproj 
   and open it in a text editor copy below code into that file.
   Dockerfile will be used by docker build command to create image


```

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1

 COPY bin/Release/netcoreapp3.1/publish/ TestWebAPI/
 WORKDIR /TestWebAPI
 ENTRYPOINT ["dotnet", "TestWebAPI.dll"]

```

 Create image of an application.Below command will use the commands 
 in Dockerfile to create image of an application.

   ` docker build -t testimage -f Dockerfile . `


 To get the list of images.

   ` docker images `


 Container is a instance of an image. Create container to run 
   created image in it.

   ` docker create --name testcontainer testimage `


 To get the list of container.

   ` docker ps -a `

 The status of the container will be ` created ` and not ` Up ` 
   until we start the container using below command.

 Start container

   ` docker start testcontainer `

After starting the container we have to run the container in one of the port.
	
   ` docker run -p 8080:80 testimage `

	
 Open in the browser

` http://localhost:8080/weatherforecast `
Installing chromedriver and Selenium Server on Linux Mint 19.3 (Tricia)
Tags: tdd, testing, linux, selenium
Published: 2020-06-11 12:54:55

Hi there! 

Just have to setup a chromedriver with Selenium on my Linux machine to run some tests. So I've decided to write about that...

## Download and install the chromedriver

First step is to check the Chrome browser version installed on your machine. Click the kebab menu icon at top right. Go to Help -> About Google Chrome. It shows I'm using `Version 81.0.4044.138 (Official Build) (64-bit)` so I have to download  [ChromeDriver 81.0.4044.138](https://chromedriver.storage.googleapis.com/index.html?path=81.0.4044.138/).

Go to [Chromedriver Downloads](https://chromedriver.chromium.org/downloads) page. Click the download link for appropriate version (both chromedriver and Chrome browser should have same version installed), click the `chromedriver_linux64.zip` archive to download it.

After the download is completed - extract and move the chromedriver to /usr/bin directory and make it executable.

```bash
sudo unzip chromedriver_linux64.zip -d /usr/bin
# make sure it is executable
sudo chmod +x /usr/bin/chromedriver
```

Now I can enter `chromedriver` command and have it running in my terminal.

## Download and install Selenium Server standalone

Go to [Selenium Downloads](https://www.selenium.dev/downloads/) page and download Selenium Server latest stable version. In my case it's 3.141.59.

The file I've got is a `.jar` file - `selenium-server-standalone-3.141.59.jar`. I just need to execute that file to have the server up and running.

```bash
java -jar selenium-server-standalone-3.141.59.jar
```

Now I'm able to run my acceptance tests with WebDriver enabled. Though, I'm running them using [Codeception](https://codeception.com/) framework.

## Bonus

In case if you're getting an error "Address already in use", find and kill the process launched by "java -jar selenium-server-standalone-3.141.59.jar" command.

```bash
ps aux | grep java
kill -9 <PID>
```
Enable network throttling on iPhone in 5 steps
Tags: ios, safari, debugging, network
Published: 2020-06-11 12:41:22

---
title: Enable network throttling on iPhone in 5 steps
published: true
description: This article explains how to enable network throttling to simulate various bad connections when loading a website in Safari on iOS
tags: ios,safari,debugging,network
---

It's useful to be able to test your fancy new single page application or progressive web app in different network conditions. On desktop you can do so by [using network throttling](https://developers.google.com/web/tools/chrome-devtools/network#throttle) on Chrome dev tools for example.

But on Safari on your iPhone, things are messier. The top result on Google for "ios safari network throttling" gives a Stack Overflow answer that goes like this:

![Stack Overflow answer](https://dev-to-uploads.s3.amazonaws.com/i/79v9oh2i9fiui2jq3v81.png)

😤 Installing a proxy!

Well turns out there's another way. 😌

**1. Install XCode on your mac**

Open the Mac App Store on your mac, search for Xcode and install it.

![Xcode on the Mac App Store](https://dev-to-uploads.s3.amazonaws.com/i/6er1bow2miobrwzrjfy0.png)

**2. Connect your iPhone**

Connect your iPhone to your mac via a USB cable, say yes and confirm any request from your mac or iPhone.

**3. Launch XCode**

Just launch it.

**4. Access developer settings on iPhone**

Now that XCode was launched, you should be able to access a new "developer" settings on your iPhone.

![Developer settings on iPhone](https://dev-to-uploads.s3.amazonaws.com/i/s5ltg30kdx6f5kb7jy2r.jpeg)

I am not even sure you still need XCode running now, you can try to close it.

**5. Use the Network Link Conditioner**

Inside developer settings, there's a Network Link Conditioner submenu that you can use to throttle your connection on iPhone.

Here's a full demo: 
![Throttling fast.com](https://dev-to-uploads.s3.amazonaws.com/i/fi2x765qvghs1agk6gzw.gif)

Enjoy!
DESTRUCTURING ARRAYS IN JS
Tags: javascript, webdev, 100daysofcode, beginners
Published: 2020-06-11 12:34:09


Hi I am Ndonna Ugwuede a javaScript newbie, and as a noob in javaScript i found it hard understanding Destructuring, even after reading many materials and watching tutorial videos it was still sounding strange but thanks to Mark Zamoyta i finally got a grasp of it. 

Firstly, what do you need destructuring for?

Destructuring gives us an avenue to name our Array/Object items as against the regular calling of array items with "arrayName[0]" or Objects with "object.key". 

DESTRUCTURING ARRAYS 

You can destructure an array using the syntax let [name1, name2, name3] = names; where names is an already existing array. Using an example we have an array named Cars with content ["Benz", "Honda", "Nissan", "Toyota", "Ford"] and we want to assign them to variables namely car1, car2, car3, car4, car5. Going the old school way we would to go through assigning each with: 
let car1 = Cars[0], car2 = Cars[1], .... etc
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/6fky39s2m5tma97nck92.png)

Destructuring has brought a simpler way to do this where you can name array items where we can name our array items using: 
let [car1, car2, car3, car4, car5] = Cars;
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/4b3k2hel9ie1ab7ukyb7.png)

You could even assign the remaining items into another named array using a rest operator (...), if we aren't sure of the number of items to be named. 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/9klvcm1x776pxgiosd31.png)

Another beauty is we could skip some items, if we are sure of what to skip, some strategic items we are sure of we could be removed by putting a comma in its place e.g we could remove our first and second item of the array using: 
let [,,car3, car4, car5] = Cars;
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/6rwyv6e3osspgalq51t6.png)

Destructuring also works fine with/on Objects, I'll be making another post explaining DESTRUCTURING OBJECTS IN JS, in the near future but in the meantime you could reach out to me on twitter: https://twitter.com/Ndonnauc
Day 0: Hello World.
Tags: beginners, python
Published: 2020-06-11 12:23:10

This is always the foundation code every beginner learning programming, the ‘Hello World’ code. Mine is in python and it was quite straightforward as [HackerRank](https://marketing.hackerrank.com/) have some tutorials on how to go about it(They have the tutorials in Java but for python I have used [Python Tutorial](https://docs.python.org/3/tutorial/) and also [W3Schools](https://www.w3schools.com/python/) .

This however had a small twist whereby you are required to read input from the user then print this below the ‘Hello World’ statement:

Code Snippet: 
```python
# Read a full line of input from stdin and save it to our dynamically typed variable, input_string.
input_string = input()

# Print a string literal saying "Hello, World." to stdout.
print('Hello, World.')
print(input_string)
```
The Best Tech Websites to Follow in 2020
Tags: webdev, showdev
Published: 2020-06-11 12:20:27

Every day a number of new and awesome technological products are launched in the market. With tech evolving at a rapid pace, it’s difficult to keep up with the changes.

To give you an idea, everyday apps like Instagram, Lyft, Slack, Ring, Alexa, Tinder, Google Drive- all didn’t exist 10 years ago! Yet, now they seem like such an integral part of our lives.

If you work in the technology field or are just tech geeks like us, keeping up with technology news becomes a top priority!

To help you stay ahead of the world, we have compiled a list of some of the [best tech websites](https://blog.bit.ai/best-tech-websites/) to follow in 2020. So without further ado, let’s get started!

##The Best Tech Websites You Must Follow!
###[TechCrunch](https://techcrunch.com/)
**What it’s about**: Kicking off our list is TechCrunch, one of our favorite tech websi

###[TheVerge](https://www.theverge.com/)
**What it’s about**: Another one of our favorites, especially if you are more into gadgets and other ‘cool stuff’, TheVerge is a great resource for that. Their YouTube channel is probably the best one out there for Tech news and gadget reviews.

###[VentureBeat](https://venturebeat.com/)
**What it’s about**: Focused on covering all the latest and greatest in tech, VentureBeat is purely a tech news website with no fluff whatsoever.

###[Wired](https://www.wired.com/)
**What it’s about**: We are pretty sure you have heard about Wired. If you haven’t, you need to check out this cool tech website right away.

###[Digital Trends](https://www.digitaltrends.com/)
**What it’s about**: Digital Trends is a website full of great information. From the latest new product and gadget coverage to detailed product analysis, Digital Trends is a great website to stay on top of well, digital trends!

###[Mashable](https://mashable.com/)
**What it’s about**: Apart from covering the latest tech happenings and product launches from around the globe, Mashable is a full-fledged infotainment website covering topics like entertainment, politics, culture, science, business, and more.

##Final Words
There you have it, folks- some of the best tech websites to follow in 2020. If you want to be informed about everything happening in the world of tech and gadgets, the above-mentioned sites are more than enough to put you on the right track. Happy Reading!
IT Disaster Recovery Management
Tags: itdisasterrecovery, itdisasterrecoverymanagement, disasterrecovery
Published: 2020-06-11 12:05:26

Businesses today thrive over a robust IT framework to the point that most organizations take it for granted. Daily operations are carried out through VoIP, telephones, EDI and other avenues. However, there can be serious implications if the functioning of such a critical component gets interrupted. Business efficiency gets hampered if there isn't easy access to data which makes <a href="https://www.stayinbusiness.com/resource/it-disaster-recovery-management/" title="IT Disaster Recovery"><strong>IT disaster recovery (IT DR)</strong></a> all the more important.

<h2>IT Disaster Recovery Management</h2> 

An <a href="https://www.stayinbusiness.com/disaster-recovery-plan/" title="Disaster Recovery Plan"><strong>IT disaster recovery plan</strong></a> is activated to restore activity when business operations get stalled due to a disaster. Its effectiveness hinges on the amount of detail that has gone into its planning and the extent to which it has been tested.

Enterprise teams work with information that is constantly exposed to threats such as malware, hacking, network intrusions and other hazards. In such a scenario, the importance of <strong>IT disaster recovery</strong> can't be emphasized enough where a large portion of data that enterprises deal with is critical to business.
An easy way to get the (real) client IP in PHP
Tags: php, ip, coding
Published: 2020-06-11 12:03:52

Here we go with another post! 🤘

In the other day I noticed all IPs recorded from visitor on one of my apps were the same, with a very little variation each-other! Aha~ found a bug! 

Well, not much! 🙄 After a quick Google search I figured out that those IPs were all from CloudFlare (the CDN provider my apps are behind)! So, CloudFlare replaces the commonly used `$_SERVER['REMOTE_ADDR']` variable with their own IP.

Fair enough! 

So, if you're reading this, the chances are you are facing a similar problem and are looking for a solution ... or perhaps you're just curious, which is fine too. 🤪

Here's a very simple way to get the (real) client IP address. Note that the sintax used here is `PHP7+`, which means for earlier versions you're gonna need to apply some chained `if`s and `else`s.

```php
<?php

# PHP7+
$clientIP = $_SERVER['HTTP_CLIENT_IP'] 
    ?? $_SERVER["HTTP_CF_CONNECTING_IP"] # when behind cloudflare
    ?? $_SERVER['HTTP_X_FORWARDED'] 
    ?? $_SERVER['HTTP_X_FORWARDED_FOR'] 
    ?? $_SERVER['HTTP_FORWARDED'] 
    ?? $_SERVER['HTTP_FORWARDED_FOR'] 
    ?? $_SERVER['REMOTE_ADDR'] 
    ?? '0.0.0.0';

# Earlier than PHP7
$clientIP = '0.0.0.0';

if (isset($_SERVER['HTTP_CLIENT_IP'])) {
    $clientIP = $_SERVER['HTTP_CLIENT_IP'];
} elseif (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
    # when behind cloudflare
    $clientIP = $_SERVER['HTTP_CF_CONNECTING_IP']; 
} elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
    $clientIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
} elseif (isset($_SERVER['HTTP_X_FORWARDED'])) {
    $clientIP = $_SERVER['HTTP_X_FORWARDED'];
} elseif (isset($_SERVER['HTTP_FORWARDED_FOR'])) {
    $clientIP = $_SERVER['HTTP_FORWARDED_FOR'];
} elseif (isset($_SERVER['HTTP_FORWARDED'])) {
    $clientIP = $_SERVER['HTTP_FORWARDED'];
} elseif (isset($_SERVER['REMOTE_ADDR'])) {
    $clientIP = $_SERVER['REMOTE_ADDR'];
}

echo "My client IP: ", $clientIP;

```

Happy coding! 👋
Deno Extension
Tags: deno, vscode, extension
Published: 2020-06-11 12:03:37

## Deno
---
* Ryan Dahl (Nodejs Developer) recently released deno, an alternative for nodejs with typescript support and created by rust programming language and v8 chrome javascript engine.

* I tried to create deno applications like REST Api and third party modules for deno. While development, I'm in need of some extension so that errors and bug can be easily fixed.

* After my serious research 😜 on finding the best deno extension for vscode editor, I found deno extension by denoland.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/gv5dhh2onv1myod5wrci.png)

### Why this extension?
---

* I have uploaded a video on youtube for why this extension rather than other extensions for deno in vscode.

{% youtube dV4oH8oUN1E %}

* Finally, If you like my videos on my youtube channel **Vuelancer** , do subscribe.

## Thank You!