teleren/devto huggingface dataset:
Why Perl does not have good IDE's?
Tags: perl
Published: 2019-12-07 18:36:15

In today's world, Integrated Development Environment (IDE) is an integral part of programming. It empowers the developer to build the software application effectively and quickly. The essentials features of IDE are Syntax highlighting, Refactoring, debugging, Auto Code Completion, Terminal, version control and data structure browsing, which helps a developer quickly execute actions and maximize the productivity by providing the User Interface.

Most of the IDE in the today's world supports multiple languages and Perl is one of them.

Perl's and most popular IDE's are :

* Komodo Edit
* Atom
* Padre (Not in active development)
* VS Code
* Pycharm

All IDE's mentioned above are good in Syntax highlighting, having their Terminal and also provides the version control. But the auto code completion is missing from all the editors. And the reason is the TIMTOWTDI. Yes, you read it right. The boon for Perl is actually the bane for Perl, and hence here is no perfect IDE for Perl and I think this is the reason that new Programmers are not attracted towards Perl.

For example in Python3 to add two numbers using function is

```python
def add_number(var1, var2):
    return var1 + var2


print(add_number(2, 3))
```

Whereas to do the same in Perl:

## Method 1

```perl
use warnings;
use strict;

my $res = add_number(2, 3);

print "Result is : ", $res, " ";

sub add_number {
    my($num1, $num2) = @_ ;

    return $num1 + $num2;
}
```

## Method 2

```perl
use warnings;
use strict;

my $res = add_number(2, 3);
 
print "Result is : ", $res, " ";
 
sub add_number {
    my $num1 = shift;
    my $num2 = shift;
 
    return $num1 + $num2;
}
```

## Method 3

```perl
use warnings;
use strict;

my $res = add_number(2, 3);
 
print "Result is : ", $res, " ";
 
sub add_number {
   return $_[0] + $_[1] ;
}
```

## Method 4

```perl
use warnings;
use strict;

my $res = add_number(2, 3);
 
print "Result is : ", $res, "";

sub add_number {
   # my ($num1, $num2) = (@_);
 
   return shift(@_) + shift (@_);
}
```

## METHOD 5

Last but not the least

```perl
use warnings;
use strict;

my %dis = (  plus => sub { $_ [0] + $_[1] } );
my $res = $dis { plus } -> (2, 3);
 
print "Result is : ", $res, "\n";
```

Which one of the above is correct?

All of the above methods can be used to add two numbers in Perl. I am pretty sure that there are other methods to achieve the same result.

Anyways, imagine just to add two numbers, Perl has at least 5 ways to do it, and if we want to add all the shortcuts or code completion for Perl in an IDE it is practically impossible and if somehow it is possible then that particular IDE will be memory extensive which is kill to the system.

In short, I don't think in future it is possible to have the IDE in Perl. You might have editors (I like atom personally) but not the full-fledged IDE.

As a Perl lover, I wish I am wrong.
Connect useEffect and useState to Update Components with Data
Tags: react
Published: 2019-12-07 18:22:19

We have one way to update (or re-render) a component.
It's `React.useState`.

When we want to render our component with data we've `useEffect`ed from the internet, we need to need a `useState` updater function to call.

This is a common pairing of functions where server data is used to update a component:

```js
let [componentData, setComponentData] = React.useState(null);

React.useEffect(() => {
  fetchData().then(serverData => setComponentData(serverData));
})
```

In our Pokemon app, that looks like this:

```jsx
let [index, setIndex] = React.useState(1);
let [pokemon, setPokemon] = React.useState(null);

React.useEffect(() => {
  fetchPokemon(index).then(json => setPokemon(json));
});
```

Our `useEffect` connects us to the outside world — fetching data with JavaScript.
The callback we give to `fetchPokemon` calls our `useState` updater function when data is ready — updating our component.

## Give it a try!

Assignment Sandbox:
{% codesandbox 10wf6 %}

Assignment:
1. Update the `let pokemon` assignment to get it's value from `React.useState(null)`
1. Using destructuring assignment, take the second element of `React.useState`'s return (our updater function) and `setPokemon`
1. Replace `console.log(json)` with a call to `setPokemon(json)`



---

Follow the 🧵 on Twitter:
{% twitter 1203313209257496579 %}

Subscribe on YouTube:
{% youtube HvM9Ob4CHa0 %}
Charming the Python: Sets
Tags: beginners, python
Published: 2019-12-07 18:16:30

*If coding tutorials with math examples are the bane of your existence, keep reading. This series uses relatable examples like dogs and cats.*

---
## Sets


