teleren/devto huggingface dataset:
Association Accessors
Tags: ruby, rails, backenddevelopment, database
Published: 2023-09-30 01:56:43

## Introduction

While working with Ruby on Rails I have encountered a couple tedious things. On my first project in which I was learning Active Record query methods. I was writing a lot of these query methods in erb and couldn't help but think there was a simpler way.

## Problem

I was attempting to render names of different models linked through a join table. 

So my code looked something like:

```erb
<!-- app/views/actor/show.html.erb -->
<%@characters.each{ |character| %>
    <tr>
      <td><%= Movie.where({:id => character.movie_id})at(0).title %></td>
      <td><%= Movie.where({:id => character.movie_id})at(0).year %></td>
      <td><%= Director.where({:id => Movie.where({:id=> character.movie_id}).at(0).director_id}).a(0).name %></td>
      <td><%= character.name %></td>
      <td><a href="/movies/<%= character.movie_id%>">Show details</a></td>
    </tr>
<% } %>
```

A minimum of 30 minutes were wasted writing that loop in order to avoid typos. That is too long. Luckily, I never have to do that again because of Association Accessors.

## Solution

Association Accessors are to models like attribute accessors are to Classes. 

On the third table data tag, you can see we are trying to get the name of the director using the movie_id value given by the character. 

So we need to do two things:

1. Create a director getter inside the Movie model
2. Create a characters getter inside the Actor model

In our Movie model we need to return the director:

```ruby
# app/models/movie.rb
class Movie < ApplicationRecord
  def director
    my_director_id = self.director_id

    the_director = Director.where({:id => my_director_id}).at(0)

    return the_director
  end
end
```

Here we are creating a method that returns the director when called. So if we have the director_id we can call the method and chain the key of the value we want.

In our Actor model we need to return the Characters:

```ruby
class Actor < ApplicationRecord
  def characters
    my_actor_id = self.id

    characters = Character.where({:actor_id => my_actor_id})

    return characters
  end
end
```

We now created a method that returns the characters when called getting the id of the actor, so we can make our code more legible by using those methods.

```erb
<!-- app/views/actor/show.html.erb -->
<% @the_actor.characters.each do |a_character| %>
    <% the_movie = a_character.movie %>
    <tr>
      <td><%= the_movie.title %></td>
      <td><%= the_movie.year %></td>
      <td><%= the_movie.director.name %></td>
      <td><%= a_character.name %></td>
      <td><a href="/movies/<%= the_movie.id %>"> Show details</a></td>
    </tr>
  <% end %>
```

## Conclusion

You should be using association accessors when creating your models. They take time to create but they will save you time as your project scales.
Assignment 2
Published: 2023-09-30 01:17:20

One of the biggest and most frustrating struggles I had while working on Assignment 2 was before I had even started the assignment. I was having trouble with step 1, cloning my repository from GitHub into my desktop. After typing in the git clone command for my repository, I was prompted to input a username and password. I originally thought my GitHub account username and password would work but after some googling, I found that I needed to make create a key called a “personal access token”. It is essentially an alternative way to log in as opposed to using a password. It’s unique to my account and it can be used for accessing items on GitHub. After hours of trying to make the “personal access token”, I thought it would be best to access my professor for help with bypassing the password. After meeting with my professor, he was able to create an SSH key for me so I could clone my repository that way. Finally, I had access to my repository but there was another problem not long after.

My second major problem was also in Task 1. After adding a simple print statement into Main.java and doing “git add .” as well as a git commit, I was unable to do the final step which is git push. I kept receiving a message saying I didn’t have permission to access the repository. I thought everything was resolved after changing the access URL to SSH, but unfortunately, I was wrong. After trying many different solutions I found online with no success, I decided to contact my professor again. I was told that my remote address was incorrect, so I had to delete the one I currently had (https) and add the SSH remote address.

Next, I had a problem in Task 6 which was about recovering the file I had deleted in Task 5. I knew I had to use git revert since it was stated in the hint given to use. After going back over the slideshow shown in class, I saw I had to do “git revert <commit>”. At first, I was trying to input the command I had used to delete the file, but it just wasn’t working. I did a little more research on how to recover a deleted file, but I kept reading about “git reset”. I knew this was the incorrect way and after many different searches, I was finally able to find a detailed article about git revert. In the article, one of the instructions was using “git log” to retrieve the commit ID to use with git revert. I then realized that “<commit>” was referring to the commit ID and not the command that was used to delete the file. After completing this step, I finally fully finished Task 1.

In conclusion, since GitHub and GitKraken are all new to me, I had a lot of trouble getting started when it came to using all the different commands. With a lot of help from my professor and some additional research online as well as going back to rewatch parts of the lecture, I was able to overcome the rough start on assignment 2.
ROADMAP TO BECOMING A DATA SCIENTIST
Published: 2023-09-30 01:12:14

