teleren/devto huggingface dataset:
I Made A NPM Card... It Was Fun
Tags: node, javascript, npm
Published: 2020-04-01 00:04:11


So I found out that you can make these cards and publish them to NPM and from there use NPX 
```shell
npx @jacobmgevans/card
``` 
to run them... I was like, uhhh cool? I think. Well, it was quite interesting and it got me comfortable publishing to NPM which was something I was always unsure about, not how to do it but more should I? I have concluded that much like putting code up to GitHub, just do it. Especially if you have code abstractions you use in things regularly. 

You can find the card here: https://www.npmjs.com/package/@jacobmgevans/card

code: 
https://github.com/JacobMGEvans/jacobmgevans-card
NPM
Tags: ubuntu, reminders, node, npm
Published: 2020-05-10 09:58:16

---
title: NPM
published: true
date: 2020-04-01 00:00:00 UTC
tags: ubuntu, reminders, node, npm
canonical_url: http://jamessessford.com/blog/npm
---

I was setting up a Rasperry Pi over the weekend and I'd forgotten how to set up NPM permissions so I don't have to use sudo to install global packages

```
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
```

That's a relief - sudo npm'ing anything is a terrifying prospect!
Binance Chain Dev Series: Part I - How to set up a Binance chain node
Tags: blockchain, binance, tutorial, linux
Published: 2020-03-31 23:39:29


> Binance Chain is a blockchain developed by Binance and its community, that focuses on building a performant matching engine and exchange over a decentralized network.

The Binance chain development series is split into 6 chapters and is meant give you a deep dive into building with Binance chain