### Making a set
Python uses curly brackets for sets. Sets are unordered and have no index
```python
dog_parts = {'paws', 'legs', 'tail', 'fur'}
```
### Changing a Set

We cannot change items in a set, but we can add, update, and remove them.
```python
dog_parts = {'paws', 'eyes', 'tail', 'fur'}

dog_parts.add('whiskers')
print(dog_parts)
>>> paws, etes, tail, fur, whiskers

dog_parts.update('whiskers', 'nose', 'tongue')
print(dog_parts)
>>> paws, eyes, tail, fur, whiskers, nose, tongue
```


### Comparting Sets

Intersection shows the items shared between sets
```python
dog_parts = {'paws', 'eyes', 'tail', 'fur'}
fish_parts = {'fins', 'gills', 'eyes', 'scales'}
print(dog_parts.intersection(fish_parts))
>>> eyes
```

similarly, we can find which items are not shared
```python
dog_parts = {'paws', 'eyes', 'tail', 'fur'}
fish_parts = {'fins', 'gills', 'eyes', 'scales'}
print(dog_parts.difference(fish_parts))
>>> paws, tail, fur, find, gills, scales
```


---
Series based on {% post https://dev.to/asabeneh/30daysofpyton-challenge-43ii %}
How authorize web application and manage sessions 
Published: 2019-12-07 18:08:01

i am building a single page react app that uses redux as state manager and an express node js as backend server but i don't know what is the best way to authorize my users in the application!

if it was php or express-js website i could use PHPSESSION or express-session to manage users sessions data but now the single page web application is separated from the backend and i can't manage sessions like before!

my idea is to make a session id for each new web request then save it for client in local storage then in the server store all needed informations in a database and when application have an api call send that id in request header then we can check authorizations by using that implemented session

but i thought if there was a simpler way to handle this problem that have no need to make a session implementation by myself

(i don't want to use third party services like firebase or okta or save all session data in client part like JWT)
Execute command line commands from inside vim
Tags: vim, productivity, commandline, neovim
Published: 2019-12-07 18:07:22

---
title: Execute command line commands from inside vim
published: true
description: "Power! Unlimited Power!!"
tags: vim, productivity, commandline, neovim
canonical_url: https://irian.to/blogs/execute-command-line-commands-from-inside-vim
---

*Follow [@learnvim](https://twitter.com/learnvim) for more Vim tips and tricks!*

One vim command I have been experimenting with recently is bang (`!`) command to execute external commands from within vim (`:h :!`).

Why is this so awesome? Let me show you some examples so you can do even more awesome things!

# Curl from inside vim

Yes, you read that right. If you have [curl](https://curl.haxx.se/) installed, you can curl *from inside* vim.

```
:r !curl -s 'https://jsonplaceholder.typicode.com/todos/1'
```

The `r` is `r[ead]`. It is used to display the result. This command is so useful I mapped it as a shortcut (`<Leader>cg`): `nnoremap <Leader>cg :r !curl -s<Space>`

Of course, this works with curl POST/PUT/DELETE. 

# Paste file content 

I find this is useful when dealing with fake data and json files. You can do this with `:r !cat path/to/your.file`


# Get list of files

Let's say you need to quickly get a list of all javascript files in a project, you can do something like: `:r !ls **.*.js`


# Get word count

If you want to check how many words in your current file, you can do `:!wc %`. You can also do the same with `g C-g`

# Send command to other tmux session/window/pane

This is my personal favorite right after curl. This one is for [tmux](https://github.com/tmux/tmux) users. If you are working with multiple panes, you can send command to another pane.

```
:!tmux send-keys -t mySession:myWindow.2 "echo 'HELLO TMUX MAGIC'" Enter
```

Let me break it down:
- `tmux send-keys` sends tmux instructions
- `-t` to target
- `mySession:myWindow.2` is tmux's convention to target a specific pane. The syntax is: `session_name:window_name.window_number`.
- `"echo 'HELLO TMUX MAGIC'" Enter` is the instruction

With this, I can send any instruction to any session, any window, any pane. I can tell my "Rails" session to execute `rspec` on "Test" window's pane #2 while I am sitting inside a different session. How cool is that? 

# Repeat the previous bang command

After running fairly lengthy command, you can quickly recall previous command with double bang: `:!!`

# Conclusion

I have only scratched the surface of `!` potential; being able to execute external command unlocks many possibilities. 

What command do you personally find it helpful to execute from inside vim?
Day 4 - Window === Global ? - Learning Node JS In 30 Days [Mini series]
Tags: node, javascript, codenewbie
Published: 2019-12-07 18:00:07

__Window === Global__

If you know JavaScript already then you know there is a __window object__ in console

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/pb7h8e1fwk478zq5tln7.png)

If you new to JavaScript then just open your `console` in browser and write `window` there and you can see the what inside this `window object`

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/shijy9clw6454bchyza7.png)

When we are on the Browser we can access to the `window`, but there is no `window `in the computer. So how we can use that ?
Even after installing the `npm`, it doesn’t give us to access those `window` object so how should we do it ?

Well good thing is we can access the `window` here to, it just changed it’s name. It called `global` now.

You can go to latest doc of node js by https://nodejs.org/dist/latest-v12.x/docs/api/

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/s7nenx1ctiwpyfthpgq1.png)

Good thing is you can access the `global object` which is same as `window` https://nodejs.org/dist/latest-v12.x/docs/api/globals.html

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/321s3i4xioqi4epyi3wo.png)

Now you can use all the functions like – setInterval, setTimeout etc on app.js

__See an example –__

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/tt70nlp34izn9752sbmx.png)


