teleren/devto huggingface dataset:
Ensure required environment variables are set when booting up Rails
Tags: ruby, rails, webdev
Published: 2021-02-17 14:50:51

---
title: Ensure required environment variables are set when booting up Rails
published: true
date: 2021-02-17 13:00:00 UTC
tags: ruby,rails,webdev
canonical_url: https://boringrails.com/tips/ensure-rails-env-vars
---

It’s common to use [environment variables to configure](https://12factor.net/config) external services or other options in a Rails app. These `ENV_VARS` usually are not checked into source control, but rather configured per environment.

Rails has the concept of `initializers`, which is code run during the boot phase of a Rails app.

You can add a custom `initializer` to check that required environment variables are set to avoid exceptions later on when your code expects a value to exist.

## Usage

Create a new initializer in your app and add the required variables:

```ruby
# config/initializers/01_ensure_environment.rb

if Rails.env.development?
  %w[
    AWS_ACCESS_KEY_ID
    AWS_SECRET_ACCESS_KEY
    S3_BUCKET
    ALGOLIA_ID
    ALGOLIA_API_KEY
    ALGOLIA_SEARCH_KEY
    ALGOLIA_INDEX
    ALGOLIA_CAMPAIGN_INDEX
    TWITTER_API_SECRET
    TWITTER_API_TOKEN
  ].each do |env_var|
    if !ENV.has_key?(env_var) || ENV[env_var].blank?
      raise <<~EOL
      Missing environment variable: #{env_var}

      Ask a teammate for the appropriate value.
      EOL
    end
  end
end
```

## Options

Rails initializers are loaded and executed in alphabetical order. So use a name like `01_ensure_environment.rb` to control the sort order and make sure this one loads first.

You may wish to check in a sample `.env.sample` file into git (without any values) to make it easier for new team members to get their environment into a working state.

## Additional Resources

Rails Doc: [Configuring Rails apps](https://guides.rubyonrails.org/configuring.html)

* * *
[![](https://boringrails.com/images/twitter-banner.png)](https://twitter.com/_swanson)
Testing & Formatting React
Tags: react, testing, formatting
Published: 2021-02-17 12:57:22

## Start
Start med at opret en mappe, og kald den et navn, mappen skal stå med småt. Åben derefter mappen i din editor, og skriv i terminalen 
`npx create-react-app .`

Opret 2 mapper i vores "src" mappe som hedder,
1. `__test__`, som skal indeholde vores tests.
2. `components`, som indeholder vores komponenter.

## Komponent
Lav en fil i vores `components` mappe og kald den et navn som giver mening ift. det komponent du vil lave. I mit tilfælde kalder jeg den, "Tutorial.js" første bogstav skal altid stå med stort.

Billedet indeholder et komponent med et `<p>` tag som skal indeholde vores title 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/enm25a2ivi19ndsy8blo.png)
 
Tilføj nu vores komponent i filen "app.js". 
1. I toppen importere vi vores komponent, `import Tutorial from "./components/Tutorial";`
2. Skriv nu dit komponents indhold, `<Tutorial title="Welcome to my Tutorial"/>`

**Du har nu lavet et komponent som er klar til at blive testet!**

## Test i React
Ved hjælp af `npm test`, kan vi tjekke om der er fejl i vores komponent. Vi kan f.eks. tjekke efter et specifikt ord i vores komponent.

Billedet indeholder vores test, som tjekker efter ordet "Tutorial"
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ntf5y9c2u2isq6qo1rmk.png)

**Du har nu lavet en test, og et komponent**

##Prettier?
Med prettier kan vi sætte nogle grundlæggende formatterings regler for vores kode. Fx kan vi bestemme linjelængde, om vi skal bruge tabs i stedet for mellemrum osv. Dette kan hjælpe andre med at overskue vores kode, og lave en standard hvis man er flere om et projekt.

Opret vores 2 filer der skal indeholde, formatterings regler og de filer som vi ikke skal formattere.

`.prettierrc.json`
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/50qsyq4c0j3jel4sn8lq.png)

`.prettierignore`
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zcxqw69atl157gce99b2.png)

## Pre-commit hooks & prettier
Pre-commit hooks sørger for at vi ikke uploader noget kode til github som ikke er blevet kørt af vores test, eller prettier, det gør den ved at køre en command inden.

Vi skal installere følgende,

1. Download `npx mrm lint-staged`
2. Download `npx husky install`
3. Download `npx husky add .husky/pre-commit`
4. Tilføj `npm test` til vores pre-commit fil.

