teleren/devto huggingface dataset:
Rails generators
Published: 2022-05-23 14:16:20

Rails comes with many helpful ways to speedup backend development. One really convenient tool are generators.

Generators are used to quickly create your backend structure by taking care of repetitive code, allowing you to focus on the more unique aspects of your application. 

There are several different things able to be created with rails generate, the most common ones you might encounter are: 
```
rails generate

controller
migration
model
resource
scaffold
serializer
```

###Model
`rails g model <model_name>` creates a migration file, including any column names for your table if passed as an argument. 
E.g. `rails g model Pen brand color price:integer` would create the following migration file:
```
# 20220507194429_create_pens.rb

class CreatePens < ActiveRecord::Migration[6.1]
  def change
    create_table :pens do |t|
      t.string :brand
      t.string :color
      t.integer :price

      t.timestamps
    end
  end
end
```
model file:
```
# pen.rb

class Pen < ApplicationRecord
end
```
and spec file:
```
# pen_spec.rb

require 'rails_helper'

RSpec.describe Pen, type: :model do
  pending "add some examples to (or delete) #{__FILE__}"
end
```
##Resource
`rails g resource Pen brand color price:integer` will create all of the above files, along with a serializer:
```
# pen_serializer.rb

class PenSerializer < ActiveModel::Serializer
  attributes :id, :brand, :color, :price
end
```
controller:
```
# pens_controller.rb

class PensController < ApplicationController
end
```
your routes:
```
# routes.rb

Rails.application.routes.draw do
  resources :pens
end
```
and some additional specs.

##Scaffold
`rails g scaffold Pen brand color price:integer` creates all of the above, but adds full CRUD capability for your controller:
```
# pens_controller.rb

class PensController < ApplicationController
  before_action :set_pen, only: [:show, :update, :destroy]

  # GET /pens
  def index
    @pens = Pen.all

    render json: @pens
  end

  # GET /pens/1
  def show
    render json: @pen
  end

  # POST /pens
  def create
    @pen = Pen.new(pen_params)

    if @pen.save
      render json: @pen, status: :created, location: @pen
    else
      render json: @pen.errors, status: :unprocessable_entity
    end
  end

  # PATCH/PUT /pens/1
  def update
    if @pen.update(pen_params)
      render json: @pen
    else
      render json: @pen.errors, status: :unprocessable_entity
    end
  end

  # DELETE /pens/1
  def destroy
    @pen.destroy
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_pen
      @pen = Pen.find(params[:id])
    end

    # Only allow a list of trusted parameters through.
    def pen_params
      params.require(:pen).permit(:brand, :color, :price)
    end
end
```
and more spec files.

Of course it's important to know how all of this code works, and why. However, once you've worked on a few rails projects, generators are a great way to quickly and painlessly create the basic framework for most applications.
Moving Background using CSS
Published: 2022-05-23 14:16:13

A moving background is a really simple way to spice up your website. It is also surprisingly simple to do.

HTML:
```
    <div id="background">
      <div id="effect"></div>
    </div>
```
Here are our two divs that will contain our static background image, and our moving overlay for that image. Note that you can have any number of these divs, moving or not.

CSS:

```
#background {
  background-image: url("../public/transport1_touchup.png");
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: cover;
  width: 100%;
  height: 100vh;
  z-index: -200;
}

#effect {
  position: absolute;
  background-image: url("../public/transport1_effects.png");
  width: 200vw;
  height: 100vh;
  animation: slide 20s ease-in-out infinite;
}

@keyframes slide {
  0%,
  100% {
    transform: translate(0px);
  }
  50% {
    transform: translate(-25vw);
  }
}
```
This is our css for our two divs, as well as the keyframes for our slide animation. For this particular effect, I needed to make sure the overlay effect was much wider than the background image, yours may be different depending on your needs.

In some circumstances, it might make more sense to turn your effect into a repeating video or gif, and both have their pros and cons.

I hope this post was helpful, go get creating!
How to call SOAP Services using REST
Tags: soap, rest, api, apidevelopment
Published: 2022-06-22 11:09:06

---
title: How to call SOAP Services using REST
published: true
date: 2022-05-23 14:12:50 UTC
tags: SOAP,REST,API,APIdevelopment
canonical_url: https://linx.software/soap-to-rest/
---


