teleren/devto huggingface dataset:
Installing the latest version of Ruby on Raspberry pi
Tags: raspberrypi, ruby
Published: 2020-05-28 05:49:59

---
title: Installing the latest version of Ruby on Raspberry pi
published: true
description: 
tags: RaspberryPi, Ruby 
---

## First

* This is almost the same way to install in Debian.
* Please be patient because it may take several hours to install Razpai because the spec is low.

## Prerequisites
* Body: Raspberry Pi 1 Model B+
* Memory card: 8GB
* OS: Latest version of Raspbian installed


## rbenv installation

Install rbenv and write the configuration to the bash configuration file, if you use zsh, etc.

```
> sudo apt-get install rbenv
> echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> .bashrc
> echo 'eval "$(rbenv init -)"' >> .bashrc
```

Confirmation of installation

```
> rbenv
> rbenv x.x.x #version to be displayed
```

Installing ### git

If git is not installed, install git.

```
> sudo apt-get install git
```


## Install ruby-build

I'm going to clone ruby-build from git.

```
> git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

> rbenv install --list
there are 2.3.1 and the latest version of Cruby 2.3

rbenv install 2.3.1
```

## Troubleshooting

### If you don't have enough libraries in your Ruby installation, you can try to add them by using the following command

```
> sudo apt-get install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
```

Reference: https://github.com/rbenv/ruby-build/wiki#suggested-build-environment


### If you installed ruby-build with apt-get

Even if I install ruby-build by apt-get, there is no latest version of Ruby in the list of available installables.
At runtime, ruby-2.2.0-preview is the latest version, and there is no 2.3 system of the latest version at this time.


```
> sudo apt-get install ruby-build
> rbenv install --list
```

To uninstall ruby-build, click here

```
> sudo apt-get remove ruby-build
```
Common Git Alias
Tags: git, github
Published: 2020-05-28 05:42:24

This posts will help you understand what a `git` alias is and some of the basic ones I use.

### What's a `git` alias?
In the computer science domain, alias means an alternative name or label that refers to a file, command, address, or other items, and can be used to locate or access it.

So, basically with `git` alias, the idea is that you create shorter alias for the most commonly used commands, to reduce the amount of typing that you do.

### How to use them?
To use them, add the commands to your `.bash_profile`, `.bashrc` or `.gitconfig` file. Once you add them run the `source .bash_profile` command.

You can add them by using [command line](https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases) also, but would not recommend it as it would be very verbose and difficult to manage over time.
```
$ git config --global alias.co checkout
```

### Common commands
```
alias gc='git checkout'
alias gcm='git commit -m'
alias gs='git status'
alias ga='git add --all'
alias gp='git pull --rebase'
alias gb='git branch -vv'
alias gr='git remote -v'
alias grt='git reset --hard'
alias gpub='git push origin master'
alias grp='git rebase master'
alias gd='git branch -D'
alias gm='git merge'
alias gmx='git merge -X theirs'
alias gk='gitk &'
alias gda='git branch | grep -v "develop" | grep -v "release" | xargs git branch -D'
alias gf='git fetch'
alias gl='git log -3'

# cleans all branches locally that have already been merged.
alias gcmb="git branch --merged | grep -Ev '(^\*|develop)' | xargs git branch -d"
```

