teleren/devto huggingface dataset:
How to Setup RSpec on a Rails Project
Tags: rails, ruby, rspec, testing
Published: 2023-11-30 06:28:11

At the time of writing this article using ruby 3.2.0 & Rails 7.1.2

Let's get started...

## 1. Create a new project

```
rails new rspec-test-app -d postgresql
cd rspec-test-app
rails db:create
rails s
```

## 2. Install gems

```ruby
group :development, :test do
  gem 'rspec-rails', '~> 6.1.0'
  gem 'factory_bot_rails'
  gem 'faker'
end
```

## 3. Run below commands

```
bundle install
rails g rspec:install
```

## 4. Configure factory bot
Create spec/support/factory_bot.rb file then copy & paste below code

```ruby
# spec/support/factory_bot.rb
require 'rails_helper'

RSpec.configure do |config|
    config.include FactoryBot::Syntax::Methods
end

```
Almost done. Now generate the user model

```
rails generate model User email:string password:string
rails db:migrate
```

It will generate following files for us:

```
invoke  active_record
create  db/migrate/20231130055533_create_users.rb
create  app/models/user.rb
invoke  rspec
create  spec/models/user_spec.rb
invoke  factory_bot
create  spec/factories/users.rb
```
Now run the below command and the watch the output
`rspec`

```
*

Pending: (Failures listed here are expected and do not affect your suite's status)

  1) User add some examples to (or delete) /home/spritle/p/rspec-test-app/spec/models/user_spec.rb
     # Not yet implemented
     # ./spec/models/user_spec.rb:4


Finished in 0.00287 seconds (files took 0.64832 seconds to load)
1 example, 0 failures, 1 pending
```
**_To know more:_**