SOAP, being a mature technology, has an extensive and often differently interpreted standard set. This makes it an excellent tool for corporate users to manipulate data into their precise requirements and technology stack. However, for public consumption, this causes issues that sometimes are difficult or impossible to solve without changing code.  A good example here is that SOAP is allowed to define the same type in some standard interpretations in different XSD files. However, when trying to use this in other interpreters, it will most likely crash.

To solve this, we need to look at SOAP a little bit deeper. In essence, SOAP, as a technology, is simply a Web (or HTTP) POST call with a specifically formatted XML payload, which the SOAP server is expecting and understands. It then returns a specifically formatted XML response which the client then can parse and use.

You might be saying, ‘Hey, that sounds very much like a REST call,’ but that is exactly what it is. Instead of an API reference, which gives you the Request and Response formats and requirements, SOAP publishes a WSDL. So if you’ve got one of these SOAP Services which breaks standards, if you can get the text of a successful Request, you can use REST to make the call with that request body. 

Below is how to implement this technology in Linx, a low-code platform for backends.

Background - https://linx.software/soap-to-rest/
Linx solution - https://community.linx.software/community/uploads/short-url/nN1SP5FaN36GUZY9aPCjNbnh7SL.lsoz
The Boy Scout Rule 💡👩‍💻
Published: 2022-05-23 14:06:27

#### This post is going to be a little different.

---

> Most engineers have heard of the 'boy-scout rule': 'Always leave the code better than you found it.' It's often been heralded as a magic cure for technical debt; if only all software engineers behaved like good citizens, our software wouldn't deteriorate so relentlessly.

---

A small snippet from an office talk describing impact of it on real projects:
{% embed https://www.linkedin.com/posts/sameerkumar1612_sameer-on-coding-standards-activity-6934497182557315072-NcIC?utm_source=linkedin_share&utm_medium=member_desktop_web %}

---

Audio snippet:
{% embed https://twitter.com/tarkalabs/status/1528731583473065985?s=20&t=MAC5AUIXinFzidF6wFozYA %}

---

What you think about conscious negligence and voluntarily clearing technical debt left by previous engineers?

---

Quote referred from: [Here](https://www.stepsize.com/blog/how-to-be-an-effective-boy-girl-scout-engineer#:~:text=Most%20engineers%20have%20heard%20of,wouldn't%20deteriorate%20so%20relentlessly.)

---
## To Connect
🏭 LinkedIn: https://www.linkedin.com/in/sameerkumar1612
✍️ Medium: https://sameer-kumar-1612.medium.com
✍️ Dev.to: https://dev.to/sameer1612
Scope
Published: 2022-05-23 14:05:49

**Scope** is what we can access and where we can access it. It is the concept of where something is available.

Through the **scope chain**, a function has access to all variables and functions declared in its **outer scope**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uv2wguudjgflyq43jqfr.png)

## 3 levels of scope

## Global
- Accessible in every scope
- Outermost scope

## Functional
- Accessible within a function
- If you have 2 functions, they have their own unique scopes. You can't access the same items from each other's boxes. 
- Specific to a single function
- Can't be accessed by anything in outer scopes
- Every function creates its own scope, and any variables or functions you declare inside of the function will not be available outside of it.

## Block
- Accessible within a block
- Specific blocks
- Can't be accessed by anything in outer scopes
- Variables declared with _var_ are not block scoped. Variables declared with _const_ and _let_ are block scoped.

## Lexical Scope
- Can access variables in outer scope
- Can't access variable in nested scope


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/41v2zlcdv70uahrm8yc1.png)

Cannot access variables in parent scope. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ke9mlv4npiq6qiqkeuns.png)
O que levar para viagem?
Tags: javascript, beginners, braziliandevs, career
Published: 2022-05-23 14:04:53

1 ano e 2 meses me preparando para essa viagem.

Consegui transicionar de carreira e hoje posso dizer que sou um desenvolvedor profissional.

Apesar de curta, mas a frase anterior possui muitos pontos para conversar, porém hoje vou tratar apenas sobre essa viagem para a programação.

O caminho não foi fácil, mas também não foi o pior de todos como muitos dizem por aí; mas dentre todos os pontos no qual podia mencionar aqui, o que eu quero mais ressaltar é a importância de arrumar bem sua bagagem.

O que eu devo levar na primeira viagem?

Essa já posso responder…

Uma bagagem bem arrumada.

Se você souber exatamente o que nem na sua mala, a chegada no novo destino vai ser muito mais segura. 