Med pre-commit og prettier søger vi altid for at vores kode følger vores formatteringsregler inden vi comitter til github, eller om der er fejl i vores komponent.

1. Installer `npm i -D cross-env`
2. Tilføj i vores package.json `"test": "cross-env CI=true react-scripts test"`
 
**Vi kører nu vores test & prettier inden vi commiter**
Useful Npx Packages for the Developer's Everyday Life
Tags: npm, webdev, npx
Published: 2021-02-17 12:52:55

Npm comes with a neat tool called `npx` that lets you directly execute packages from the npm registry. It temporarily downloads it behind the scene and won’t pollute your local or global npm environment.

In this post I’ll skip useful packages that are bound to libraries and frameworks like Angular’s `ng`, react’s `create-react-app` or capacitor’s `cap`.

I focus on packages that have helped me through my daily life as a developer.

---

# npx kill-port
![npx kill-port](https://wicki.io/posts/2021-02-useful-npx-packages/kill-port.gif)**usage:** `npx kill-port 8080`
**repo:** [npkill](https://github.com/tiaanduplessis/kill-port)

Did some webpack dev server not shut down nicely and now 8080, or any port for that matter, is in use? Just kill it with kill-port.

---

# npx npkill
![npx npkill](https://wicki.io/posts/2021-02-useful-npx-packages/npkill.gif)**usage:** `npx npkill`
**repo:** [npkill](https://npkill.js.org/)

It’s no secret that node_modules folders [are the black holes of software development](https://wicki.io/posts/2021-02-useful-npx-packages/node_modules-black-hole.png). This package will help you get back your disk space by selecting and deleting the node_modules of your (unused) projects.

---

# npx http-server
![npx http-server](https://wicki.io/posts/2021-02-useful-npx-packages/http-server.gif)**usage:** `npx http-server .`
**repo:** [http-server](https://github.com/http-party/http-server)

Easily serve a directory as a simple webserver. Especially useful for compiled webapps in /build folders.

---

# npx timezone-compare
![npx timezone-compare](https://wicki.io/posts/2021-02-useful-npx-packages/timezone-compare.gif)**usage:** `npx timezone-compare`
**repo:** [timezone-compare](https://github.com/imbhargav5/timezone-compare)

This package helped me to plan quickly setting up meetings with others of different timezones.

---

# Honorable Mention: npx emoj
![npx emoj](https://wicki.io/posts/2021-02-useful-npx-packages/emoj.gif)**usage:** `npx emoj happy`
**repo:** [emoj](https://github.com/sindresorhus/emoj)

I used this package to death! Sadly its API, that came from getdango’s [Emoji & Deep Learning](https://getdango.com/emoji-and-deep-learning/), is not maintained anymore. Thus the emoji results are not ground breaking anymore.

As a replacement I suggest using `ctrl + cmd + space` (macOS), that will help you a bit on the way of finding the right emoji.

---

Simon Wicki is a Freelance Developer in Berlin. Worked on Web and Mobile apps at JustWatch. Fluent in Vue, Angular, React and Ionic. Passionate about Frontend, tech, web perf & non-fiction books.

👉 [Join me on Twitter to follow my latest updates.](https://twitter.com/zwacky)
How To Teasting in React or noget :)
Published: 2021-02-17 12:39:44

# **How To tests i react.js**
1. start ud med at kigge i dit komponent, og find ud af hvad du gerne vil ha testet.
2. importer dit komponent fra filen fx. `import Navbar from "./Navbar";`
3. derefter importer de ting du skal bruge for at teste fx. `import { render, screen } from "@testing-library/react";`
4. skriv din test: ``` jsx
test("if navbar renders with the text 'home'", function(){
    render(<Navbar />)
    var LinkText = screen.getByText(/home/i);
    expect(LinkText).toBeInTheDocument();
});
```
5. til sidst køres `npm run test` i konsollen, hvorefter vi får svar på om testen PASS'er eller FAIL'er

# **How to pre-commit hook med test**
1. for at lave et pre commit hook skal vi først ha installeret husky ved hjælp af at skrive `npx husky install` i vores konsol.
2. derefter skal vi skrive endnu en linje i konsollen `npx husky add .husky/pre-commit "npm test"`
2.1 her kan der dog ske nogle problemer med at husky ikke gider virke med det samme, der skal vi blot fjerne "npm test" fra vores command, og så derefter tilføje en linje i vores pre-commit fil i .husky mappen, der hedder `npm test` 

# **How To Prettier**
1. for at få Prettier til at virke skal vi først installere nogle NPM pakker som developer dependencies, dette gøres nemmest og hurtigst ved at skrive `npm i -D prettier eslint-config-prettier` i vores konsol.
2. imens pakkerne installere kan du lave de 2 filer der skal bruges til prettier `.prettierignore` og `.prettierrc.json`
3. lav setup til både din `.prettierignore`, og din `.prettierrc.json`.
`.prettierignore` skal indeholde følgende linjer:
```
node_modules
build
coverage
.vscode
```
4. Derefter kan du configure din `.prettierrc.json` til hvordan du vil have din kode formatteret det kan fx se sådan her ud:
``` json
{
    "PrintWidth": 120,
    "useTabs": true,
    "semi": true,
    "singleQuotes": false,
    "quoteProps": "consistent",
    "bracketSpacing": true,
    "jsxBracketSameLine": true,
    "arrowparens": "avoid"
}
```

# **How To Pre-commit hook med prettier**
1. For at lave pre-commit hooks med prettier skal vi igen starte ud med at få installeret .husky mappen ved at skrive `npx husky install` i vores konsol.
2. derefter skal vi skrive følgende kode `npx mrm lint-staged` i vores konsol, for at vores pre-commit hooks virker med prettier packagen.

herefter kan vi lave vores commits, as per usual, og vores setup vil tjekke om vores tests virker, og køre vores prettier setup, inden det bliver sendt ud på vores gitHub repository
Selenium Python Wait Commands
Tags: python, testing, tutorial, webdev
Published: 2021-02-17 12:31:19

In this post, we will learn about the various wait commands available in Selenium Python using the SeleniumBase framework. Using wait commands when doing browser automation is inevitable. Therefore, it’s important to understand how to use wait commands the right way.

### **Using “Wait” the Wrong way**
Now, this one, in particular, is a pet-peeve of mine. I have seen time and again in many codebases where hard-coded sleeps are used instead of implementing the right wait commands. I am sure you have seen this before as well or a variation of the code below –

![sleep](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4td5f1cc3c6n5p9j48dw.png)

While this one line in a single test won’t do much harm but just imagine when this becomes the “norm” for most of your tests. Soon, you will find your test run time to double, triple, or even quadruple * gulps * due to that 1 harmless line.

---

### **Using “Wait” conditionally**
Now that we know using hard-coded sleep is a bad practice, what can we do when we still need to use wait in our tests? Well, you would still use wait commands but this time you will wait for a particular condition to complete.

For example, if you need to wait for an element to be visible on the screen so that you can perform your next step, you could do something like this –

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

In the sample code above, I am not explicitly telling my test to wait ‘x’ amount of seconds before performing the next step. Rather, I am using a max timeout (6 seconds set in config) for my element to be visible on the screen. This way, my element can appear on the screen in 2 secs or 4 seconds, and then it will move on to the next steps saving you a couple of extra seconds!

**Some other wait commands to use –**

![wait-code2](https://dev-to-uploads.s3.amazonaws.com/i/6j0t7v5lmfavqwsq4fer.png)

---

### **Check out the video below to learn more about the wait commands in Selenium Python –**

{% youtube 7l88MW-2Wlw %}

To learn more about Selenium Python, check out the full [tutorial series here](https://automationbro.com/blog/selenium-python-tutorial-series/) for free!

---

📧 Subscribe to my [mailing list](https://automationbro.com/mailing-list) to get access to more content like this 

👍 Follow [automationbro](https://twitter.com/automationbro) on Twitter for the latest updates

...

I love coffees! And, if this post helped you out and you would like to support my work, you can do that by clicking on the button below and buying me a cup of coffee -

<a href="https://www.buymeacoffee.com/automationbro">![Buy me a coffee](https://dev-to-uploads.s3.amazonaws.com/i/4aw2ub3f4qkyjk0ivwt4.png)</a>

You can also support me by liking and sharing this content.

Thanks for reading!
Outdoor Lighting Columbus OH

Tags: outdoorlighting, landscape, outdoor
Published: 2021-02-17 12:25:48

If you’ve not yet made the decision to invest in outside lighting for your property, you could really be missing out. Landscape lighting and architectural lighting can lend a lot of class and elegance to a property, and you might be surprised at how affordable a new lighting design and installation can be – particularly when you consider the benefits of making such an investment.
A good lighting designs provider will be able to guide you toward solutions that will better suit your property’s characteristics, while still adhering to the tastes and budgetary restrictions that you might have. Naturally, this is the kind of service you can expect through our company.
Be BORING when choosing your tech stack
Tags: programming, productivity
Published: 2021-02-17 11:44:22

Whenever you are starting a new project either in a new startup or a new solution for your current employer, always try to be boring as much as possible when choosing the tech stack.

TL;DR

###Technology
Technologies tend to get better over time. The longer the technology is in the market, the higher the probability that it will be more stable.
Let's take python, for example, it has been around for around 30 years. it has hundreds of thousands of good packages. Hundreds of frameworks and a lot of support on StackOverflow and GitHub. So whenever I am going to start a new project, it will be on top of my choices.

### Product
The final goal of any software project is to provide a product providing a solution for a certain problem. So we should not deviate from that goal. Building the coolest piece of software without solving the main problem is not considered progress and it's highly likely to be replaced with one that actually solves it.
The main factor in measuring the success of a product is its functionality. No user cares about what is the tech stack or the programming languages behind it.
Always remember the main goal.

###Developers
Our goal is to solve problems. Chasing trends and use them whenever we can to pad our resumes will not the end goal and it's not advised.
And there no shame in using an old and stable solution to provide the functionality needed. 

###Takeouts
1- New technology choices come with a great deal of baggage. 
2- Always keep your solutions Stupid Simple.
3- It’s important to master the tools you choose. Make sure you do that.
4- Progress happens when delivering working solutions.

Thanks
Interview with Ryan Dahl, Creator of Node.js
Tags: node, javascript, typescript, deno
Published: 2021-02-17 11:28:45

Ryan Dahl is a software engineer and the original developer of the Node.js, and the Deno JavaScript and TypeScript runtime. We are glad to have had an opportunity to speak to Ryan about his projects, the main challenges in Deno, hear his thoughts on the future of JavaScript and TypeScript, find more about the third-party Deno ecosystem projects and discuss how he would have changed his approach to Node.js if he could travel back in time!

[Read the full interview here.](https://evrone.com/ryan-dahl-interview)
O que é DOR e DOD?
Tags: womakerscode
Published: 2021-02-17 11:27:34

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

Quando atuamos em projetos ágeis muitas vezes podemos acabar percebendo alguns desalinhamentos dentro do time de desenvolvimento ou até mesmo entre time de desenvolvimento e Produc Owner. Esses conflitos geralmente podem acontecer por dois fatores, sendo eles:

* O time pode estar recebendo requisitos com baixa granularidade ou com nenhum detalhamento. Além disso pode ocorrer de histórias maiores que a capacidade do time de entrega entrem para a sprint.

* Cada integrante do time entrega a sua feature ou a atividade que está responsável de uma forma diferente, ou seja, um integrante pode entender que apenas desenvolver já é o suficiente enquanto outro pode entender que o entregável é um software desenvolvido e com testes unitários.

Diante desses dois possíveis conflitos que podem acontecer durante o desenvolvimento de um produto podemos resolver com o DOR e DOD, também conhecidos como Definition of Ready e Definition of Done .Ambos servem como um acordo entre o time que deve ser visível e comum a todos os membros do time. Inclusive, se um novo integrante entrar para a equipe, ele deve ser informado a respeito dos critérios de DOR e DOD.

**DOR - Definition of Ready:** é um acordo que ocorre entre o time de desenvolvimento e o Product Owner onde ambos acordam o que é necessário para que uma estória entrar na sprint de modo que a equipe de desenvolvimento consiga desenvolve-la sem grandes problemas e que ela caiba na capacidade do time no período da sprint.

Exemplos de Definition of Ready:
* A estória deverá ter critérios de aceite detalhados
* A estória deve estar escrita seguindo o princípio INVEST
* Deve ter um wireframe de baixa fidelidade disponível e validado pelo cliente final

**DOD - Definition of Done:** também é um acordo feito com o time e Product Owner onde as expectativas alinhadas referem-se ao incremento do produto que será entregue ao final da sprint. Neste momento o Product Owner sugere o como ele espera que o entregável seja apresentado a ele ao fim do sprint.

Exemplos de Definition of Done:
* Os testes unitários devem ser feitos atingindo uma cobertura de 70% no mínimo
* A aplicação deve ser disponibilizada em ambiente de homologação
* Realizar Code Review

De modo geral, tanto o DOR quanto o DOD são acordos feitos para melhorar o fluxo de trabalho dando transparência sobre o que é necessário para iniciar uma estória e o que é necessário para finalizar um estória dentro de uma sprint.
What are the different types of GCP Certifications?
Tags: career, googlecloud, it, exams
Published: 2021-02-17 11:18:09

The Google Cloud Platform certification, or GCP certification, is the most popular certification that any professional can use to promote better positions and careers. By using GCP certification information, a job applicant gets more benefits and desires than others. Therefore, GCP is the best certificate that every student or technical professional should strive for. There are 4 levels of GCP certification that are given below

1.	Level 1 :- Associate Google Cloud Certified
2.	Level 2:- Professional Google Cloud Certified 
3.	Level 3:- G Suite Google Cloud Certified 
4.	Level 4:- Additional Certification, Google Cloud Certified

To earn the credentials of Google Cloud Certification is not an easy task, however with the help of JustCerts <a href=" https://www.justcerts.com/google-certification-exams.html"> Google Certification Exams </a> practice questions you can get success in the final Google cloud certification exams easily.
Skills Data Mining Specialists need to Master in 2021
Published: 2021-02-17 11:12:30

Here are a bunch of skills you will need if you want a career in data mining in 2021.

These articles will NOT list ALL the languages, tools, and technologies required. It's not practical. It will only list the main languages and tools that you need to get started and get your feet wet in this industry. We got these answers when we asked ourselves the question, "If we were to restart our education on Web Crawling at Proxies API, knowing what we know, what would be master". So here we go...

Basic skills:
These are table stakes that you will need to have to even begin to feel comfortable in this area.

Basic understanding of database tools like SQL, NoSQL, and Hadoop.
Intermediate-level skills in Python. This is because some of the best scrapers and crawlers are written in Python and have the biggest communities.
Master working on servers on AWS especially Amazon Linux.
Intermediary skills:
For being totally comfortable with extracting data, you will need a working knowledge of Regex, XPath and CSS selectors.

Machine Learning tools:

Get familiar with the Python NLTK library and have the ability to use Naturl Language Tools (NLP) like POS extraction, summarization, sentiment analysis, classification etc.

Understand neural networks: Tools like nn_builder which is a python package that lets you build neural networks in a single line and popular plug and play libraries like Tensorflow.



Advanced-Data mining skills:
For deep data mining projects, a mastery of the above skills and excellence in the following skills is required.

Machine learning skills

Use a specialized language like R which is designed for machine learning.

Understand and master the important machine learning algorithms like...Linear Regression, Logistic Regression, Naive Bayes classification, K-Means clustering.

Statistical Thinking Get acquainted with the basics: hypothesis testing, correlation, regression, types of scales, distributions, etc.

Visualization tools

A good part of data mining work is communicating the inferences effectively. Visualization tools like Tableu, SAS BI, R-Graphics, or even mastering Excel is absolutely invaluable.
Software Engineering : React, Azure and Graphql
Tags: react, azure, graphql
Published: 2021-02-17 10:57:42

Many times in the Software Engineering trade, we feel like we are treading water to stay afloat. The problem with this is that treading water takes too much energy and we will eventually run out of power.  Here's a few tips to make the journey more efficient. 

**Stay Laser Focused**

As web developers we owe it to ourselves to narrow our studies.  Today these are the best three to focus on.

- React or Next.js
- The cloud
- GraphQL
 
**React**

React is by far the most popular due to :
- Facebook
- Speediness 
- Easy learning curve 
- JSX 
- GraphQL
- A massive adoption with plenty of GitHub projects
-  A robust Stack Overflow community
- Plenty of jobs 

Learn everything you can about React but put emphasis on its newer feature named  Hooks. Everything in React is free! The library, videos on You tube,  Examples everywhere, and even Visual Studio Code which is a wonderful IDE for React, JavaScript and Typescript.

**Cloud**
We just learned recently that Azure has taken over AWS for Cloud revenue.  I personally prefer Azure and study it daily.  Start first learning Serverless/Microservices architecture.  Why? Because it will eventually render full blown back-end legacy architecture obsolete. There's no reason any longer to host our own back-end and call those endpoints instead of our new Cloud Function Endpoints. 

There's too many good things about the cloud.  We must stay focused on learning all we can "in the cloud".

**GraphQL**

GraphQL is an industry database disrupter.  It's a query language for JSON and JSON is the best database option for web applications.  So we are obliged to follow this trend.  Create an Apollo Server and host it as a function in Azure to see for yourself. 

Just these three items will keep us plenty busy for the next year. Start on it now, and don't look back.  Stay laser focused and motivate yourself until you are totally comfortable with these three things. 

JWP2021