<u></u>


**-Learn basic fundamentals of python** (control structures, data types, syntax, functions, Object Oriented Programming and data structures).

**-Build a core of Statistics and statistical models:**(hypothesis testing, regression analysis, calculus, probability and linear algebra to help you in drawing insights and making informed decisions.

**-Data collection/scraping**(learn to collect data from relevant sources from various sources including databases, web scraping using(scrapy, Beautiful soup) and APIs.

**-Data cleaning:** Learn to clean data in order to get rid of anomalies this can be done using python libraries(numpy, pandas).Learn how to handle missing values and inconsistencies. 

**-Learn the fundamentals of SQL**(Aggregation Functions, Joins, Nested queries,
CREATE TABLE,GROUP BY, ALTER, INSERT, DELETE, DROP TABLE, ORDER BY, UPDATE).Gain proficiency in database management and working with large datasets.

**-Data visualization:** (Visualize data through chart and bar graphs in order to understand trends, variations and drive meaningful insights from the data. Gain familiarity with tools like Tableau, Power BI, and python packages(matplotlib, Seaborn).

**-Become proficient in Machine Learning:** Be well versed with different machine learning models and when they are used based on the problem and data characteristics(Linear Regression, Naive Bayes, Reinforcement Learning, Random Forest, Decision Trees, Neural Networks).This helps in training models and achieve high accuracy and precision.

**-Learn Git and version control for Augmented Analysis.**Helps in collaborating with others in doing projects and tracks the changes you make and save them.

**-Learn soft skills including communication**. Learn how to story tell about data to both technical and non-technical audiences. Be able to summarize the findings in a clear and understandable manner and provide recommendations and insights based on the insights.
SDXL DreamBooth vs LoRA — Comparison
Tags: sdxl, ai, drembooth, lora
Published: 2023-09-30 00:54:38

It is commonly asked to me that is Stable Diffusion XL (SDXL) DreamBooth better than SDXL LoRA?

Here same prompt comparisons. Not cherry picked. Look prompts and see how well each one following

1st DreamBooth vs 2nd LoRA

3rd DreamBooth vs 3th LoRA

Raw output, ADetailer not used, 1024x1024, 20 steps, DPM++ 2M SDE Karras

Same training dataset

DreamBooth : 24 GB settings, uses around 17 GB

LoRA : 12 GB settings - 32 Rank, uses less than 12 GB

Hopefully full DreamBooth tutorial coming soon to the SECourses YouTube channel.

https://www.youtube.com/SECourses

Experiments (66 full fine tuning), workflow and config files already shared on Patreon.

https://www.patreon.com/posts/very-best-for-of-89213064

Also I am about to publish amazing prompting list for self trained models. Stay tuned and subscribed.



1st Prompt

ohwx man (masterpiece:1.5), (close-up shot:1.8), (extremely intricate:1.2), 8k, highly detailed, A delicate pencil sketch of a ohwx man with flowing hair cascading down his shoulders. The sketch captures the man's serene expression,

no negatives



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

 

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



2nd Prompt

portrait photo of (ohwx man:1.1) wearing an expensive Brown suit, white background, fit



(blue eyes, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime:1.4), fat, text, cropped, out of frame, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7cf5jvyifb7bpmpc1n3k.jpg)


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

Conclusions: DreamBooth quality is much more superior in terms of realism and also generalization thus styling.
My Hacktoberfest Pledge
Tags: hacktoberfest23, opensource, 100daysofoss
Published: 2023-09-30 00:46:52

---
title: My Hacktoberfest Pledge
published: true
tags: #hacktoberfest23 #opensource #100daysofoss 
---

![Logo for Hacktoberfest'23](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4rr3iwgb49frfxo1r1ep.jpeg)




### About Me
Hi there! I'm Chrissy, a lover of open source, technical writing, and the Oxford Comma! :) I also moderate and review the content here on Dev.to, so if you see a heart emoji, that's from me! ;) 

### Background

This year will be my first time doing Hacktoberfest! :) I've been contributing to open source projects for a couple of months now and decided to participate in this event after seeing so many posts about it on X and a couple of coding communities I belong to. If you want to learn more about my journey, check out my posts on [Hashnode](https://chrissycodes.hashnode.dev/)

### Pledge


As a contributor, my goal for Hacktoberefest is to have fun and find interesting projects. As a maintainer for [LinksHub](https://github.com/rupali-codes/LinksHub) and a Triage team member at [OpenSauced](https://github.com/open-sauced), I want to work on ways to make new contributors feel less intimidated about open source projects.
working on my github repository to practice multiple changes in a single project
Published: 2023-09-30 00:41:55


 
In this blog post, I am going to discuss working on my github repository to practice multiple changes in a single project.
Following is the repository link I worked on:
https://github.com/alikhan1998/fragments
• Step1: Pick your Features
In this step, I picked following 2 features from a list of provided features:
1- Make sure that program exits with proper error codes.
2- Add support for inline code blocks.
• Step2: Create topic branches:
In github, we have a main (default) branch in which all code is written and all changes also show in same branch. While working on creating issues, I create separate topic branches for each issue:
1- issue1 for feature 1
2- issue2 for feature 2
These branches are made so that the implementation of these features remains separate from main branch and we merge it with main branch when we need it.
• Step3: Implement your features:
I worked on these features in their respective branches.
For appropriate error code feature, I modified the code to exit with appropriate error in all cases considered. If there is no error, code exits with 0. Else, it exits with -1.
For the inline code block feature, I added a new regular expression to the Markdown parser and modified the code to render inline code blocks as HTML.
• Step4: Merge first feature branch:
After completing first branch i.e. issue1, we have to merge it with main branch. For this purpose, we can use 2 ways. Either I use the commands given to us in command prompt or I merge branch directly by opening the branch and click on merge button. I use the second way.
• Step5: Merge second feature branch:
Similarly, after completing second feature branch i.e. issue2, I have to merge it. Same 2 ways as described above are present and I merged this branch by opening it and clicking merge button.
• Step6: Push main branch to github:
After merging branches, I have to push my main branch to github. For this purpose, I used the following cmd command
$git push origin main
• Step7: Close issues:
After pushing main branch, I closed both issues by clicking on them one by one and clicking close issue button. I add the desired comment also on closing.
• Conclusion:
Working on multiple changes in a single project can be challenging, but it is an important skill to have as a software developer. By using topic branches and following a structured workflow, I was able to successfully implement two features in my GitHub repository.
I learned a lot during this process, including how to:
o Create topic branches to isolate changes and make it easier to merge
o Implement features in isolation without affecting the main codebase
o Merge branches and resolve merge conflicts
o Push changes to GitHub and close issues
I am confident that I can apply these skills to future projects to develop and deliver high-quality software.
A React component library for animating elements as they enter the viewport
Tags: animation
Published: 2023-10-03 18:56:40

---
title: A React component library for animating elements as they enter the viewport
published: true
date: 2023-09-30 00:32:00 UTC
tags: Animation
canonical_url: https://reactjsexample.com/a-react-component-library-for-animating-elements-as-they-enter-the-viewport/
---

# react-swift-reveal
 ![A React component library for animating elements as they enter the viewport](https://reactjsexample.com/content/images/2023/09/Code_2023-09_11-26-48.jpg)

React-swiftReveal is a React component library and animation framework for animating elements as they enter the viewport.

for more, check the [documentation](https://react-swift-reveal.vercel.app/)

## Installation

with npm:

```
npm install react-swift-reveal
```

with yarn:

```
yarn add react-swift-reveal
```

with pnpm:

```
pnpm add react-swift-reveal
```

## Usage

```
import { Fade } from "react-swift-reveal";

const App = () => {
  return (
    <Fade>
      <h1>hello world</h1>
    </Fade>
  );
};
```

or

```
import { Fade } from "react-swift-reveal";

const App = () => {
  return (
    <Fade>
      <MyComponent /> //component to be animated
    </Fade>
  );
};
```

both examples will fade in the element as it enters the viewport.

## Available Animations

- Fade
- Bounce
- Slide
- Zoom
- Flip
- Rotate
- Roll
- LightSpeed

## Simple animations

- Flash
- Jello
- Pulse
- RubberBand
- Shake
- Swing
- Tada
- Wobble
- HeadShake
- Pop
- Spin
- Jump

# Support

If you like this project, please consider supporting it by giving it a star.

## GitHub

[View Github](https://github.com/Mutesa-Cedric/react-swift-reveal?ref=reactjsexample.com)
Implementing new features to till tool
Published: 2023-09-30 00:19:52

Hello Everyone,
I have updated my till-tool project and added new features to enhance the user experience. 

1. Add an optional -l, --lang flag
This feature allows to change the language attribute of an HTML page by adding -l or --lang on the command terminal along with run command, if the user wish to change language to French then they can run the following command to change html page language to French.

```
node src/index.js process src/till-1.txt -o example -l fr
```

2. Exit with valid error codes.
This feature is implemented to allow program for exit with valid error code, If there are no errors, exit with 0. Otherwise it exit with a non-zero exit code (e.g., -1).
So upon successful compilation of code it will exit with 0 and if there is any error it will display with non zero number which will eventually help programmer to rectify and solve the error much properly.

Finally with these feature it is more user friendly and I learned how to do branch merging and better integration after adding new features.
The Steps Framework: Solve Any Problem
Tags: programming, developer, design, beginners
Published: 2023-09-30 00:16:39

Start with the first step you need to accomplish to solve the problem and then repeat in order until the problem is solved.

1. What do you need?
2. How much does it cost?
3. Where do you get it?
4. How do you implement it in this system?
5. Does it help you get closer to the solved problem?
6. If not, Turn the unknown into a question and get it answered.
7. Repeat for the next step.

Once your problem is solved, revisit the framework and ask yourself if you can eliminate any steps or find better ways to accomplish a step. When you do so, use the Steps Framework to hone your solution.
Top 5 form validation libraries in React JS and Next JS
Tags: formik, react, nextjs, yup
Published: 2023-09-30 00:11:32

1. **Formik**
is a widely used library for building forms in React, next, and Vuejs as well. It includes a built-in form validation system that is easy to use and integrates well with React components. Formik provides a high level of flexibility and customization.

GitHub Repository: https://github.com/formium/formik)
Installation: 
```
npm i formik
yarn add formik
```


2. **React Hook Form**
is another popular library for building forms in React. It focuses on providing a simple and efficient way to manage form state and validation using React hooks.

GitHub Repository: https://github.com/react-hook-form/react-hook-form

Installation: 
```
npm i react-hook-form
yarn add react-hook-form
```

3. **Final Form**
is a form state management and validation library for React. It emphasizes performance and flexibility and provides a wide range of plugins for additional functionality.

GitHub Repository: [](https://github.com/final-form/final-form)

Installation: 
```
npm i final-form
yarn add final-form
```

4. **Redux Form**
If you're already using Redux in your React application, Redux Form can be a good choice. It integrates well with Redux to manage form state and validation.

GitHub Repository: [](https://github.com/erikras/redux-form)

Installation: 
```
npm i redux-form
yarn add redux-form
```


5. **Yup**
While not a form library itself, Yup is a schema validation library that works seamlessly with Formik and other form libraries. You can define your validation schema with Yup and use it to validate form inputs.

GitHub Repository: [](https://github.com/jquense/yup)

Installation: 
```
npm i npm i yup
yarn add npm i yup
```
A Desktop application, for streaming and downloading your favourite anime
Tags: desktop, streaming
Published: 2023-10-03 18:56:51

---
title: A Desktop application, for streaming and downloading your favourite anime
published: true
date: 2023-09-30 00:10:00 UTC
tags: Desktop,Streaming
canonical_url: https://reactjsexample.com/a-desktop-application-for-streaming-and-downloading-your-favourite-anime/
---

# Jennie – Anime player

> ![A Desktop application, for streaming and downloading your favourite anime](https://reactjsexample.com/content/images/2023/09/Code_2023-09_18-05-51.jpg)
> 
> A Desktop application, for streaming and downloading your favourite anime.

## 🚀 Features

- A User Friendly Interface
- Download anime from [supported websites](#-supported-websites) in multiple resolutions and languages
- Batch Download
- Stream anime on the inbuilt player and your favourite [external video player](#-supported-external-players)
- Explore anime based on different [filters](#filters)
- Download Manager
- Library to view pre-downloaded episodes and active downloads
- Recommendation System

## Dependencies

- [ffmpeg](https://ffmpeg.org/download.html)

## 📖 Installation

### Building From Source

- Clone the project using

#### Prerequisites

- Make sure python 3.10 and node 18 are installed.

#### Installing

1. Create and activate the virtual environment

2. Install the dependencies using the `requirements.txt` and `build_requirements.txt` files.

3. Create `.env` & paste the following content

4. Install Node modules

5. Add `ffmpeg` executable to `root folder` or in `PATH` Var.

6. run package using

7. Build package using

Note:

> Make sure to allow app to run as admin and allow incomming port forwarding on (`6969`, `9000`).

### Environment Tested on

- Tested on Windows 8, 10 & 11.

## 😁 Demo

![A Desktop application, for streaming and downloading your favourite anime](https://user-images.githubusercontent.com/83329806/270330410-4233126c-047a-45d9-a1a5-98bc2b2969bb.png) ![A Desktop application, for streaming and downloading your favourite anime](https://user-images.githubusercontent.com/83329806/270330407-d99a006d-8f15-4baa-94c4-c1178e852dc0.png) ![A Desktop application, for streaming and downloading your favourite anime](https://user-images.githubusercontent.com/83329806/270330399-6469bfc9-b3d0-42ad-bf7d-c8b98d338f08.png) ![A Desktop application, for streaming and downloading your favourite anime](https://user-images.githubusercontent.com/83329806/270330377-d3a31367-097c-4eba-8224-c5c91b7821cb.png)

## DISCLAIMER

This software has been developed just to improve users experience while streaming and downloading anime. Please support original content creators!

## GitHub

[View Github](https://github.com/developerrahulofficial/jennie-anime-player?ref=reactjsexample.com)