Você acaba de chegar em um local novo, não sabe para onde ir, com quem falar, o que usar, mas na primeira oportunidade de poder atuar, você vai tirar algo da sua mala que pode contribuir. 

Isso fará toda a diferença.

Agora voltando para a realidade; a sua mala é a base do seu conhecimento. 

Eu trabalho com Javascript, portanto, entender sobre métodos, funções, herança e etc, foi a melhor maneira de arrumar a minha bagagem.

E sim, isso faz toda a diferença.

Estude a base, prepare bem sua bagagem e você sempre estará seguro, em qualquer lugar, em qualquer viagem.
Changelog #0016 — ℹ️ OPTIONS method, 🔑 param auth, Terminal 3.2, and more
Published: 2022-05-23 13:58:58

---
title: Changelog #0016 — ℹ️ OPTIONS method, 🔑 param auth, Terminal 3.2, and more
published: true
description: OPTIONS method, API key auth through parameters, HTTPie for Terminal 3.2, UI improvements, bug fixes, and more.
cover_image: https://httpie.io/Images/Share/blog-changelog-0016.png
canonical_url: https://httpie.io/blog/changelog-0016
---

## HTTPie for Web & Desktop

### ℹ️ OPTIONS method

One more option in the method select — 🥁 — `OPTIONS`!