| Binance Chain development series     |
| ----------- |
|  [chapter 1:- Setting up a light Binance node](https://dev.to/codaelux/how-to-set-up-a-binance-chain-node-4bb4) |
| [chapter 2:- Issuing a BEP2 token on Binance Chain](https://dev.to/codaelux/binance-chain-series-part-ii-issuing-bep2-token-51a)    |
| chapter 3:- Adding our BEP2 to Binance Dex and Interacting with it using the CLI   |
| chapter 4:-  *Adding token to trust wallet*  |
| chapter 5:- *Setting up a full Binance Chain node*    |
| chapter 6:- *Using the Binance Chain SDK*    |


## Let's get started

In this section, we are going to set up a VPS light client node on mainnet

I am assuming you have already set up your cloud VPS server if you haven't click [here](https://medium.com/@bsovevo/digitalocean-vs-amazon-ec2-vs-google-cloud-vs-linode-bb48e7148050), I'll jump right into it 

There are two types of Binance Chain client 

- Light client:- does not sync state or relay transactions
- Fullnode: - downloads full blockchain and relays transactions

for more details on these, click [here](https://docs.binance.org/light-client.html#light-client-versus-full-node)



*Let's kick off by downloading the node-binary*

```
    git clone https://github.com/binance-chain/node-binary.git
```
    
`Cd` into the `node-binary` folder you will see the following 

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

let's explore some of the options here 

- `CLI`:- this is where we interact with Binance Chain from our VPS, more on this in later Chapters
- `Docker`:- setup node using docker
- `Fullnode:`- Setting up a fullnode
- `Lightnode`:- Setting up a light node

```
    cd lightnode/prod/0.6.3/linux
```

> version 0.6.3 is latest at time of writing

Starting our node

    ./lightd --chain-id "Binance-Chain-Tigris" --node tcp://dataseed1.binance.org:80 > node.log & 

We have our light client running !!!

## What’s Next?
In the next chapter, we will look at issuing a BEP2 token. Stay tuned!
True or False: Math.pow(2, 53) == Math.pow(2, 53) + 1 ?
Tags: discuss, javascript, codenewbie
Published: 2020-03-31 23:20:56

Hello code newbies:

I have a fun JavaScript question for you.

Is the following expression `True` or `False`?

```javascript
Math.pow(2, 53) == Math.pow(2, 53) + 1
```

Before answering, please test your answer in your favorite JavaScript environment.

Explain!
What problems do front end developers face currently that do not have a well formed solution?
Tags: javascript, typescript
Published: 2020-03-31 22:11:23

So the modern applications are based on React/Vue and maybe even the latest version of Angular because these libraries make life easier for developers by solving some very common problems. 

I am trying to understand, are there any such issues that are still currently being faced that developers find a way around but feel that if there was a generic/general solution to this, life would be easier? 

I have only been working with JavaScript for about 2 years now and I am interested to know what kinda problem statements are out there.
What are best practices for finding, vetting, and working with freelance developers?
Tags: help, freelance
Published: 2020-03-31 22:09:36

I’m planning to start a project soon and want to find freelancers for design and engineering work. 

I’m hoping to learn from the wisdom of the crowd, and some of the topics that come to mind are:
* best places to look for freelancers/contractors (of course I’ll start here 😌😃 but where else?)
* how to screen applicants
* topics to talk about to ensure neither of us is having their time wasted. 

What has worked for you?

If you work freelance, what makes a good client? What do you wish more clients did?

Thanks!
Needing help with Importing / parsing tweets into Wordpress posts
Tags: wordpress, help, rss, twitter
Published: 2020-03-31 22:01:35

---
title: Needing help with Importing / parsing tweets into Wordpress posts
published: true
description: Looking for a better take on how to handle a Twitter feed into Wordpress posts automatically.
tags: wordpress, help, rss, twitter
---


## HELP! ##

I'm looking for a way to import Twitter posts from a user automatically into Wordpress posts, bearing in mind that the image contained in a Tweet becomes the featured image.

So far, I've managed to:

1- Turn the twitter feed into an RSS feed (through a service such as rss.app),
2- Import the feed into Wordpress through a syndication service (such as WP Syndication, have tried WP RSS aggregator also),
3- Alas, I cannot manage to make a tweet's image into a featured image by default. Any ideas on how to handle this?

I've also thought of other ways this could be done, eg. if there were a service that could turn the twitter feed into a json file and see if there were better fit plugins/ options to import said json file or something like that. But so far, the decisions taken 1 through 3 are the upstanding ones. I know that a while ago there may have been other options as well (eg. in the past I had managed to do something similar by turning a Twitter feed into a structured feed through Yahoo pipes, but I cannot remember much now)

Any ideas on how this could be better implemented? 

Caveat: I'm using Wordpress because it's what the client prefers to be flexible to move contents and design around, not necessarily because it's optimal (Gatsby could be better, for an example).

All inputs appreciated.

Thanks!
Day 106 : Tonight
Tags: hiphop, code, coding, lifelongdev
Published: 2020-03-31 21:57:37

_liner notes_:

- Professional : Had a few meetings in the morning and afternoon. After that got to coding. Finally reworked some code I had reworked previously, but there are some new methods I wasn't aware about (I think they were just released in the latest version) so I incorporated them. Just have to rewrite the corresponding tutorial to include the new stuff. 

- Personal : Got a basic Svelte app scaffolded and added Firebase Authentication. Wasn't that bad. I used a tutorial as a guideline at https://fireship.io (Not an ad. But the site is pretty awesome and I'm signed up as a lifetime member. Super helpful resource.)

![coast of Lladdwyn Island, Wales with a lighthouse](https://dev-to-uploads.s3.amazonaws.com/i/uqmtvw5a1z4njobfqsz3.png)

Tonight, I'm hoping to get a connection to the database for my project so I can start pulling and pushing data from my admin site. Yeah, that's it. Small goals. haha

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube vfbvcd71qCo %}
Mocking Logger in Java with Mockito
Tags: java, testing
Published: 2020-03-31 21:40:42

Yes, you read it correctly: "*Mocking Logger in Java*". That might sound very weird when you see this for the first time but there are some particular cases in which the only way to unit test some parts of your application is by checking whether some specific messages were logged or not.

For example, suppose that your application needs to make an asynchronous call to some other WebService. Then you have separate threads for making that call. For the main thread, it doesn't matter if the call to the service was successful or not because it won't wait for a response (otherwise it would be synchronous, right?). Suppose that this part of your application will just call the service and, after that, only log whether the call was successful or not (needless to say that in such a case, you need a monitoring tool in place to know when things are not going well in production).

Now, you have to create a JUnit test case to cover these scenarios. If you google it, you are going to find some people using *PowerMock* for this, but imagine that you are already using *Mockito* and, for some reason, you want to do this using *Mockito* only.

In this post I'm assuming that you are already familiar with *Mockito*, so I'll focus on the "*mocking logger*" part only. You can find lots of *Mockito* tutorials on the Internet if you want to learn it.

Okay. One way to accomplish this is to mock the *Appender* of your *Logger* object and use *Mockito*'s *ArgumentCaptor* to capture all logging events in your test case:

``` java
    @Mock
    private Appender mockedAppender;

    @Captor
    private ArgumentCaptor<LoggingEvent> loggingEventCaptor;
```

Then you have to make sure that the mocked *Appender* is added to root *Logger* before the tests are executed:

``` java
    @Before
    public void setup() {
        Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
        root.addAppender(mockedAppender);
        root.setLevel(Level.INFO);
    }
```

After this you are ready to call the tested class and do the assertions on the logged messages:

``` java
    @Test
    public void testSuccessCall() throws Exception {
        // mock all required response objects in here

        [...]

        // this is the call to the service being tested
        myService.execute(createRequestForSuccessResponse());

        // check how many times the ArgumentCaptor was called
        verify(mockAppender, times(1)).doAppend(loggingEventCaptor.capture());
        // get the reference to the LoggingEvent you want to inspect
        LoggingEvent loggingEvent = loggingEventCaptor.getAllValues().get(0);
        // check the logged message
        assertEquals("Webservice was successfully called", loggingEvent.getMessage());
        // check the log level
        assertEquals(Level.INFO, loggingEvent.getLevel());
    }
```

I hope this might be eventually helpful when you face such a particular scenario! ;-)
JavaScript Spread Operator Explained
Tags: javascript, webdev, tutorial, beginners
Published: 2020-03-31 21:39:39

The JavaScript spread operator is a way to expand an array or list into a concatenable type. This will make more sense after looking at a few examples and code snippets. If you do not understand arrays or lists within JavaScript please read this post first - Arrays and Lists in JavaScript

If we want to combine two arrays in JavaScript we can use the Concat function, which stands for concatenation. This function does not affect the arrays, it returns a new array with the combination of the two arrays. The 'result' variable in the code snippet below will contain an array with the number 1 through 10 inside.

```javascript
var arr1 = [1, 2, 3, 4, 5];
var arr2 = [6, 7, 8, 9, 10];

var result = arr1.concat(arr2);
```

We can achieve the same thing by using the spread operator. The spread operator is represented by three dots/periods (...). To concatenate two arrays we first create a new array by using two square brackets, then the first element we use the spread operator on the first array and we do the same with the 2nd element and 2nd array. The spread operator will expand the arrays into there elements. So the 'result' variable will contain the number 1 through 10, as before.

```javascript
var arr1 = [1, 2, 3, 4, 5];
var arr2 = [6, 7, 8, 9, 10];

var result = [...arr1, ...arr2];
```

If we didn't use the spread operator, as shown below. The 'result' array would contain two arrays, inside of 10 numbers. The first element would contain an array/list of the number 1 through 5 and the second element will be another list with the number 6 through 10.

```javascript
var arr1 = [1, 2, 3, 4, 5];
var arr2 = [6, 7, 8, 9, 10];

var result = [arr1, arr2];
```

You can also combine raw values and a spread operator to create a new array. The below result variable will contains a list of number from -2 to 5. This is because we are adding the raw value -2, -1, and 0 and then concatenating the 'arr1' list using a spread operator.

```javascript
var arr1 = [1, 2, 3, 4, 5];

var result = [-2, -1, 0, ...arr1];
```

You can also use array methods, such as the filter function, in combination with the spread operator to create really custom lists. The below 'result' variable will contain a list of number from 3 to 6. Without the spread operator the result variable would contain two arrays instead of a list of just numbers.

```javascript
var arr1 = [1, 2, 3, 4, 5];
var arr2 = [6, 7, 8, 9, 10];

var result = [...arr1.filter(i => i > 2), ...arr2.filter(i => i < 7)];
```

This post was originally published on https://acroynon.com
MySQL: ERROR1364 fix
Tags: linux, mysql
Published: 2020-03-31 21:14:07

## It's all about the money

Saving $s has become a hard fact for many individuals and companies these days. In this process I started questioning whether I really need an AWS RDS database instance of whether I run my mysql installation on my EC2. After a rather simple switch, I set up a cron-job for dumps and planned on storing them in a separate S3 bucket (you never know, right?).

The complete process took me less than two hours and I started to rethink some DevOps concepts after being very happy with the benchmarks & performance of my brave EC2 micro instance.

## Failing inserts

However, something was off. Did people stop using the POC installation of [blua.blue](https://blua.blue)? Since I am a big proponent of privacy, monitoring is limited to a minimum. But API traffic seemed normal. 

I tried logging in, changing settings, signing up, commenting, viewing - all seemed working. Until I failed to create a new article.

## Unusual debugging

I was unable to reproduce the error locally and none of the error logs on my server showed anything. Hm, how was my error reporting set up again? Sometimes the bold methods are the right choice: I logged every SQL-transaction result and found the following error-number on some transactions:  **1364**

## Field doesn't have a default value

A quick google search revealed that apparently some of my tables contain columns requiring a value. But didn't I use exactly the same schemata as previously used via RDS? Thankfully, I am not the first one running into this issue and it seemed I should check somewhere else then I expected: in my MySQL configuration. The fist thing I did was verifying that what I read online is indeed my problem:

```
mysql> SHOW VARIABLES LIKE 'sql_mode';
```


And sure enough, there it was: **STRICT_TRANS_TABLES**

What this variable does is setting the your MySQL to reject any empty (or most likely undefined) field or your query unless there is a defined default value.
I don't know about you, but I always lived quite happily with the fact that nullable fields will default to null. And minimizing constraints is definitely a plus on top of the laziness. 
So how can I get rid of that behavior? 

## Changing the configuration

The easiest way is to override your mysql configuration. Depending on your setup, your will find various .cnf files that will offer possibilities. If you are not sure, simply create a new one   in the conf-directory (likely `/etc/mysql/conf.d/`).

Here are the steps to take:

1. copy your existing mode-variable (see above SQL-query)
2. define your new sql_mode variable (under mysqld block)
3. restart the mysql service

If you created your own **.cnf**-file (e.g. custom.cnf ), it could now look like this:

```
[mysqld]
sql_mode=IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
```
After restarting your service, you might want to check your setup again

`$ sudo service mysql restart`

`$ mysql -u root -p`
`mysql> SHOW VARIABLES LIKE 'sql_mode';`
Using Python Enum and IntEnum Like An Expert
Tags: python, enum, models, expert
Published: 2020-03-31 21:11:22

Hello guys. If you use forms on your Django web applications and you want to clean model scheme, you should use enums! 

## Let's start

For example, you have a product model and your visitors select something on form like status.

We consider the options as follows:
* Task
* Pending
* Published

...you have a two option. First one is complex and unmanagable.
You can create tuple like below and add 'choises' attribution to CharField:

```python
STATUS = (
  ("TASK", "Task"),
  ("PENDING", "Pending"),
  ("PUBLISHED", "Published"),
)
```
or 
```python
STATUS = (
  (1, "TASK"),
  (2, "PENDING"),
  (3, "PUBLISHED"),
)
```

Your product model:
```python
class Product(models.Model):
  category = models.ForeignKey("Category", on_delete=models.CASCADE,
    verbose_name="Category Name", blank=True, null=True)
  title = models.CharField(max_length=50, verbose_name="Product Title",
    blank=True, null=True)
  status = models.CharField(choices=STATUS)
```

It is correct and will work without errors. Python will save them to db as string.
But it is both complex and unmanageable. Because If you want to use this field anywhere, you need to call like below because tuple is not useful for calling:

```python
def example(self):
  if self.status == 1:
    make_something()
  elif self.status == 2:
    make_something()
```

I prefer using Enum or IntEnum.
Firstyl we need import Enum:

```python
from enum import Enum, IntEnum
```
Let's create our enum classes. Don't worry, we don't need create new migrations.

```python
class Status(enum.Enum):
  TASK = "Task"
  PENDING = "Pending"
  PUBLISHED = "Published"
```
or (how you want to keep them)
```python
class Status(enum.IntEnum):
  TASK = 1
  PENDING = 2
  PUBLISHED = 3
```

And your model should be below:
```python
class Product(models.Model):
  ...
  status = models.CharField(
    choices=(
        (x.value, x.name.title()) for x in Status),
    default=Status.TASK
    )
```
or
```python
class Product(models.Model):
  ...
  status = models.IntegerField(
    choices=(
        (x.value, x.name.title()) for x in Status),
    default=Status.TASK
    )
```

You can set a default value as I added above.
How do you use Enum on functions or anywhere?

You will call enums like below:
```python
def example(self):
  if self.status == Status.TASK.value:
    make_something()
  elif self.status == Status.PUBLISHED.value:
    make_something()
```
or you can iterate them like below:
```python
def get_states(self):
  return [{"id": s.id, "name": s.name} for s in Status]
```
Congratz! It's Pythonic way.
How to Implement a Stack in Node.js
Tags: javascript, node
Published: 2020-04-09 17:51:46

---
title: How to Implement a Stack in Node.js
published: true
date: 2020-03-31 21:01:44 UTC
tags: javascript,node
canonical_url: 
---

[![](https://cdn-images-1.medium.com/max/2600/0*2qmCy1qhKeVpPTv8)](https://medium.com/javascript-in-plain-english/how-to-implement-a-stack-in-node-js-e7b43af282d4?source=rss-bba4d4e74108------2)

Stack is one of the most important data structures in programming, but how we can implement a stack in javascript? Let’s dig in.

[Continue reading on JavaScript in Plain English »](https://medium.com/javascript-in-plain-english/how-to-implement-a-stack-in-node-js-e7b43af282d4?source=rss-bba4d4e74108------2)
What’s your alternative solution? Challenge #6
Tags: challenges, discuss, javascript, codenewbie
Published: 2020-03-31 20:55:11

# About this series

This is series of daily JavaScript coding challenges... for both beginners and advanced users.

Each day I’m gone present you a very simple coding challenge, together with the solution. The solution is intentionally written in a didactic way using classic JavaScript syntax in order to be accessible to coders of all levels.

Solutions are designed with increase level of complexity.

## Today’s coding challenge

```
Calculate 10! (factorial of 10).

```

(scroll down for solution)

## Code newbies

If you are a code newbie, try to work on the solution on your own. After you finish it, or if you need help, please consult the provided solution.

## Advanced developers

Please provide alternative solutions in the comments below. 

You can solve it using functional concepts or solve it using a different algorithm... or just solve it using the latest ES innovations.

By providing a new solution you can show code newbies different ways to solve the same problem.

## Solution

```javascript
// Solution for challenge06

var prod = 1;

for(var i = 1; i <= 10; i++)
{
    prod *= i;
}

println(prod);

```


To quickly verify this solution, copy the code above in this coding [editor](https://codeguppy.com/code.html) and press "Run".

> Note: The solution was originally designed for [codeguppy.com](https://codeguppy.com) environment, and therefore is making use of `println`. This is the almost equivalent of `console.log` in other environments. Please feel free to use your preferred coding playground / environment when implementing your solution.
How did you estimate your coding experience level for dev.to?
Tags: discuss, selfevaluation, devmeta
Published: 2020-03-31 20:43:09

---
title: How did you estimate your coding experience level for dev.to?
published: true
description: 
tags: discuss, self-evaluation, dev-meta
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/g36ynh9gbyhy1hcma7z1.png
---

I'm curious: How did others feel about evaluating their experience level inside their dev.to profile?[^1]

I'll be honest about something that I feel kind of weird about... I just set mine to 5, **the max ooOOOoOoO**.

Do I _really_ feel like "la crème de la crème" of engineers? Like a 5 out of 5?? Like a 5x dev?!? No. Absolutely not.

However, I wanted to start seeing more challenging content in my feed, and I figured that would be the most straightforward way.

Hence, I'm curious if anyone else felt unsure about how they estimated their skill-level.

Opening the floor to discussion. 

[^1]: If you have no idea what I'm talking about, go to your [UX Settings](https://dev.to/settings/ux) and scroll to **Content Customization**. 

![Photo of the Content Customization section of UX Settings page](https://dev-to-uploads.s3.amazonaws.com/i/k8bezru02xri8ap63njw.png)
<figcaption>This is what Content Customization looks like as of 31 March, 2020</figcaption>