teleren/devto huggingface dataset:
Defining Your Own Callbacks in RoR
Tags: ruby, rails
Published: 2023-11-05 23:24:51

With the define_callbacks method, it's possible to define your own callbacks. The [ActiveSupport::Callbacks](https://api.rubyonrails.org/classes/ActiveSupport/Callbacks.html) module contains all the logic and implementations for defining events in the lifecycle of objects.

```ruby
class MyModel < ActiveRecord::Base
 define_callbacks :custom_callback
 set_callback :custom_callback, :before do |record|
   puts "before important_thing"
 end
 set_callback :custom_callback, :after do |record|
   puts "after important_thing"
 end
 
 def important_thing
   run_callback :custom_callback do
     puts "...code"
   end
 end
end

MyModel.new.important_thing
```
The output:
```sh
before important_thing
...code
after important_thing
```
How I Recover Scammed Binary Option Funds
Published: 2023-11-05 23:23:08

Protecting yourself from bitcoin investment scams requires a combination of knowledge, caution, and due diligence. It is essential to research and understand the basics of cryptocurrency investments, familiarize yourself with reputable platforms and exchanges, and be aware of common scam tactics. Additionally, exercise caution when approached with investment offers that seem too good to be true, and never invest more than you can afford to lose. If you encounter suspicious activities or believe you have fallen victim to a scam, promptly report it to the appropriate authorities and seek professional assistance from Pro Wizard Gilbert Recovery. Pro Wizard Gilbert Recovery works closely with legal experts to explore all possible legal avenues to hold scammers accountable and facilitate the recovery process. However, it is important to note that the legal landscape surrounding cryptocurrency scams is constantly evolving, and outcomes may vary in different cases. In my case, Pro Wizard Gilbert Recovery was able to assist me recoup $210,000 of which I lost. Please reach out to this cryptocurrency expert to get the assistance you seek elsewhere. E-mail: prowizardgilbertrecovery(@)engineer.com &
Homepage :www.prowizardgilbertrecovery.xyz
Liskov Substitution Principle (LSP)
Tags: webdev, programming, tutorial, learning
Published: 2023-11-05 22:55:41

The Liskov Substitution Principle (LSP) is the third SOLID principle and states that objects of a base class should be replaced by objects of its derived classes without affecting the correctness of the program. In other words, if a class is a subtype of another, it must be able to be used in place of that class without the program behaving in an unexpected way. By following LSP, you guarantee that derived classes will not exhibit behavior that is not compatible with the contract predicted by the base class.

## Example After Applying LSP in PHP:
```php
<?php

class Animal
{
    protected $name;

    public function setName($name)
    {
        $this->name = $name;
    }

    public function makeNoise()
    {
        // Generic logic for making noise, each animal can have its own sound
    }
}

class Cat extends Animal
{
    public function makeNoise()
    {
        return "Meow!"; // Specific implementation for the sound of a cat
    }
}

class Dog extends Animal
{
    public function makeNoise()
    {
        return "Oof Oof!"; // Specific implementation for the sound of a dog
    }
}
```

In this example, Animal is the base class that contains a `makeNoise()` method. The Cat and Dog classes are subclasses of Animal and implement the makeNoise() method according to the sound that each animal makes.

According to the **LSP**, you can use objects of the `Cat` or `Dog` class in place of objects of the Animal class without this causing problems in the program logic.

## Example of use:

```php
<?php

function makeAnimalNoise(Animal $animal)
{
    echo $animal->makeNoise();
}

$cat = new Cat();
$cat->setName("Frajola");
makeAnimalNoise($cat); // Output: Meow!

$dog = new Dog();
$dog->setName("Rex");
makeAnimalNoise($dog); // Output: Au Au!
```

In this code, the `MakeAnimalNoise()` function accepts an object from the Animal class, but we can pass objects from the Cat or Dog subclasses without any problems, thanks to the **LSP**. Each animal makes its own noise, as expected.

***

## Thanks for reading!

If you have any questions, complaints or tips, you can leave them here in the comments. I will be happy to answer!

😊😊 See you later! 😊😊

***

## Support Me