![Options HTTP method](https://httpie.io/_next/image?url=%2FBlog%2Fchangelog-0016%2Foptions-http-method-TSAIZRWU.png&w=3840&q=95)

You can use `OPTIONS` to [request information](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS) about the communication options available on a given URL or server.


### 🔑 API key auth through parameters

We [recently](https://httpie.io/blog/changelog-0014) introduced a way to authenticate requests using a custom API key header. Now we’re expanding this auth type with the option to send the API key as a URL parameter:

![API key via a URL_parameter](https://httpie.io/_next/image?url=%2FBlog%2Fchangelog-0016%2Fapi-key-param-5RFHEUAM.png&w=3840&q=95)

This allows you to specify your auth at the collection level and have HTTPie add it to the URL automatically.

### ✍🏻 Font improvements

As with everything else, we [continue to improve](https://httpie.io/blog/changelog-0014) the monospace variant of our font, and this time we focused on making the `0` and `O` characters more distinct:

![Monospace font used by HTTPie with improved 0 characters](https://httpie.io/_next/image?url=%2FBlog%2Fchangelog-0016%2Fmonospace-zero2-52BHC7A4.png&w=3840&q=95)

### 🪲 Bug fixes
- You probably didn’t encounter this, but if you typed fast while having multiple HTTPie browser tabs, the text would start flashing. Fixed!
- Some generated headers (e.g., `Content-Type`) weren’t displayed in some preview formats. Now they are.
- Inherited auth was also missing from the preview in some cases.
- Draft requests created via the global `+` button could lose their name.
- Fixed an app crash in case of invisible characters in the URL.

## HTTPie for Terminal

HTTPie for Terminal 3.2 is now available 🎉 This version introduces:

- 💅 Refined UI
- 📖 Man pages
- 📦 Single binary executables
- 🌀 Debian releases
- ⬆️ Update warnings
- 🤩 And more

We have a separate post covering this release, check it out 👇

[What’s new in HTTPie for Terminal 3.2 →](https://httpie.io/blog/httpie-3.2.0)
## Happy testing, and see you next week!

But in the meantime…

- 💁🏻‍♀️ If you’re not on the private beta yet, you can [join the waitlist here](https://httpie.io/beta).
- 👉 You can also follow [@httpie](https://twitter.com/httpie) and join our [Discord community](https://httpie.io/discord).
- 👩‍💻 We’re looking for new colleagues in [engineering and design roles](https://httpie.io/jobs).

---

Originally published on [HTTPie blog](https://httpie.io/blog/changelog-0016).
Day 14&15/100, complete
Tags: webdev, beginners, programming, 100daysofcode
Published: 2022-05-23 13:35:55

I was able to complete 14&15th day(Saturday and Sunday 5/22/22) of coding/programming. 

At first I started studying the following weeks lesson on CS50 course. I realized it was super late and I didn’t want to stay up until the sun came up watching a lecture and then ALSO spending another hour on coding. 

What I did instead was stop CS50 and hop on #freecodecamp.org and started the first course on there, which was HTML building a Cat photo app. 

It was super fun and simple and I was able to actively code in that time as I was learning. Definitely was a breeze compared to the very challenging and frustrating CS50 environment. [](freecodecamp.org)
Position props.children in an unique way
Tags: react, nextjs, webdev
Published: 2022-05-23 13:23:24

Recently I faced an interesting issue. I was asked if there's any way to position each children element passed into a children component via wrapping these elements/components using a component. The syntax of the question is as follows,

Let's assume we have a modal component. So, it will be like,

## Fig: 1
```jsx
<Modal>
  <Header />
  <Body />
  <Footer />
</Modal>
```

Now, the expected output should look similar to this codes' output,
(inside modal component)

## Fig: 2
```jsx
<div>
 <header>
  <Header />
 </header>
 <main>
  <Body />
 </main>
 <footer>
  <Footer />
 </footer>
</div>
```

Now, here's how I solved the issue,
I did not know how to solve it as I had no experience such like this. But I thought that if I could select them via the index, I could do so. So I spun up a Next.js application and tested my theory later on. And voila! I was right. You can achieve the same output (similar to the [Fig: 2](##fig2)) as shown here,

## Fig: 3
```jsx
const Modal = ({children}) => {

 return (
   <div>
    <header>
     { children[0] }
    </header>
    <main>
     { children[1] }
    </main>
    <footer>
     { children[2] }
    </footer>
  </div>
 )
}
```

similarly:
```jsx
const Modal = ({children}) => {
/**
* @desc assigning each array element to a variable;
*/
 const [header, body, footer] = children;

 return (
   <div>
    <header>
     { header }
    </header>
    <main>
     { body }
    </main>
    <footer>
     { footer }
    </footer>
  </div>
 )
}
```   

Maybe, it's not the best way to pass an element or achieve such output. But it's an unique way and you never know, there might be an use-case for this. Here's an working demo: [Click here!](https://replit.com/@SajjatHossain/propschildren#pages/index.jsx)
Youtube/Twitch like hovering video player,keeps playing across pages
Tags: intertiajs, javascript, laravel, videojs
Published: 2022-05-23 13:18:43


Problem: How to play a video across different pages of the Website. Similar to how youtube player keeps playing



Solution: Use vue with interiajs [credit](https://laracasts.com/discuss/channels/code-review/keep-video-playing-while-switching-pages-inertiavuelaravel), 


interiajs has persistent layout, [persistent-layouts](https://inertiajs.com/pages#persistent-layouts)

{% embed https://vimeo.com/712855628 %}

Note: this uses laravel 8+

Github code: [Click here](https://github.com/sahilkashyap64/videoplayer-on-different-pages)
Vertical align with a full screen across Tailwind CSS
Tags: jetthoughts, css, tilewind, webdev
Published: 2022-05-23 12:58:44

How can vertically align an element with Tailwind CSS by Flex?
 
## Justify-Center and Items-Center

- `flex` : To use a flex-div as a container.
- `h-screen` : To size the container height to the viewport height.
- `justify-center` : To justify center (horizontal center).
- `items-center` : To align the items to the center (vertical center).

```html
<div class="flex h-screen items-center justify-center">
  <h1>Title</h1>
</div>
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g8oeati6etcsm4r4fytf.png)
 
This is already pretty well documented in the [Tailwind CSS](https://tailwindcss.com/docs/align-items#center) docs.

## Another way to use Flex for to align items

In this case need to set `margin: auto` to wrapper of children element.

```html
<div class="flex h-screen">
  <div class="m-auto">
    <h1>Title</h1>
  </div>
</div>
```
I just finished reading "Customizing ASP.NET Core 6.0" and this is my review
Tags: books, review
Published: 2022-05-23 12:57:33

A few weeks ago I had the chance to read the this book (gifted by the author).
I would like to share with you my feelings.

## The author
Jürgen Gutsch is a software developer based in Basel and he is also the lead of the .NET user group in Basel.
This is not his first book and maybe you know his blog [http://asp.net-hacker.rocks](http://asp.net-hacker.rocks) because it's very well indexed by google and if you are googling something related to .NET, maybe you found some of his articles. 🙂

![Customizing ASP.NET Core 6.0 book cover](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9m696q53a3cld0jpl0dc.png)
 
## Summary
> ASP.NET Core comes packed full of hidden features for building sophisticated web applications. You'd be missing out on a lot of its capabilities by not customizing it to work for your applications. With Customizing ASP.NET Core 6.0, you'll discover techniques to help you get the most out of the framework to deliver robust applications.

I think this description on the [Amazon page](https://www.amazon.com/Customizing-ASP-NET-Core-6-0-applications-dp-1803233605/dp/1803233605) is perfect to describe the book and its content.
Chapter by chapter a fundamental concept is explained for a middle/senior developer.
The chapter helps the reader to understand some advanced topics for ASP.NET Core 6.0.

This is the table of contents:
- Customizing Logging
- Customizing App Configuration
- Customizing Dependency Injection
- Configuring and Customizing HTTPS with Kestrel
- Configuring WebHostBuilder
- Using Different Hosting Models
- Using IHostedService and BackgroundService
- Writing Custom Middleware
- Working with Endpoint Routing
- Customizing ASP.NET Core Identity
- Configuring Identity Management
- Content Negotiation Using a Custom OutputFormatter
- Managing Inputs with Custom ModelBinder
- Creating a Custom ActionFilter
- Working with Caches
- Creating Custom TagHelper

## My evaluation
I can only recommend reading this book, and it is definitely a useful book to keep on your desk because it can always be useful during the development of a project.

## Conclusion
You can find this book directly on the Pack website [here](https://www.packtpub.com/product/customizing-asp-net-core-6-0-second-edition/9781803233604) or on Amazon [here](https://www.amazon.com/Customizing-ASP-NET-Core-6-0-applications-dp-1803233605/dp/1803233605)
Unutulan Root Şifresini Sıfırlama (Ubuntu)
Tags: resetpassword, linux, ubuntu, kernel
Published: 2022-05-23 12:53:03

Bu yazımda şifresini unuttuğumuz ve erişemediğimiz root kullanıcısının veya herhangi bir kullanıcının şifresini bilgisayarı sıfırlamadan ve verileri kaybetmeden nasıl değiştiririz ondan bahsedeceğim.

**1. İlk olarak Ubuntuyu 'Recovery Mode' da başlatıyoruz.**

Bunun için yapmamız gereken şey bilgisayarı yeniden başlatmak ve açılırken ***Shift*** tuşuna arka arkaya basarak **Grub** ekranına gelmek. Aşağıdaki ekranı gördükten sonra **'e'** tuşuna basarak grub panelini açıyoruz.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8x4w2grtek3fjwu5xmie.png)

**2. Grub Ekranında Gerekli Konfigürasyonları Yapıyoruz**

İlk olarak şuna benzer bir ekran karşımıza çıkıyor.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6q3st1d7bwgek5we2k7z.png)
  
------

Aşağıda görüldüğü gibi değiştiriyoruz. `ro quiet splash $vt_handoff` yazan yere `rw quiet init=/bin/sh` yazıyoruz. 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kztn7i34w9d2ye95h099.png)

**3. Yaptığımız Değişiklikleri Kaydediyoruz**
**ctrl-x** basarak değişiklikleri kaydedip önyükleme yapıyoruz. Artık Linux çekirdeğine hem okuma hem yazma yetkimiz var.

**4. passwd Komutuyla Şifre Değiştirme**
Artık `passwd username` yazarak şifesini unuttuğumuz kullanıcının şifresini değiştirerek hesaba erişim sağlayacağız. Ardından şu komutlarla makineyi yeniden başlatabiliriz.

```
reboot
```

ya da

```
shutdown -r now
```
Create custom fetch hook in react
Tags: customhook, react
Published: 2022-05-23 12:44:35

---
title: Create custom fetch hook in react
published: true
description: reate custom fetch hook in react
tags: customhook, reactjs
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kvj3zl2xgpeje2idiv0g.png
---
## Custom hook useFetch

```Javascript 
import { useState, useEffect } from 'react';

const useFetch = (url, initialValue) => {
    const [data, setData] = useState(initialValue);
    const [error, setError] = useState(null);
    const [loading, setLoading] = useState(true);

    useEffect(() => {
        (async () => {
            try {
                const res = await fetch(url);
                const resJson = await res.json();
                setData(resJson);
            } catch (err) {
                setError(err);
            } finally {
                setLoading(false);
            }
        })();
    }, [url]);
    return { loading, data, error };
};

export default useFetch;
```
### usage
```Javascript
import useFetch from "./useFetch";
const { data, loading, error } = useFetch('https://jsonplaceholder.typicode.com/todos', []);
```