Another good resource here to enable a quicker workflow I also use the [`git-extras`](https://github.com/tj/git-extras). It allows an abstraction on more complicated git workflows.
How to check the connection between mysql and memcached in php
Tags: php, mysql, memcached
Published: 2020-05-28 05:41:47

---
title: How to check the connection between mysql and memcached in php
published: true
description: 
tags: PHP, MySQL, Memcached 
---


## First things first

We all love PHP, but setting up the middleware is a bit of a pain.
I'm sure I've set it up, but I've got a little snippet to make sure it's all connected.

If PHP and the middleware are configured correctly, the following code will confirm that PHP has access to Mysql and Memcached
If it doesn't work, you're in the middle of a setup gone wrong.

It would be a good idea to check the environment with phpinfo()

**Caution**.
Memcached's library uses Memcached, not Memcache, so if you use Memcache, please read the

## Create a file for checking and check the operation.

Put the following chack.php in the document root and access it with a browser

```check.php
<html>
  <body>.
<?php

  // Database connection check
  // Put the host name, connected user, and password in the argument of mysql_connect, in that order.
  $dbc = mysql_connect('mysql', 'root', 'password');
  if (! $dbc) { dbc = mysql_connect('mysql', 'root', 'password'); if (!
    die('db connection failed<br/>'.mysql_error());
  }
  print('DB connect success! <br/>');

  // selection check in database
  // insert the name of the database to connect to your_database.
  $db_selected = mysql_select_db('your_database', $dbc);

  if (! $db_selected){ { mysql_select_db('your_database', $dbc); if (!
    die('db select failed<br/>'.mysql_error());
  }
  print('db select success! <br/>');

  if (mysql_close($dbc)){
    print('disconnect success! <br/>');
  }

  // memcached connection check
  $m = new Memcached();
  // put memcached host name and port number in addServer's arguments
  $m->addServer('memcached', 11211);

  $m->set('integer', 100);
  $m->set('string', 'string 1234');

  var_dump($m->get('integer'));
  print('<br/>');
  var_dump($m->get('string'));
? >
  </body>.
</html>
```

If it succeeds, the following will be displayed on the screen

```html
DB connect success!
DB select success!
disconnect success!!!!
int(100) 
string(11) "string 1234"
```
How to run multiple bash commands in CMD and docker-compose.yml of Dockerfile
Tags: bash, dockercompose, docker
Published: 2020-05-28 05:24:49

---
title: How to run multiple bash commands in CMD and docker-compose.yml of Dockerfile
published: true
description: 
tags: Bash, docker-compose, Docker 
---

When executing a command with CMD in Dockerfile or command in docker-compose.yml file, the
There is only one command that can be executed.

In this case, it is also possible to execute multiple commands by executing a shell script

A simpler way to execute multiple commands is to use


```
bash -c "Command string"
```

You only need to call it with `bash -c` for

It seems to say `bash -c "ls -l && ls"` in the console, so you might want to experiment.


Specifically, we will introduce an example of running elasticsearch on 9200 and 9250 ports.

### Dockerfile

```
CMD bash -c "elasticsearch -d && elasticsearch --http.port=9250"
```

### docker-compose.yml

```
command: bash -c "elasticsearch -d && elasticsearch --http.port=9250"
```
Nodemon Like Reloader 🔄 in Deno (Denon)
Tags: deno, typescript, node, tutorial
Published: 2020-05-28 05:17:49

<p>It might be frustrating to always close your Deno server and restart it again. As Deno doesn't provide "Hot Reload" out of the box but still there is a way to do it, so no more closing your server and restart it again or banging your head to a desk 😅. </p>

<p>
For the sake of this example we gonna make little Deno application into "app.ts" file
</p> 

<pre>

import { serve } from "https://deno.land/std@0.52.0/http/server.ts";
const s = serve({ port: 8000 });
console.log("http://localhost:8000/");
for await (const req of s) {
 req.respond({ body: "Hello World\n" });
}

</pre>

<p>
After saving the code you need to install Denon. Denon is the deno replacement for nodemon providing a feature-packed and easy to use experience. You need to upgrade Deno v1.0.2 to install the Denon simple type the following command.
</p>

<pre>

$ deno upgrade

</pre>

<p>
Now you just need to write the following command into your Terminal or PowerShell and you ready to go.
</p>

<pre>

$ deno install --allow-read --allow-run --allow-write -f --unstable https://deno.land/x/denon/denon.ts

</pre>

<p>
Denon uses unstable features of the stdlib, as a result the flag - unstable currently required for the installation.

You can see various other options Denon has provided by simply writing "denon -h" or "denon- help".

For running our app.ts file we need to write denon run then we have to pass the flag so that our app will only pass those options require by the user then we need to type the file name.
</p>

<pre>

$ denon run -allow-env -allow-net app.ts

</pre>

<p>
Now enjoy the feature of host reload on the fly whenever you change your file. Just try to change the body msg to "Deno is amazing" and you are done.
</p>

<p>
You can also follow our video tutorial also on youtube on <a href="https://www.youtube.com/channel/UCnhsNyu4bdDxuW1TT3hg-pg">Recoding </a>.
</p>

{% youtube ugRTRLpMQ6U %}
"How do you use a Next.js router in a class component?"
Tags: react, nextjs, javascript
Published: 2020-05-28 05:16:23

---
title: '"How do you use a Next.js router in a class component?"'
published: true
description: A React + Next.js mini-tip.
tags: ["react", "nextjs", "javascript"]
---

Recorded live on [Twitch](https://www.twitch.tv/videos/633185925) on 26 May 2020.

This video is a short clip from one of my Twitch-Driven Development sessions, when someone asked me how to use a Next.js router in a class component. Want more of these? I do live coding streams occasionally on my [Twitch channel](https://www.twitch.tv/resir014). Follow me to be notified!
Correlation vs Covariance
Tags: Correlation, Covariance, datascience
Published: 2020-05-28 05:14:04

Correlation and Covariance are two commonly used statistical concepts majorly wont to measure the linear relation between two variables in data. When wont to compare samples from different populations, covariance is employed to spot how two variables vary together whereas correlation is employed to work out how change in one variable affects the change in another variable. albeit there are certain similarities between these two mathematical terms, these two are different from one another . Read further to know the difference between covariance and correlation.

Covariance:

It is an indicator of the degree to which two variables change with reference to one another i.e.., it measures the direction of linear relationship between these two variables .The values of covariance can lies within the range of -? to +?

Here,

Xi – values of X variable
yj – values of Y variable
X?- mean of x variable
Y?- mean of y variable
N- Number of knowledge points ( n-1 for sample covariance)
Now let’s see the way to calculate an equivalent in python using inbuilt functions:

Here, Covariance for the variable itself is that the variance for an equivalent .

Correlation:

Correlation measures the strength and direction of linear relationship between two variables or we will say it’s a normalized version of covariance. By dividing the covariance with variance of the variables it scales down the range to -1 to +1 , comparatively correlation values are more interpretable.

As we will see from the formula itself, correlation is calculated from standardising covariance results; allow us to just execute an equivalent in python and see the difference.


Here , the correlation results on original data is analogous to covariance on standardized data ( with deviation in decimal values ) . For any of our applications like PCA , we will use either of them which yields an equivalent results. Alternatively, we will use function from NumPy modules also Covariance : numpy.cov(a,b) Correlation: numpy. corrcoef (a,b)

Difference between Correlation and Covariance:

Covariance is suffering from the change in scale as opposite to an equivalent correlation values aren't influenced by change in scale. Correlation values are dimensionless with unit free and scale free measure of strength and direction between two variables.

Conclusion:

Both covariance and correlation are closely associated with one another and differ tons when it involves making a choice between these two. Most of the analysts prefer correlation because it is more interpretable and can not be suffering from scale and units within the data.

For more info : https://www.excelr.com/blog/data-science/statistics-for-data-scientist/Correlation-vs-covariance#
Alien symbols in Jenkins!
Tags: jenkins, utf8, problems
Published: 2020-05-26 17:29:42

If you ever come accross some these "alien symbols" in Jenkins, specially on Windows:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/59wlbf75d44kxq3a5b75.PNG)

And you want to make it up, the problem is the default encoding system and the solution is pretty *straight forward*:

- Navigate to the directory where jenkins is installed. Usually `C:\Program Files (x86)\Jenkins`.

- Once in the folder, open the `jenkins.xml` with Notepad, VSCode or any text editor.

- Add --> `-Dfile.encoding=UTF8` to the arguments.

The arguments should look something like this:

```xml
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -Dfile.encoding=UTF8 -jar "%BASE%\jenkins.war" --httpPort=8080 --webroot="%BASE%\war"</arguments>
```

- restart you Jenkins service and voilá!

After that, if you run the job/pipeline, you should see the console output showing the logs properly!

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

That's it, keep having fun with your CI/CD pipelines!
How to change the table used in DelayedJob
Tags: delayedjob, rails
Published: 2020-05-28 05:06:43

---
title: How to change the table used in DelayedJob
published: true
description: 
tags: delayed_job, Rails 
---

DelayedJob, a gem that realizes asynchronous processing, uses RDMS such as MySQL or PostgreSQL for queuing (although it seems that MongoDB can also be used).

The table of this queued database is fixed to `delayed_jobs` by default.
In this article, I'll show you how to change this table from the default.

This measure may be used in the case of multi-tenant use of monolithic Rails.

## About each gem version
* rails: 5.1.4.
* delayed_job: 4.1.3
* delayed_job_active_record: 4.1.2 * rails: 5.1.4 * delayed_job: 4.1.3

## Fixes config/application.rb
Change Delayed::Backend::ActiveRecord::Job.table_name in config.after_initialize block.

For example, if you want to change the default table delayed_jobs to other_delayed_jobs in DelayedJob

```config/application.rb
Module ApplicationName
  class Application < Rails::Application
    config.after_initialize do
      Delayed::Backend::ActiveRecord::Job.table_name = 'another_delayed_jobs'
    end
  end
end
```

DelayedJob, a gem that realizes asynchronous processing, uses RDMS such as MySQL or PostgreSQL for queuing (although it seems that MongoDB can also be used).

The table of this queued database is fixed to `delayed_jobs` by default.
In this article, I'll show you how to change this table from the default.

This measure may be used in the case of multi-tenant use of monolithic Rails.

## About each gem version
* rails: 5.1.4.
* delayed_job: 4.1.3
* delayed_job_active_record: 4.1.2 * rails: 5.1.4 * delayed_job: 4.1.3

## Fixes config/application.rb
Change Delayed::Backend::ActiveRecord::Job.table_name in config.after_initialize block.

For example, if you want to change the default table delayed_jobs to other_delayed_jobs in DelayedJob

```config/application.rb
Module ApplicationName
  class Application < Rails::Application
    config.after_initialize do
      Delayed::Backend::ActiveRecord::Job.table_name = 'another_delayed_jobs'
    end
  end
end
```

## 【Reference】When using non-conventional tables in a normal ActiveRecord model
Changing the value in self.table_name

For example, in the User model, if you want to change the users table from the users table as per the Rails convention to the foo_bar_users table
I'll do it for you as follows

```user.rb
class User < ApplicationRecord
  self.table_name = 'foo_bar_users'
end
```


## 【Reference】When using non-conventional tables in a normal ActiveRecord model
Changing the value in self.table_name

For example, in the User model, if you want to change the users table from the users table as per the Rails convention to the foo_bar_users table
I'll do it for you as follows

```user.rb
class User < ApplicationRecord
  self.table_name = 'foo_bar_users'
end
```
Mirror a sub-directory GitHub repo with CircleCI
Tags: circleci, github, mirroring, repository
Published: 2020-05-28 04:20:27

Last time, I was talking about [Mirroring a Github Repo with CircleCI](https://medium.com/p/68d038e66b04). That article was about mirroring the whole repository using `git clone --bare command`. By using that git command, we not just mirror the whole content but also all branches from the repository.

There are times that we want to only mirror a sub-directory from the main repository. We can achieve that easily by using a special command by "git".

So today I will share what I learned mirroring a sub-directory from a GitHub repository using CircleCI.

This time we don't need to generate an SSH key. We will use CircleCI's `checkout` command as we need the CI to clone our repository normally, not bare.

Add the code below into your "config.yml" and CircleCI will do the magic for you.

{% gist https://gist.github.com/oshimayoan/0654140cae4205a76e17c85b36fb5bd4 %}

We're done! Actually, this is a lot easier than the previous one as there is almost no setup this time.

You can push a commit now to make the CircleCI mirror your sub-directory into another repository.
SIX POINTS TO CONSIDER WHILE ADDING AN IMAGE TO A TECHNICAL DOCUMENT
Tags: writing, visual, technicalwriting
Published: 2020-05-28 04:03:53

Image is an essential element of a technical document. While preparing a manual or a release note, you need to include a screenshot for a process or step. Here are some points to consider while adding an image to a written text;

1. Ensure the image included correlates with the mechanisms, processes, or steps that you are trying to clarify.

2. Always reference an image in the description before its placement. Also, include numbers and titles. Some document generator tools like; Sphinx automatically generate numbers for images.

3. Use appropriate labels and captions. Besides, used labels and captions should match the text description. For instance, if you are describing the "Add icon" of a UX design, do not call it "Add icon" in the image and "icon to add" in the text.

4. Use an image when it contains copyrighted information. Also, anonymize critical information if you are using borrowed images.

5. Avoid using blurry and unclear images. While adding screenshots in a technical document (manual and release note), take a clear picture using screen capture tools such as; Snagit. 

6. An image need not be mandatorily added to the document. However, it can help your audience to self-evaluate a process. Some concepts are so complex. Instead of using an image, it is best to enhance the text.

As a bonus tip, do not exaggerate or misinterpret the original scale of an image. It affects the readability of the text.

Keep writing :)
[From May 21 to May 27] The things I knew and thought last week
Tags: frontend
Published: 2020-05-28 04:01:44

---
title: [From May 21 to May 27] The things I knew and thought last week
published: true
description: [From May 21 to May 27] The things I knew and thought last week
tags: frontend
---

# [vuetify] breadcrumb generator

I want to generate Vuetify's breadcrumb automatically by URL.

Let's say it the URL is _/home/company/list_. The generator makes breadcrumbs like the below.

```
[
  {
    title: 'HOME',
    url: '/home',
  },
  {
    title: 'HOME / Companies',
    url: '/home/company/list',
  },
]
```

# [vue] create form initializer

Almost case, I will create an initial data with an interface using TypeScript like this.

```ts
interface Data {
  id: number
  name: string
}

Vue.extend({
  data(): Data {
    return {
      id: 0,
      name: '',
    }
  }
})
```

But if the Data interface definition gets much more, I have to fill in all initial value for the Data because the TypeScript compiler cannot build it.

So I want to generate initial values from a Data interface. Below is an example. `generator` function makes initial values from the interface.

```ts
const initalValues = generator(data: Data)

// initialValues
{
  id: 0,
  name: '',
}
```

# [js] module bundler

I'm looking into how module bundler works.
Rest API Testing using JMeter | API Testing Tutorial | Day 28
Tags: testing, tutorial, webdev, beginners
Published: 2020-05-28 03:48:31

In this video of 30 Days of API Testing Challenge, I am going to discuss How to perform JMeter API Testing or API Performance Testing.

[![30 Days of API Testing](https://i.imgur.com/W9v9czl.png)](https://youtu.be/f9hfKO-_S3I "30 Days of API Testing")


### 👉 What is Performance Testing?
 Performance testing is artificially creating or simulating load and measuring how your environment or apis handles it.

### 👉Types of Performance Testing
 ⚡️Baseline Testing
  How a system performs under expected or normal load and creates a baseline with which other types of tests can be compared.
 ⚡️Stress Testing
  Find the load volume where the system actually breaks or is close to breaking.
 ⚡️Load Testing
  In this increasing the load and see how the system behaves under higher load.
 ⚡️Soak Testing
  run load tests or even baseline tests over a long period of time and see how the target environment handles system resources and if it works properly.
 ⚡️Scalability Testing
  to check whether your system scales appropriately to the changing load. 


### 👉 Why we do API Performance Testing? 
 ⚡️To determine the overall performance of a system under specific circumstances
 There are Two Types
  ⚡️Functional Tests
   To ensure that the API returns the desired output for a given input.
  ⚡️Load Test
   ⚡️In this multiple clients hit the same server at the same time, and the number of clients can drastically affect the behavior of the API.
 ⚡️ Nonoptimized code is making a request to a database that is slow in responding.
 processing of payloads (request and response bodies to multiple clients
 ⚡️ Check the impact of  a large amount of XML/JSON processing on the server-side

### 👉 JMeter API Testing
 Download
  http://jmeter.apache.org/download_jmeter.cgi
 Demo

🚀 Day 28 Task:  How to Performance testing APIs?

🚀 Thread:  https://scrolltest.com/api/day28

🚀 All Task List: https://scrolltest.com/api/task

🚀 Watch Full Playlist: https://apitesting.co/30days


🚀 Mastering API Testing -  https://www.learnapitesting.com

--
Be sure to subscribe for more videos like this!

[![ TheTestingAcademy](https://dev-to-uploads.s3.amazonaws.com/i/r7vcy6wbvyjbk1y1uu0o.png
)](https://www.youtube.com/TheTestingAcademy?sub_confirmation=1 "TheTestingAcademy")
What tools are you using to manage your company's workflow?
Tags: productivity, startup
Published: 2020-05-28 03:40:27

As we know every company whether it is big or small we need some tools to manage our organizational work. 

Here I'm conducting a survey on how you/your company is managing operations. So that we can have a curated list of tools to handle operations smoothly.

[Click here to fill survey](https://codewithghazi.typeform.com/to/OAsDsc)
Introduction to Mockito: Unit Testing Framework
Tags: Mockito, java, Junit, UnitTest
Published: 2020-05-28 03:28:42

Mockito is a Java-based mocking framework most preferred with the Junit testing framework. It internally uses Java Reflection and allows to create dummy objects of service.

Mockito is a very useful tool that simplifies the test case creation by creating mock/dummy object of external dependencies this dummy data will later apply with mocks into code under test.

Link: https://blog.joshsoftware.com/2020/05/27/introduction-to-mockito-unit-testing-framework/