[rspec-rails](https://github.com/rspec/rspec-rails)
[factory_bot_rails](https://github.com/thoughtbot/factory_bot_rails)
[faker](https://github.com/faker-ruby/faker)

![It's done](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/subs132o7v7h82k3dbv5.png)

I hope this helps you to start your journey on rspec 🚀. Thanks for reading!
Opensource adblocker for chrome
Tags: adblocker, chrome, extensions, opensource
Published: 2023-11-30 06:27:25

Pls checkout this opensource adblocker for chrome.

https://chromewebstore.google.com/detail/no-ads/nhoimkephmfpfakaopdjheigigmfefge?pli=1

github repo:
https://github.com/piyuesh-dev/adblocker
The Professional Advantages of Online Class Assistance
Tags: onlineclass, classhelp
Published: 2023-11-30 06:18:41



In the dynamic realm of Academia Central, Alex, a dedicated student, found himself navigating a demanding academic landscape. Striving for excellence, Alex discovered the instrumental benefits of "Online Class Assistance"—a service designed not only to streamline coursework but also to elevate the overall learning experience.

Foremost among the advantages was the impeccable time management facilitated by [Do my class](https://domyclassesnow.com/online-class-help.php). Balancing multiple courses and extracurricular commitments, Alex appreciated the efficiency of this service. Timely completion of assignments to the highest standards allowed Alex to strategically allocate time, fostering a deeper understanding of academic subjects.

The personalized expertise provided by online class assistants emerged as a pivotal aspect of Alex's academic journey. Each assistant, well-versed in their respective fields, not only guided through assignments but also offered valuable insights that enhanced Alex's comprehension of complex topics. This professional collaboration transcended traditional tutoring, evolving into a mentorship that enriched Alex's academic pursuits.

Flexibility became a hallmark feature, particularly beneficial in the fast-paced environment of Academia Central. Online class assistance allowed Alex to attend virtual classes and submit assignments within flexible timelines, accommodating individual learning preferences and seamlessly integrating education with daily life demands.

The positive impact on academic performance was undeniable, with marked improvements in Alex's grades. Online class assistance wasn't merely a support service—it functioned as a catalyst for achieving excellence. The synergy between Alex's commitment to success and the professional guidance received reflected in tangible academic accomplishments.

Moreover, the collaboration extended beyond assignment completion. Alex actively participated in insightful discussions, received constructive feedback, and gained additional resources, transforming the learning experience into a dynamic and engaging process. Online class assistance evolved into a personalized educational forum that enhanced traditional learning models.

As Alex's educational journey progressed in Academia Central, the advantages of online class assistance played a pivotal role in shaping a focused, efficient, and enriched learning experience. In this city of continual learning, the service provided not just assistance but a strategic pathway to academic empowerment and success. The professional benefits of time efficiency, personalized expertise, flexibility, enhanced academic performance, and collaborative learning converged to redefine Alex's narrative—an inspiring story of educational optimization in the heart of Academia Central.
Thread safe collection class
Published: 2023-11-30 05:59:43

Blocking: Based on locks, through blocking
CopyOnWrite: modification overhead is high
Containers of Concurrent type:
Through cas optimization, high throughput
Weak consistency: When traversing, even if the container is modified, the iterator can continue to traverse, and the content is old
Seek consistency between sizes and sizes. The size operation may not be 100% accurate.
Read weak consistency
If modifications occur during traversal of a non-thread-safe container, the fail-fast mechanism will be used to cause the traversal to fail and throw
ConcurrentModificationException, no longer traversed.

_**ConcurrentHashMap**_
Same as the normal HashMap method, but thread-safe
Although each operation is atomic, the combination is not necessarily thread-safe.
map.computeIfAbsent() puts the key into the map. It is thread-safe and ensures the atomicity of the get and put method combinations.
principle:
HashMap Java 8 hash conflict elements are placed at the end of the linked list, while in Java 7 they are placed at the head.
The problem of concurrent dead links will occur when HashMap is expanded (occurred in JDK 7). The insertion method has been modified in JDK 8 so that dead links will no longer be formed during expansion, but it will easily lead to data loss during expansion.
ConcurrentHashMap

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


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

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

Lazy initialization, only the table size is calculated in the construction method, and it is not actually created until it is used for the first time.
The structure used in JDK8 is array + linked list + red and black. The initial length of the array is 16
When the length of the linked list exceeds 8, it turns into a red tree. When the length exceeds the loading factor * array length, the capacity is expanded.
In JDK7, Segment segment lock is used to achieve thread safety based on array + linked list.
Using CAS+Synchronized in JDK 8 to ensure thread safety
Last hours for last deal of the year on Lexington Themes.
Tags: webdev, javascript, astro, tailwindcss
Published: 2023-11-30 06:06:14

Last hours for last deal of the year on Lexington Themes.

Black Friday deal end in less than 24h 
Get 30% off the bundle:
- 28 Multipage Astro & Tailwind CSS themes
- Future additions and updates

Until 30.11.2023

- https://lexingtonthemes.com
Ghaziz LLC: Your Trusted Companion in Marketing Success
Published: 2023-11-30 05:56:55

Experience unparalleled marketing expertise with [Ghaziz LLC](https://vocal.media/authors/ghaziz-llc), the name synonymous with success. From established brands to those just starting their online journey, Ghaziz LLC's dedication to your success is evident in their comprehensive strategies. They're not just an agency; they're your marketing friend.
Shared model immutability
Published: 2023-11-30 05:43:47

SimpleDateFormat is thread-unsafe, you can use DateTimeFormatter (immutable class, thread-safe) under multi-threading

## Immutable design:
- Classes and all properties in a class are final
Modifying the property with final ensures that the property is read-only and cannot be modified.
Modifying a class with final ensures that methods in the class cannot be overridden, preventing subclasses from inadvertently destroying immutability.
-Protective copy: avoid sharing by creating copy objects
Protective copy to ensure that the array contents will not be changed by other classes.

## Flyweight pattern
_**Share data as much as possible**_
Since protective copy creates multiple objects and wastes resources, flyweight mode is usually used.
This pattern is often used in wrapper classes
The valueOf method of Long type will cache Long objects between -128 and 127. Objects will be reused within this range. New Long objects will be created only when the range is greater than this range.

## final principle
Principle of setting final variables

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/24vjtipy9t6iledghwd6.png)
Stateless is also thread-safe and is achieved by not setting member variables in the class.
Shop Prada Eyewear at EasySight - Latest Collection
Published: 2023-11-30 05:37:00

## 👓 Discover Timeless Elegance: Prada Eyewear at EasySight! 👓

Ready to elevate your style game? Explore the epitome of sophistication with[ EasySight's latest addition—the stunning Prada Eyewear Collection!](https://easysight.pk/brand/parada/) Get ready to redefine your eyewear experience.

## 🌟 Prada: Where Style Meets Craftsmanship

Prada is synonymous with luxury and excellence. Their eyewear collection at EasySight is a testament to this legacy, boasting impeccable designs and flawless craftsmanship. Each pair exudes class and elegance, making it more than just eyewear—it's a statement.

## 🕶️ Unveiling the Latest Collection

Dive into the world of chic frames and distinctive styles! The latest Prada Eyewear Collection at EasySight features a diverse array of designs—from classic to contemporary, ensuring there's something for every taste. Browse and find the perfect match for your unique style.

## 🌈 Elevate Your Look with Prada

Your eyewear speaks volumes about your personality. Elevate your look effortlessly with Prada's timeless collection. It's not just about fashion; it's about making a lasting impression. Experience comfort, clarity, and unmatched style.

## 🛍️ Shop the Collection Today

Indulge in luxury and sophistication with the newest Prada Eyewear Collection at EasySight. Our platform offers a seamless shopping experience, making it easy for you to explore and select the frames that resonate with your style sensibilities.

## 🌟 Redefine Your Eyewear Game

Your style journey deserves the touch of luxury that Prada Eyewear brings. Step into elegance, innovation, and unparalleled sophistication. Shop now and redefine your eyewear experience!

👓 Make a Statement. Shop Prada Eyewear at EasySight Today! 👓
JAVA
Published: 2023-11-30 05:35:40

Types in Java

There are various kinds in Java that help with data organisation and storage. Primitive types that hold fundamental data directly include integers (int), floating-point numbers (float), characters (char), and boolean values (boolean). Also , Java has non-primitive types like classes, interfaces, arrays, and enums, which enable the creation and use of more complex and unique data structures in programmes.

The differences of primitive and non-primitive

Java primitive types are simple data types such as integers (int), characters (char), floating-point numbers (float), and boolean values (boolean) that are used to store values directly. They are not objects; they contain basic info.

However, complex data types in Java, such as classes, interfaces, arrays, and enums, are referred to as non-primitive types. Since they are pointers to objects, methods and other data can be stored in them. Non-primitive types can access methods and attributes and can be null, in contrast to primitive types.

OOP

OOP namely Object-Oriented Programming . It's a style of programming that groups code according to objects, which are just some of classes. Code that is reusable  may be created because objects have methods and  variables that interact with one another. OOP stresses ideas like encapsulation, inheritance, polymorphism, and abstraction to improve readability, flexibility, and maintenance of code.

4 Pillars of OOP
Four essential ideas are represented in object-oriented programming, or OOP. Encapsulation is the process of combining processes and data into objects to limit access and assure regulated interaction. Code reuse is encouraged by inheritance, which allows new classes to inherit traits from previous ones.  Through method overloading and overriding, polymorphism allows objects to be viewed as instances of their parent class, enabling flexible coding. In order to produce simple, intelligible models, abstraction concentrates on the most important elements while hiding intricate implementations. These ideas work together to create the basis of OOP, which encourages modular, reusable, and well-organized software development.

))
Cisco Router'da Nasıl Netflow Verileri Açılır ?
Published: 2023-11-30 05:34:57

Bu yazıda Cisco Router üzerinden Netflow verilerinin açılmasını ve Virtual Machinede izlemeyi göreceğiz.

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

- İlk olarak cisco router , cisco switchlerle topoloji oluşturulur. 
- Routerlara gateway ve Statik yönlendirme ip'leri verilir.
- Yönlendirmler ile Ubuntu bilgisayarların ve routerların birbirine ping atmasını sağladım.
- Sonra hangi router üzerinden netflow verisi açacaksam ona netflow configurasyonu yaptım (R2 üzerinden yaptım).

# Router Üzerinde Ayarlar

```
Router> enable
Router# configure terminal
Router(config)# interface g2/0
Router(config-if)# ip flow ingress (iletilen trafiği izlemek için egress yazılabilir, her ikisi için ayrı satırlarda ikisinide yazmak gerekir)
Router(config-if)# exit
Router(config)# end
```
- NetFlow'un çalışır durumda olduğunu doğrulamak ve NetFlow istatistiklerinin bir özetini görüntülemek için
``Router# show ip cache flow``
- NetFlow Veri Dışa Aktarma ile trafik verilerini dışa aktarmak için NetFlow'u yönlendiricideki en az bir arabirimde etkinleştirerek yapılandırmanız gerekir. (Export adımları)
```
Router> enable
Router# configure terminal
Router(config)# ip flow-export destination 192.168.100.10 2055 (sanal bilgisayarın IP'si ve port adresi yazılır)
Router(config)# ip flow-export source g2/0
Router(config)# ip flow-export version 9
Router(config)# ip flow-export interface-names
Router(config)# ip flow-export template refresh-rate 15
Router(config)# ip flow-export template timeout-rate 90
Router(config)# ip flow-export template options export-stats
Router(config)# ip flow-export template options refresh-rate 25
Router(config)# ip flow-export template options timeout-rate 120
Router(config)# end
```
- NetFlow veri aktarımına ilişkin istatistikleri görüntülemek için
``` show ip flow export ```
# VM'ler Üzerinde Testler

- Router da görüntüledikten sonra sanal bilgisayardan görüntülemek için Tcpdump kullanacağız.
- Sanal bilgisayarın terminaline
```sudo su
telnet 192.168.100.1 2055 (ping atılan ip)
tcpdump port 2055  ```
- Başka bir terminal ekranından 192.168.100.1 'e ping attığımızda flow veri akışını izleyebiliyoruz.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4eb6fdakojzsghi0u41z.png)
How to change font size in VSCode
Published: 2023-11-30 05:19:03

## How to change font size in VSCode - short guide
- Use the shortcut CTRL + SHIFT + P and start typing 'User settings'
<a data-flickr-embed="true" href="https://www.flickr.com/photos/197764307@N08/53363234631/in/dateposted-public/" title="vscode-ctrl-shift-p-user-settings"><img src="https://live.staticflickr.com/65535/53363234631_855d4077c1_c.jpg"/></a>
- Hit ENTER
- You should see an option called font size under the 'Commonly Used' section:
<a data-flickr-embed="true" href="https://www.flickr.com/photos/197764307@N08/53363553604/in/dateposted-public/" title="vscode-settings-fontsize"><img src="https://live.staticflickr.com/65535/53363553604_32893a306f_k.jpg"/></a>
- By default, the font size is 14. I changed it to 18 in this example.
- You can click on the font size field and type which value you want.
- You don't need to save any changes, they're applied as soon as you change the value.
- In this same interface, you can change the font family, the tab size (how many spaces equal a TAB), the cursor design.
- Finally, close the settings tab by left-clicking the X button.
<a data-flickr-embed="true" href="https://www.flickr.com/photos/197764307@N08/53363439373/in/dateposted-public/" title="vscoade-settings-close-tab"><img src="https://live.staticflickr.com/65535/53363439373_1c31a8c460_c.jpg"/></a>
Exploring UI Development with Storybook and React CVA
Tags: frontend, react, cva, tutorial
Published: 2023-11-30 05:14:26

Welcome to my blog that will take you on a deep dive into two powerful React libraries: Storybook and React CVA. In the world of User Interface (UI) development, sustainability, testing, and documentation are crucial aspects. If a project is not well-documented, it can lead to significant challenges.

Imagine you or your team working on a large and complex React project. Without adequate documentation, onboarding new team members becomes a formidable challenge. How will they learn about the reusable components we've built? How will they know what props can be used for each component? This is a real issue that can hinder productivity and collaboration.

In this blog, we will tackle these issues together by leveraging two fantastic tools: Storybook and React CVA. Storybook will help us build, test, and document UI components in isolation. Meanwhile, React CVA will bring ease to writing CSS styles with TypeScript without compromising the clarity of documentation.

So, let's explore how the combination of Storybook and React CVA can be the key to creating easily understandable, reusable, and well-documented React components. Get ready to leave behind the complexity of manually naming classes and types, and let's focus on the exciting aspects of UI development. 

Click the link below to read the full article:
[Exploring UI Development with Storybook and React CVA](https://andreavindra.vercel.app/blog/exploring-ui-development-with-storybook-and-react-cva)
Happy reading!
Cisco Router'da Statik Yönlendirme Nasıl Yapılır?
Published: 2023-11-30 04:56:23

Bu yazıda Cisco Router'dan nasıl statik yönlendirme yapılacağını göreceğiz. Statik yönlendirme (static routing), ağ trafiğini belirli bir yolu takip ederek hedefe yönlendirmek için kullanılan bir yönlendirme yöntemidir.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9taoqphc3ha8trrgyfry.png)

- İlk olarak topolojide kullanılacak IP'leri ve subnetmasklarını belirliyoruz. 
- Sanal bilgisayarlara belirlediğimiz IP adreslerini, subnet masklarını ve gatewaylerini manuel olarak giriyoruz.
- Routerlara interface adreslerini veriyoruz ve no shutdown yazıp routerların interfacelerini açık hale getiriyoruz.

# Router Üzerinde Ayarlar  
Router4 için örnek :
```
router>enable
router#conf t
router# int gig1/0 (interface isimleri yazılır)
router(if-config)# ip add 200.150.150.1 255.255.255.252 
router(if-config)# no shutdown
router# int gig2/0 (interface isimleri yazılır)
router(if-config)# ip add 200.100.100.1 255.255.255.252 
router(if-config)# no shutdown
router(config)# wr

```
- Sonra Routerlara Statik Yönlendirme ekliyoruz.
Static Yönlendirme : 

`Router(config)# ip route {hedef ağ} {hedef ağ subnet mask} {hedef ağ kanalına giderken geçeceği ilk kapı}` <br>

Router1 için Statik Yönlendirme: 
``` R4(config)# ip route 192.168.100.0 255.255.255.192 200.150.150.2
  R4(config)# ip route 192.168.50.0 255.255.255.192 200.150.150.2
  R4(config)# ip route 10.10.0.0  255.255.0.0 200.100.100.2 ```
Router2 için Statik Yönlendirme:
 ``` R2(config)# ip route 200.100.100.0 255.255.255.252 200.150.150.1
  R2(config)# ip route 10.10.0.0 255.255.0.0 200.150.150.1 ```
Router3 için Statik Yönlendirme:
 ``` R3(config)# ip route 200.150.150.0 255.255.255.252 200.100.100.1
  R3(config)# ip route 192.168.100.0 255.255.255.192 200.100.100.1
  R3(config)# ip route 192.168.50.0 255.255.255.128 200.100.100.1 ```

# VM'ler Üzerinde Testler 
- 192.168.100.10 Ping Testi

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

- 192.168.50.10 Ping Testi

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

- 10.10.0.10 Ping Testi


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oan10lh8lanssx44pbgz.png)
React Router Hooks Guide
Tags: react, beginners, fullstack, webdev
Published: 2023-11-30 04:47:32

React Router is a library that was created to help create navigation links in a website.  Similar to how the react library gives us hooks to more easily create the user interface of a web application the React Router library gives use hooks and tools to add navigations routes in a simpler fashion to our applications' going to cover some of the commonly used hooks in React Router and explain what they are used for.  

## useNavigate() 

One of the most useful hooks included in the react router library is the useNavigate() hook.  The useNavigate() hook does what the name implies and allows you to add a navigation route to a component within your application.  For example if you had a webpage that showed a list of properties and once a property was clicked it would navigate the user to a new page that only showed that properties details you could use the useNavigate() hook to tell your website where to take the user once they click on the property.  This is also an extremely useful tool when creating a navbar.  You can create a route for each link in the navbar to bring the user to your desired route.  

## useParams()

Another very useful hook in the library is useParams().  This tool is used to use dynamic information from the URL of the route.  This is a great tool when you are trying to get create a route that is directed towards a specific user ID.  You will need the dynamic ability of useParams() to take the user ID out of the URL route and then you can use it in your code via useParams() to fetch and generate specific details based on the object ID.  A good example of this is if you were creating a website that sold different products.  When the user clicks on a product you want them to be directed to a page that gives additional details on that product including price, weight, shipping etc... those details are custom to each product being sold so you need the unique identifier(ID) from the URL Route to run through your fetch and to populate the new page the user is on.  

## useLocation()

useLocation() is a tool that gives us back an object of the information within the URL.  This is similar to useParams() but gives us additional information.  This tool can be useful for tracking views of a specific URL.  Say you want to know how many views each product on your website is getting.  Well based off of the unique link for each product and the useLocation() hook you can track the amount of views through creating a function that adds a counter every time the specific location is visited. 

There are many more useful react router hooks that can be used but the key is practice.  Make sure you stay refreshed on the official react router documentation linked here https://reactrouter.com/en/main.