Run the code by `node app.js`

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/5t4qasukr12fe0159dbx.png)

Did you understand today’s lesson ?
You can comment anytime if you’ve any question!

Originally it published on [nerdjfpbblog](https://blog.nerdjfpb.com/day4-nodejsin30days/) and graphical version on [instagram](https://www.instagram.com/p/B5x2reygx3b/). you can connect with me in [twitter](https://twitter.com/nerdjfpb) or [linkedin](https://www.linkedin.com/in/nerdjfpb/) !
Charming the Python: Tuples
Tags: python, beginners
Published: 2019-12-07 17:42:36

*If coding tutorials with math examples are the bane of your existence, keep reading. This series uses relatable examples like dogs and cats.*

---
## Tuples

A tuple can be a collection of multiple data types. Tuples are ordered and immutable. Immutable means unchangeable or unmodifiable.

### Creating
```python
# empty tuple to show syntax
empty_tuple = ()

# A not empty tuple
dogs = ('chihuahua', 'golden retriever', 'german shepherd', 'mutt')
```

### Accessing Items
You can access items in a tuple similar to accessing characters in a string.

| chihuahua | golden retriever | german shepherd | mutt |
|--|--|--|--|
| 0 | 1 | 2 | 3 |
| -4 | -3 | -2 | -1 |

```python
dogs = ('chihuahua', 'golden retriever', 'german shepherd', 'mutt')

print(dogs[1])
>>> golden retreiver

print(dogs[-2])
>>> german shepherd
```

### Slicing
```python
dogs = ('chihuahua', 'golden retriever', 'german shepherd', 'mutt')

print(dogs[1:2])  # will print index 1 to 2
>>> golden retriever, german shepherd

print(dogs[-3:-1])  # will print index -3 up to but not including -1
>>> golden retriever, german shepherd
```

### Casting to a List
Tuples are immutable/not-changeable, while lists are mutable/changeable. 
In order to update the contents of a tuple, you may change a tuple into a list. This is call casting into a list.
```python
dogs = ('chihuahua', 'golden retriever', 'german shepherd', 'mutt')

dogs_list = list(dogs)
```
After making adjustments to your new lest, don't forget to change it back to a tuple.
```python
dogs_list = ['chihuahua', 'golden retriever', 'german shepherd', 'mutt']

dogs = tuple(dogs_list)
```
### Joining
```python
dogs = ('chihuahua', 'golden retriever', 'german shepherd', 'mutt')

cats = ('domestic shorthair', 'persian', 'siamese')

pets = dogs + cats
print(pets)
>>> chihuahua, golden retriever, german shepherd, mutt, domestic shorthair, Persian, siamese
```

### Deleting
Because tuples are immutable, you cannot delete single items in a tuple. However, you can delete a whole tuple
```python
dogs = ('chihuahua', 'golden retriever', 'german shepherd', 'mutt')

del dogs
print(dogs)  # this will error because 'dogs' no longer exists
```

---
Series based on {% post https://dev.to/asabeneh/30daysofpyton-challenge-43ii %}
3.4 More about variables
Tags: python, beginners, webdev
Published: 2019-12-07 17:33:56

{% link https://dev.to/mohit355/3-3-type-casting-in-python-2iol %}

## Declaring more than one variable in single line:
=>> yes we can declaring more than one variable in a single line and assign it different value.

 for example
```python
x,y=1,2
print(x)
print(y)
```
output is
```python
1
2
```

==>> we can assign any variable with and data type of values in single line
For example
```python
a,b,c=1,'mohit','123as'
print(a,type(a))
print(b,type(b))
print(c,type(c))
```
output is
```python
1 <class int>
mohit <class str>
123as <class str>
```

=>> We can also assign a single value to more than one variable in single line.
 For example
```python
x=y=z=12
print(x)
print(y)
print(z)
print(x,y,z)
print(x+y+z)
```
Output is
```python
12
12
12
12 12 12
36
```
Thank you and if you have any problem regarding this please let me know in the comment box
Speed up your integration tests in one line
Tags: testing, docker
Published: 2019-12-07 16:04:43

If you are using Docker to run your integration tests, and they use a real database (MySQL, PostgreSQL, MongoDB, etc), you are in luck. By simply mounting the directory of the database files on [`tmpfs`](https://en.wikipedia.org/wiki/Tmpfs) in the containers, you will be able to reduce the execution time by a substantial amount[1]. In my case, I reduced the tests from 17 minutes execution time, to just 4 minutes.

This `tmpfs` flag is supported also in [docker-compose](https://docs.docker.com/compose/compose-file/#tmpfs).

Example `docker-compose` file for MySQL, PostgreSQL and MongoDB:

```
version: '3'
services:
  mongo_db:
    image: mongo:3.4.6
    ports:
      - "27017"
    tmpfs:
      - /var/lib/mongodb

  mysql_db:
    image: mysql:5.6.34
    ports:
      - "3306"
    tmpfs:
      - /var/lib/mysql

  postgres_db:
    image: postgres:11
    ports:
      - "5432"
    tmpfs:
      - /var/lib/postgresql/data

```

To launch a container with a `tmpfs` from the CLI, use the `--tmpfs` flat, just like it's described in the [docs](https://docs.docker.com/storage/tmpfs/):

`$ docker run -d -it --name tmptest --tmpfs /app nginx:latest`


[1]: This will vary depending on the usage of the database during the test runs. If you don't utilize the database a lot, you might not even notice any improvements.
3.3 Type casting in Python
Tags: python, beginners, webdev
Published: 2019-12-07 17:06:16

{% link https://dev.to/mohit355/3-2-how-to-take-user-input-in-python-30gf %}
## Type casting:
1. In computer science, type conversion, type casting, type coercion, and type juggling are different ways of changing an expression from one data type to another.
2. In Python [input() function](https://dev.to/mohit355/3-2-how-to-take-user-input-in-python-30gf)  the input taken by the user is a string.
3. If we want to take a integer as an input then we have to convert the input into the integer. for this we can use **int() function** in python.

##int function:
1. The int() function converts the specified value into an integer number.
for example,
   i have to string variable and we want to add together then it will generally concatenate both the value .![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/1nt29ccx1obcii79cfia.png)

2. Now if we want to add them because 12 and 13 is simple an integer value and after adding it 12+13=25.  here we can use int() function to convert '12'(string 12) into 12(integer 12).
3. **Syntax : int(x)**
```python
x='12'
print(type(x))

Output- <class str>
```
For converting into an int value
```python
int_value=int(x)
print(type(int_value))

output - <class int>
```![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/47ez17yz4hffsmk79exq.png)

Similarly you can convert y into an integer value.
Now add both and [print](https://dev.to/mohit355/python-basics-3cjd)![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/wjh1555znzja7v76s1zm.png)

3. This is generally known as type cast (converting an expression of one data type into other)

## float() function:
1. The float() method is used to return a floating point number from a number or a string.
2. As we convert a variable into int similarly we can type cast a variable into float.
3. **Syntax: float(x)**
4. floating numbers are like 12.23 ,34.00,123.9 etc  means all number which contain decimal
For example 
```python
x=12
print(type(x)
y=float(x)
print(type(y)
print(x," is " ,type(x)," value")
print(y," is ",type(y)," value")
```
Output
```python
<class int>
<class float>
12 is <class int> value
12.0 is <class float> value
```
There are too many inbuilt function for type casting in python like **str(),list(),dict(),tuple(),set() etc** i will discussed this all in upcoming tutorials.

If you have any problem then put it in the comment box.

Thank you
Choices for a console in Windows
Tags: console, cmd
Published: 2019-12-07 15:53:28

I've spent a little bit of time lately looking into different consoles to use in Windows 10. The built-in `cmd` console is what I've used the most in the past.

#### Consoles tried are:
  Windows System Command Prompt (`cmd.exe`) for simple batch operations
  Windows PowerShell ISE (`PowerShell_ISE.exe`) for PowerShell scripting
  Git for Windows (`git.exe`) for a bash shell (although I've been into using the TortoiseGit client more.)

#### Some of the newer choices I found were:
- [Windows Terminal](https://www.microsoft.com/en-us/p/windows-terminal-preview/9n0dx20hk701) - A Windows App from Microsoft in preview release that does Command Prompt and PowerShell
- [Comemu](https://conemu.github.io/) - A console emulator with a customizable GUI
- [Clink](https://mridgers.github.io/clink/) - Runs in the `cmd` console with some bash-like enhancements
- [Cmder](https://cmder.net/) - An all-in-one console that uses `Comemu` & `Clink` and does cmd, PowerShell and bash with extensive [lua](https://www.lua.org/) scripting

Now, I'm trying to decide which one is best for me. `Cmder` looks like a good choice, but I'll have to put learning `lua` on my to-do list.

Before I do that, I'm curious if there are others out there to try.
#### Requirements:
- Must be free
- Runs under latest version of Windows 10
  
Let me know what some of your favorites are and I'll post my opinion on what I like and what I decided on.
Sorry for delay in the tutorial
Published: 2019-12-07 15:51:49


Hey guys,
    Sorry for teh delay in posting  **Python for Beginners** tutorials.
    Last tutorial that i post : {% link https://dev.to/mohit355/3-2-how-to-take-user-input-in-python-30gf %} on the "Python for Beginners series".
    This is because of my semester exam on head that time. Now i am free from that and ready to post next tutorials.
    Next part is coming as soon as possible and it will continue regularly one or 2 post a day.

Thanks for the patience.
Robolectric, doesn't really require Java 9
Tags: robolectric, testing, androidtest, android
Published: 2019-12-07 15:42:00

---
title: Robolectric, doesn't really require Java 9
published: true
description: How to deal with Robolectric requiring java 9 for latest SDKs
tags: robolectric, testing, androidTest, android
---

Sometimes you'd need Robolectric to test things, like JodaTime, if you didn't want to go to the effort of either DI replacing it or running on a real device everytime.

When you do so, if you just use whatever the default your manifest runs on, you could face issues with it saying:
```
[Robolectric] WARN: Android SDK 29 requires Java 9 (have Java 8). Tests won't be run on SDK 29 unless explicitly requested.

java.lang.UnsupportedOperationException: Failed to create a Robolectric sandbox: Android SDK 29 requires Java 9 (have Java 8)
```

Usually when your target SDK is set to the latest, which is what Robolectric will use by default.

## The Fix

Instead of:
```
@RunWith(RobolectricTestRunner::class)
class EmotionJourneyToViewUseCaseTest {....}
```

Add:
```
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [Config.OLDEST_SDK])
class EmotionJourneyToViewUseCaseTest {....}
```

Sure, now you're only testing against the minSdk in your project, and this might not be adequate for you depending on what you're testing. Particularly if the test requires something in a later version of the SDK!
Please consider your individual test situation.
However, if all you need is JodaTime working, this works great!

--- 

If you want to hire me to develop for Android at a senior/team lead level and sort out tricky situations in such a way that the entire team speeds up, reach out on anikadamg att gmail!
Store Loading animation
Tags: svg, css, webdev, ux
Published: 2019-12-07 14:49:49

##with SVG and CSS

We were building a site where the user was able to create their own store for selling products online. This task might take a while, so we decided to make a loading animation to explain what was happening at the moment. 

This was my proposal, SVG drawing + CSS animations = 22k weight:
(place your mouse over the tree and wait for the >.<)

{% codepen https://codepen.io/marianab/pen/XPOQaR %}
Windows 95 bootstrap theme
Tags: css, design, html
Published: 2019-12-07 14:21:11

Hello,

I want to introduce my Bootstrap 4 theme - Win95.CSS.

This theme stylized to look like windows 95/98. Here it is 1758 Windows 98 icons, cards like win98 apps, buttons and forms. 
You can create awesome websites using it!

[Demo here](https://alexbsoft.github.io/win95.css/)

![](https://i.imgur.com/8Ay4bbL.png)


{% github AlexBSoft/win95.css %}
Producing a dynamic histogram in JS for use in Qualtrics
Tags: qualtrics, histogram
Published: 2019-12-07 14:14:31

Hi everyone,

for a research project, I am looking to implement a dynamic histogram as attached in Qualtrics.

The goal is to have a histogram in which the participant can adjust the sliders to represent preferences/beliefs in which one should also be able to adjust the number of visible sliders. Here is an example of what this may look like: https://us.v-cdn.net/6030293/uploads/editor/mh/yaefqadtxw7u.jpg

This original histogram was programmed by another team of researchers in a different coding environment. And while I have a basic understanding of JS, I am nowhere near proficient to get to this point by myself.

I would greatly appreciate any support to obtain the needed result.
Thank you!