[Youtube - WalterNascimentoBarroso](https://www.youtube.com/channel/UCXm0xRtDRrdnvkW24WmkBqA)
[Github - WalterNascimentoBarroso](https://github.com/walternascimentobarroso)
[Codepen - WalterNascimentoBarroso](https://codepen.io)
This Is How I Am Doing Research To Find Best Training Hyper Parameters For SDXL DreamBooth Training
Tags: sdxl, dreambooth, training, stablediffusion
Published: 2023-11-05 22:51:18

Started 6 different Automatic1111 SD Web UI on a 6x RTX 4090 GPUs having RunPod machine.

Doing x/y/z checkpoint comparison to find best hyper parameters for Stable Diffusion XL (SDXL) DreamBooth training with:

U-NET only
vs
U-NET + Text Encoder 1
vs
U-NET + Text Encoder 2
vs
U-NET + Text Encoder 1 + Text Encoder 2

Comparing lots of checkpoints with lots of different prompts.

Being sure to not overtraining and cooking model with Text Encoder training is super important.



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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8b7kvpp0qfa732j5o76p.png)
Implementando Editor.js com Next.js utilizando Typescript
Tags: editorjs, nextjs, typescript
Published: 2023-11-05 22:17:37

Basicamente o Editor.js é um WYSIWYG editor. Tenho certeza que irá se surpreender com essa solução e ficar ainda mais impressionado sabendo que é gratuíta. E ao meu ver está muito a frente de outras soluções pagas.

Conheça o [Editor.js](https://editorjs.io/). E também considere fazer uma [doação](https://opencollective.com/editorjs) para o projeto. São poucos projetos gratuítos com esse nível de qualidade.

A proposta deste tutorial é mostrar sua implementação com o [Next.js](https://nextjs.org/) utilizando Typescript.

Vamos utilizar o [App Router](https://nextjs.org/docs/app).

## Criando o componente Editor

Primeiramente vamos construir um componente que irá exportar uma `div` onde o Editor.js será renderizado após a tela estar pronta para o usuário.

```tsx
// components/Editor.tsx

'use client'

import { useRef } from 'react';

import EditorJS from '@editorjs/editorjs'

// Esta função irá garantir que o componente seja renderizado uma única vez
const RenderEditor = ( ElementId: string ) => {
  const rendered = useRef<false | true>( false )
  
  if ( !rendered.current ) {
    rendered.current = true;
  
    // Aqui chamamos a execução do EditorJS e também podemos passar os parâmetros necessários para execução
    new EditorJS({
      holder: ElementId
    });
  } else {
    return
  }
}

export default function Editor() {
  const elementId = 'editorjs' // Defina aqui o ID para o elemento onde o Editor.js será renderizado

  RenderEditor( elementId )

  return (
    <div id={ elementId }></div>
  )
}
```

## Importando o Componente

Para importar o componente vamos utilizar o [`next/dynamic`](https://nextjs.org/docs/app/building-your-application/optimizing/lazy-loading#nextdynamic).

Essa implementação se faz necessária para evitar erros na execução do Editor.js, lembrando que oficialmente não existe um componente React, mas podemos construir nosso próprio componente e utilizar sem nenhum problema.

```tsx
// page.tsx

import dynamic from "next/dynamic";

const Editor = dynamic(() => import("components/Editor"), {
  ssr: false,
  loading: () => <p>Loading ...</p>,
})

export default async function Page() {
 return(
   <Editor />
 )
}
```

Com essa implementação o Editor.js deverá ser executado sem erros no seu Fron-end.

Gostaria de destacar uma resposta no [Stackoverflow](https://stackoverflow.com/a/72953313/10265910) que me auxiliou na construção da função que garante que o Editor.js será renderizado uma única vez.

Até mais!!!
A Plus Garage Door Repair
Published: 2023-11-05 21:22:43

A Plus Garage Door Repair stands as your trusted partner for all your [Palm Harbor Garage door repair](http://aplusgaragedoorrepairs.com/)  needs, providing rapid, dependable, and budget-conscious solutions. Our team of expert technicians is fully prepared to deliver immediate assistance for maintenance and repairs. We take immense pride in offering exceptional customer care alongside top-tier work quality. We ensure the optimal functionality and safety of your garage door, ensuring your peace of mind. Whether you're searching for a complete door replacement or require urgent repair services,[Garage door repair Palm Harbor](https://goo.gl/maps/d2v9puzkHoGJYma98) is your ultimate source for precision and unmatched expertise.
Web Components Introduction
Published: 2023-11-05 20:55:21

## What is a web component?

When we talk about a _[WebComponents](https://developer.mozilla.org/en-US/docs/Web/API/Web_components)_, we are talking about a set of Web APIS, which together with different technologies (_HTML, CSS and JavaScript_) and always natively under web standards, allow you to create elements with a specific purpose in a fully customizable way, reusable and extendable.


## Important features of Web Components

[**1. Custom Elements**](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements)
[**2. HTML Templates**](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_templates_and_slots)
[**3. Shadow DOM**](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM)
[**4. ES Modules**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)
[**5. CSS Scopes & Parts**](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM#encapsulation_from_css)

### <u>Custom Elements </u>

They are a set of Web APIS that allow you to define custom HTML elements. Just as the HTML5 standard defines that official HTML tags must consist of a single word, custom elements must consist of at least two words separated by a hyphen.

### <u>HTML Templates</u>

They allow you to create code fragments isolated from the document, its content will be inert and will not be processed or rendered until we clone its content

### <u>Shadow DOM</u>

It allows you to attach hidden DOMs within the _[regular DOM](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Introduction)_, making it possible to encapsulate and isolate elements from the rest of the page.

### <u>ES Modules</u>

It´s a native feature that allows the import and export of data fragments between different JavaScript files.

### <u>CSS Scopes & Parts</u>

Although CSS works globally by default, we have specific pseudoclasses and pseudoelements in addition to the _[“CSS Parts”](https://developer.mozilla.org/en-US/docs/Web/CSS/::part)_ to expose parts of our component to the outside and style them.


## Advantages of web components

1. They follow web standards so they work in any current browser.
2. Its implementation is native so we do not depend on third-party frameworks or libraries.
3. They are reusable, extensible and allow us to create fully encapsulated elements.
4. Currently you can implement them in almost all the most popular Frameworks. **[Check it](https://custom-elements-everywhere.com/)**

## Links

These are some of the documentation in Spanish and English that I consider to be a reference.

- https://lenguajejs.com/webcomponents/
- https://www.webcomponents.org/
- https://developer.mozilla.org/es/docs/Web/API/Web_components
- https://htmlwithsuperpowers.netlify.app/
PERMAINAN SBOBET88 TERGACOR DI INDONESIA
Tags: slotonline, rtplive, gamedev, slot
Published: 2023-11-05 20:48:56

Permainan judi bola saat ini menjadi permainan yang cukup populer, tentunya karena fitur dan hal unik yang ada di dalam situs [Sbobet88](https://eranmendel.com/) tersebut. Seluruh para pemain akan menemukan berbagai permainan dengan tema permainan sports atau olahraga seperti permainan berkarakter sepak bola, bola volly, badminton dan masih banyak lainnya yang tentunya diwajibkan untuk anda cobain supaya mengetahui sensasi bermain judi bola tersebut. 

Tetapi tenang jika anda kurang suka permainan judi bola, disini kami akan memberikan saran situs slot online lainnya yang dapat di jadikan tempat mencari cuan banyak, situs yang menjadi rekomendasi tersebtu adalah situs mpo [slot deposit dana](https://www.mybindi.com/) terpercaya. Tentunya berbagai permainan yang sangat menarik akan anda kunjungi dan permainan tersebut tentunya akan membuat seluruh para pemain menjadi tidak akan bosan untuk bermain slot online ini.

Kedua tersebut memiliki kesamaan yang dapat dirasakan oleh seluruh para pemain yaitu sama sama menjadi situs terpercaya yang dapat di jadikan tempat mencari cuan banyak dan cepat. Seluruh para pemain tentunya akan mendapatkan banyak bantuan dan bantuan tersebut tentunya sangat membantu untuk memperoleh sebuah kemenangan dengan mudah, maka itu ayo segera bermain dan bergabung dengan situs [slot mpo](https://www.glowsantamonica.org/) terpercaya sekarang juga agar mendapatkan banyak bantuan yang sangat membantu untuk memperoleh sebuah kemenangan dengan mudah.

Seluruh para pemain tidak perlu takut ataupun ragu untuk bermain [slot gacor](https://faminegenocide.com/) di dalam situs terpercaya kami karena sudah tentu situs kami terpercaya jadi seluruh para pemain tidak perlu takut, selain itu jika seluruh para pemain memperoleh sebuah kemenangan yang kecil tetap akan diberikan hadiah maka itu tenang jika anda memperoleh sebuah kemenangan kecil karena kami akan tetap memberikan hadiahnya.

Untuk informasi [slot online](https://dev.to/ullianna/permainan-sbobet88-tergacor-di-indonesia-5bld) lebih banyak dan lebih akurat seluruh para pemain dapat membantu seluruh para pemain untuk memperoleh sebuah kemenangan dengan mudah, segera kunjungi situs terpercaya kami melalui link berikut ini:
[https://bijou-cinemas.com/](https://bijou-cinemas.com/)
[https://mysentimentexactlee.com/](https://mysentimentexactlee.com/)
🛣️ API Marketplaces & innovation, explained and showcased
Tags: api, apigateway, beginners, showdev
Published: 2023-11-05 20:46:25

## ❔ Context

Digital Transformation, Data Strategy, monetization, AI & chatBOTs... are all very trending topics.

Yet,... to achieve these goals: 

> **_we need to get nicely delivered, secured and easy to use APIs._**

To achieve these goals, we need to get well suited _API Marketplaces_:

[![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j30do4aiwvpjygmk4nws.png)](https://trends.google.com/trends/explore/TIMESERIES/1697755800?hl=en-US&tz=-660&hl=en-US&q=api+marketplace&sni=3 )

**🤔 Yet, defining what an _API Marketplace_ is may not be so evident to all us... nor how to implement an efficient one.**


👉 With this post and video, **you'll discover a practical approach, from the bottom-up, experience driven.**

## 🎙️ Discover

{% youtube cfwEP6Oqjew %}

## 📑 Bookmarks

### 🏛️ Data Strategy

For more about data strategy, see:

{% embed https://dev.to/optnc/data-strategy-for-not-so-dummies-1b23 %}
Problem to generate reports for our users
Published: 2023-11-05 19:58:00

Hello,

I am the founder of Fitfame.co which is SaaS for content creators and their fans. Creators can choose their monthly subscription price and invite fans to their Fitfame channel.

In Stripe each creator are listed as Products and under their product we can open different prices. My problem is that every month I need to deliver a financial reports of the revenue, but with Stripe it seems to be impossible. 

Anyone else facing the same issue? I would be more than happy to understand how you guys are solving the issue :)

Best,
Jukka Mitrunen
Crypto investment scam recovery
Published: 2023-11-05 19:42:58

What I thought could ruin my investment turned out to be a very educating and informative experience; having lost $850,000 through BTC to some criminal online impersonating to be my business associate. I was left with no option other than finding a reliable firm to help with a possible solution as I had read something about it online before; with that I contacted Daniel Meul Recovery and beyond my own expectations, they were able to help recover my lost money only by requesting just a handful of information; so I recommend them to everyone who needs such services. Contact details: Danielmeuliweberecovery (At) email . com
Or Whatsapp  
+.3.9.3.5.1.2.0.1.3.5.2.8
And Telegram
@ Danielmeuli
ACTITUBE SLIM 50s - Smoke Smoother, Smoke Smarter
Published: 2023-11-05 19:27:31

Enhance your smoking experience with ActiTube. Discover ACTITUBE SLIM 50s and a range of smoking accessories, including actitube 50 and actitube joint products. Elevate your smoking journey with ActiTube today!

Experience a smoother and more enjoyable smoke with [ACTITUBE SLIM 50s](https://acti-tube.com/products/ACTITUBE-SLIM-50s-p440507269). Our premium filters enhance flavor and reduce harsh hits. Slim, eco-friendly, and effective.

ActiTube Joint Filters - Elevate Your Joints
Elevate your joint rolling game with ActiTube Joint Filters. Enjoy smoother, well-rolled joints with ease. Precision-crafted for superior quality and extended smoking pleasure.

Contact Us
www.acti-tube.com
+357 96533000
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u62qx1450cb7935zltzp.png)
Talk about a little Code Snippet with instanceof
Tags: php, discuss
Published: 2023-11-05 19:20:44

Hello together,

i don't know if this is the right place where i should ask about your Opinion. I want to talk about a little PHP-Code Snippet where i discussed with a Colleague the last days.

The following Code triggered me at an Pull Request Review, and i need your opinion.

Introduction: The following Method should check if the given $foundId is found in the Database AND there are NO mutliple Types which you get from the Database.

```php
public function isValid(int $searchId): bool
{
    $foundIdinDatabase = ArticleRepository::getInstance()->findById($searchId)

    if ($foundIdinDatabase instanceof Article) {
            retrun true;
    }
    
    return false;
}
```

The following line triggered me:
```php
if ($foundIdinDatabase instanceof Article) {
```

I talked to my College and asked, why do you use "instanceof" instead of something like:

```php
if ($foundIdinDatabase) {
    return true;
}
```

He told me "There is nothing wrong with the code with instanceof, i want to know if i found an Article-Object in the Database? It works correctly and i think there is nothing wrong with this code".
I mentioned that, if as i read the code, i mean that i can get mutliple "Instances of" something like "Book", "Article" or something else because he use "instance of". And thats not the truth, the "search" could return only an (Article) Object or null.

I said, look at the PHP Documentation who to use "instanceof", but nothing happend, the Colleague mean its okay to do it this way.

Whats your Opinion to the code above? Good way, bad way? I'm wrong?
How to use GitHub Workflows to Streamline Your Software Development Process
Tags: technology, github, workflows, automation
Published: 2023-11-05 18:29:18

# Introduction

Are you looking for ways to streamline your software development process? Have you heard about GitHub Workflows but don’t know how to use them? Well, you’re in luck. In this blog post, we’ll discuss how to use GitHub workflows to streamline your software development process.

GitHub Workflows are powerful tools that allow you to automate your software development processes. They help you save time and effort by automating mundane tasks, so you can focus on more important things. By taking advantage of the power of GitHub Workflows, you can quickly and easily streamline your software development process.

# What Are GitHub Workflows?

GitHub Workflows are automated scripts that are triggered by certain events. They are written in the code language YAML and can be used to automate tasks such as building, testing, and deploying code. They allow you to define a set of rules that are executed whenever a certain event occurs. For example, you can define a workflow that is triggered whenever you push a new version of your code to GitHub.

# How to Use GitHub Workflows

Using GitHub Workflows is relatively simple. All you need to do is create a workflow file in your project’s repository. This file should be named “.github/workflows/workflow.yml” and should contain the code that defines your workflow. You can then define the events that should trigger your workflow and the tasks that should be executed when those events occur.

Once you’ve created your workflow file, you can start using it to automate your software development process. You can define workflows for tasks such as building, testing, and deploying code. For example, you can define a workflow that builds and tests your code every time you push a new version to GitHub. You can also define workflows that deploy your code to various servers and services.

# Conclusion

GitHub Workflows are powerful tools that can help you streamline your software development process. By taking advantage of the power of GitHub Workflows, you can quickly and easily automate mundane tasks and save yourself time and effort. So, if you’re looking for ways to streamline your software development process, consider using GitHub Workflows.
An overview of CRDTs
Tags: 100daystooffload, crdt, distributedsystems, algorithms
Published: 2023-11-05 17:41:44

Inspired by the excellent blog post [An Interactive Intro to CRDTs](https://jakelazaroff.com/words/an-interactive-intro-to-crdts/), I began to read more about the topic. To solidify my understanding of this concept (which is fairly new, minted around 2011) of [CRDTs](https://en.wikipedia.org/wiki/Conflict-free_replicated_data_type), I will start with a short overview.

**C**onflict-free **R**eplicated **D**ata **T**ypes (CRDTs) are a family of data types that can be replicated across multiple nodes in a distributed system. 

These data types are designed to handle concurrent updates to the same data without conflicts. This makes them ideal for use in a variety of distributed applications, such as real-time collaborative editors, chat systems, and database replicas. 

To resolve conflicts the data types are leaning on optimistic replication, which means that replicas can diverge temporarily, and then reconciled later when it is detected that there is a conflict.

CRDTs are not just working in a distributed system it is also working nicely in decentralized system, meaning they do not require a single server. This makes them ideal for use in peer-to-peer networks and other decentralized settings.

There are two approaches of CRDTs:

* State-based, convergent replicated data types, CvRDTs. This approach is sending the complete state to the other replicas.
* Operation-based, commutative replicated data types, CmRDTs. This approach is replicating the state by sending the update operation.

Since each approach can simulate the other, they are theoretically equivalent.

There are several known CRDTs which can be seen in my mind map below.

![Mind map](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6mdzlvmagfu2xqgqe7uz.png)

I have only have had time to scratch the surface of this concept yet, and the site [CRDT.tech](https://crdt.tech/) is a great starting point for anyone interesting to deep dive in this topic too.

I hope to get time to try to implement something with CRDTs in a near future.
Want to search for Open Source Repos on Github to contribute to?
Published: 2023-11-05 17:39:54

Hey folks,

Although this is no such tech stuff, and yeah it's very easy that anyone can do.
I recently created (I mean, I just... whatever) an AI agent that can give the names of Open Source repos available by knowing the category for searching the repo.

Just enter a category like hacking and it will provide a list of different open source repos available.

You can try this out: [Live](https://illa.ai/ai-agent/ILAfx4p1C7p2/detail)

Doc: [Click](https://github.com/illacloud/illa-builder/blob/beta/hacktoberfest2023/awesome-ai-agents/GOSSIF.md)