teleren/devto huggingface dataset:
OOP Python 2- Understanding Inheritance in Python : A Comprehensive Guide with Examples
Tags: programming, beginners, tutorial, python
Published: 2024-03-10 07:30:00

Discover the power and versatility of Python inheritance with this in-depth guide. Explore single, multiple, multilevel, hierarchical, and hybrid inheritance through professionally crafted examples. Enhance your understanding of object-oriented programming and inheritance in Python.

Inheritance is a mechanism in Python that establishes a parent-child relationship when deriving one class from another. It enables the usage of common methods and properties across these classes, facilitating code reusability and structure.

- a. Single Inheritance: The subclass inherits all properties of a single superclass. 
- b. Multiple Inheritance: The subclass inherits all properties of multiple superclasses. 
- c. Multilevel Inheritance: It involves creating a subclass of a class, and then creating a subclass of that subclass. 
- d. Hierarchical Inheritance: A superclass serves as the base class for multiple subclasses. 
- e. Hybrid Inheritance: This type combines two or more other inheritance types.
Inheritance promotes code organization, reduces redundancy, and allows for more maintainable and scalable code.

**Example with all types of inheritance:**

```
# Inheritance Example with All Types

# Single Inheritance
class Animal:
    def __init__(self, name):
        self.name = name

    def speak(self):
        return "Generic animal sound"

class Dog(Animal):
    def speak(self):
        return "Woof!"

# Multiple Inheritance
class Flyable:
    def fly(self):
        return "Flying"

class Bird(Animal, Flyable):
    def speak(self):
        return "Tweet!"

# Multilevel Inheritance
class Poodle(Dog):
    def speak(self):
        return "Bark softly"

# Hierarchical Inheritance
class Cat(Animal):
    def speak(self):
        return "Meow!"

# Hybrid Inheritance
class SuperDog(Dog, Flyable):
    pass

# Using Inheritance
dog = Dog("Buddy")
bird = Bird("Robin")
poodle = Poodle("Fluffy")
cat = Cat("Whiskers")
super_dog = SuperDog("Super Buddy")

print(dog.speak())      # Output: Woof!
print(bird.speak())     # Output: Tweet!
print(poodle.speak())   # Output: Bark softly
print(cat.speak())      # Output: Meow!
print(super_dog.speak()) # Output: Woof!  (inherits from Dog)

# Using Multiple Inheritance
print(bird.fly())       # Output: Flying

```

This example showcases all types of inheritance in Python with well-structured and professional coding practices. It includes single, multiple, multilevel, hierarchical, and hybrid inheritance. Each class demonstrates the specific characteristics associated with its inheritance type.

If you need further information or have specific questions, feel free to ask! Tahsin Soyak tahsinsoyakk@gmail.com
Using `!!` to Convert to Boolean
Tags: javascript
Published: 2024-03-10 07:27:48

**_Quickly convert any value to a boolean by using double negation._**

```
let truthyValue = !!1; // true
let falsyValue = !!0; // false
```

## NOTE
- 1 can be any `true` value 
- 0 can be any `false` value

### For more refer
- which are the true values
- & false values in javascript
- https://javascript-equality-table.vercel.app/if-condition

---

> Learn from: https://dev.to/mmainulhasan/30-javascript-tricky-hacks-gfc
Some points to consider when designing exceptional software
Tags: learning, softwareengineering, architecture, dotnet
Published: 2024-03-10 07:22:58


* Understanding User Needs:
  > Identify the preferred platform (mobile, web, or desktop) based on user preferences.
  > Assess the potential benefits of offering cross-platform compatibility.
* User Requirement Understanding:
  > Ensure a thorough comprehension of user needs to align development efforts effectively.
* Implementation of User Needs:
  > Develop strategies to translate user requirements into actionable features.
* Handling Concurrent Users:
  > Design the software architecture to gracefully manage multiple concurrent users.
* Optimizing Database Operations:
  > Implement techniques for optimizing database operations to enhance performance.
* Managing Memory Leaks:
  > Employ effective memory management practices to prevent and address memory leaks.
*  Handling Frequently Accessed Data:
  > Devise strategies for efficiently handling frequently accessed, unchanging data to minimize resource consumption and enhance responsiveness.
React 19 is coming and What's new?
Tags: react19, whatsnew
Published: 2024-03-10 07:17:58

As I eagerly await React 19, let's explore the exciting new features it brings to the table with its release.


**React Compiler**

One of the most common challenges in React development is avoiding unnecessary re-renders. Although we've had tools like **useMemo**, **useCallback**, and **memo **for manual state caching to mitigate this issue, React Compiler promises to address it automatically without requiring manual intervention. This should result in noticeable improvements in performance and the prevention of unwanted re-renders.

The great news is that "React Compiler is no longer a research project: the compiler now powers instagram.com in production, and we are working to ship the compiler across additional surfaces at Meta and to prepare the first open-source release - React Dev".

**Action**

Another exciting addition is the introduction of **Actions**, providing a more efficient way to interact with the server. Actions allow you to attach a function to DOM elements such as `</form>`.

```
<form action={search}>
 <input name="query" />
 <button type="submit">Search</button>
 </form>
```

When using an action, React manages the lifecycle of data submission for you, offering hooks like **useFormStatus **and useFormState to access the current state and response of the form action.

By default, Actions are submitted within a transition, ensuring that the current page remains interactive while the action is processing. Additionally, Actions support async functions, allowing the use of async/await in transitions. This enables the display of pending UI with the isPending state of a transition when an async request starts, and maintains the pending UI until the update is applied.

Another noteworthy feature is **useOptimistic** for managing optimistic state updates, but we won't delve into the details of that just yet.

**New Features in React Canary**

For those eager to try out new stable features before the public release, React Canary will prove invaluable. This allows React developers to gather feedback from the community before the stable release, facilitating further improvements.

**React Server Components, Asset Loading, Document Metadata,** and **Actions** are all available in React Canary already.

There's still more to come. In React 19, additional improvements are on the horizon, including long-requested enhancements like support for Web Components. The focus now is on finalizing these changes, preparing for release, updating documentation for new features, and announcing what's included.

It's clear that significant changes and improvements are on the way, and I can't wait to give them a try. Let me know which feature you're most excited about—I'm personally intrigued by the React Compiler and React Server Components.

For more Info follow **https://react.dev/blog**
Is Public Learning the most Effective way ?
Tags: datascience, learning, webdev, community
Published: 2024-03-10 07:12:25

🌟 Hey everyone! 🚀 Recently I was scrolling through Instagram and stumbled upon the concept of _Public Learning _and I was hooked! 🤩 

After searching and learning more about this method I figured it out. 

The term "_Public Learning_" actually have two meanings:-

**_Learning in Public_**:- This is a growing trend where people share their learning journeys with others. This involve things like creating blog posts about what you're studying, sharing code you're working on, or even live streaming your study sessions. The idea is that by making your learning public, you can benefit from others' feedback and experiences, and you can also help to motivate and inspire others who are learning the same things.

**_Public Learning for Educators_**:- This is a more specific concept used in professional development for teachers. It involves educators sharing their teaching practices and challenges with each other in a safe and supportive environment. This can help teachers to learn from each other's experiences, improve their teaching skills, and better understand the needs of their students.


Here's how you can benefit in the long run? Let me spill the tea! ☕👇

1. **Accountability and Consistency 📆:-**
   - If you want to level up your commitment game? Publicly sharing your learning journey keeps you on track and motivated! 💪

2. **Community Engagement 🌐:-**
   - Join the coolest crew! Building a community around your learning journey means connecting with awesome folks who share your passions. 🤝💬

3. **Feedback and Improvement 🔄:**
   - Say hello to growth! Get constructive feedback that'll supercharge your learning process. 🚀🔍

4. **Documentation and Portfolio 📚:**
   - You can turn your journey into a masterpiece! Your public learning platform becomes a portfolio showcasing your brilliance. 🌟📖

5. **Networking Opportunities 🤝:**
   - Doors opening left and right! Public learning brings networking opportunities that could lead to epic collaborations or even job offers. 🚪🌐

6. **Personal Branding 🚀:**
   - Shine bright like a star! Consistently sharing your knowledge builds your personal brand, making you a go-to expert. 🌈✨

7. **Self-Reflection and Clarity 🧘‍♀️:**
   - Find your zen! Publicly articulating your thoughts deepens your understanding and brings clarity to your goals. 🌌💭
If you found this blog useful and insightful, do consider sharing this blog and comment down your views on it. Do follow for more such content.


Here's how you can connect with me.

[Email](ys3853428@gmail.com) [Twitter](https://twitter.com/LoneWol56368438) [LinkedIn](https://www.linkedin.com/in/yashksaini/) [GitHub](https://github.com/yashksaini-coder)

Thanks for giving it a read !!
Mock /api/auth/me
Tags: 100daystooffload, playwright, testing, auth0
Published: 2024-03-10 06:45:32

[Playwright](https://playwright.dev/) is a wonderful tool for creating end-to-end tests for your web app.

The documentation is super nice and has several guides that are handy. One guide that I would like to highlight is the one about [mocking APIs](https://playwright.dev/docs/mock).

I have been using the [nextjs-auth0](https://github.com/auth0/nextjs-auth0) package in a web application that is using [Auth0](https://auth0.com/) as an IdP. The rate limit for requests to a tenant are pretty low when using a development tenant.

The `nextjs-auth0` library makes requests to the `/api/auth/me` endpoint which triggers a request to the auth0 development tenant. This setup with a couple of end-to-end tests with Playwright made the requests exceeding the rate limits that was allowed on that Auth0 tenant.

To the rescue of this problem was the guide mention earlier. By using this utility function in the `beforeEach` setup it's possible to avoid exceeding the rate limit. 

```typescript
import type { Page } from '@playwright/test'
import fs from 'fs'

const meAuth0Har = './hars/me.auth0.har'

export const mockAuth0Requests = async (page: Page) => {
  const harFileExists = fs.existsSync(meAuth0Har)

  await page.routeFromHAR(meAuth0Har, {
    url: '**/api/auth/me',
    update: !harFileExists,
  })
}
```

This code is based on the section `Mocking with HAR files` in the Playwright guide. The HAR file ([HTTP Archive](http://www.softwareishard.com/blog/har-12-spec/) a JSON based format) is created automatically based on the actual network information and will be populated with real data.

With this in place the end-to-end tests stopped being flaky because of the rate limit and is now working great.

Happy hacking!
A game environment creator except blender !
Tags: discuss, gamedev, software
Published: 2024-03-10 06:23:36


Hello everyone!
I was trying to use blender for creating game environment but m not able to do that because of my graphic driver. When I tried to update my driver from intel it said "No updating required". I am having 8GB RAM and 256GB hard disk. Can anyone please suggest me another software for game environment according to my pc specifications?
plus m a beginner so not familiar with each and everything. Help me with this please.
The Ultimate Guide to Free SVG Generators
Tags: webdev, beginners, design, productivity
Published: 2024-03-10 05:55:00

SVG (Scalable Vector Graphics) stand out for their crispness and scalability, making them indispensable for modern design projects. Here are some SVG generators that are not only free but incredibly user-friendly. Whether you're a seasoned designer or just starting out, these tools can elevate your designs with minimal effort. Let's explore some of the best free SVG generators I've found.

---

## FFFUEL - A SVG Creative Suite

[FFFUEL](https://fffuel.co/) is more than just a single tool; it's a comprehensive suite of creative instruments designed to cater to various design needs.

### nnneon - Bring Neon Back

Dive into the vibrant world of neon art with [nnneon](https://fffuel.co/nnneon/), a tool that lets you create stunning neon sign effects. Perfect for adding a touch of retro glamour.

### ccclaymoji - Playful Clay Emojis

With [ccclaymoji](https://fffuel.co/ccclaymoji/), you can generate adorable clay-style emojis to add a fun, three-dimensional look to your projects.

### bbblurry - Smooth Backgrounds

For those seeking to add a modern touch to their designs, [bbblurry](https://fffuel.co/bbblurry/) provides the perfect solution. Create smooth, blurry backgrounds that can enhance the aesthetic.

## GetWaves - Effortless SVG Waves

[GetWaves](https://getwaves.io/) simplifies the creation of wave patterns, easy-to-use interface lets you customize wave shapes to fit your design perfectly.

## CopyIcon - Iconic SVG Icons

[CopyIcon](https://copyicon.com/) is your go-to source for a wide array of SVG icons. From social media icons to user interface elements, finding the perfect icon for your project has never been easier.

## BlobMaker - Organic SVG Shapes

Create unique, organic shapes with [BlobMaker](https://www.blobmaker.app/), a tool designed to produce blob-shaped SVGs.

## Softr - Versatile SVG Tools

Softr offers two specialised tools for creating SVG shapes and waves, perfect for adding custom graphics to your projects.

### SVG Shape Generator

The [SVG Shape Generator](https://www.softr.io/tools/svg-shape-generator) provides an intuitive platform for creating custom SVG shapes tailored to your design needs.

### SVG Wave Generator

Similarly, the [SVG Wave Generator](https://www.softr.io/tools/svg-wave-generator) focuses on producing unique SVG wave patterns, offering a fresh take on web design backgrounds.

## PatternPad - Complex Pattern Design

For those looking to design more complex patterns, [PatternPad](https://patternpad.com/editor.html) offers a robust editor capable of creating intricate SVG designs suitable for any project.

---

I trust these tools will be as beneficial for you as they have been for me. Enjoy.

Feel free to follow the links below to view my Open Source Projects and more.

[travislord.xyz](https://travislord.xyz/)
[github.com/lilxyzz](https://github.com/lilxyzz)
BakaLLM 17.6 More epochs! More evaluations! Cerebras slashed and smashed
Published: 2024-03-10 05:45:04

Hello fairy dairy diary! 

For the first time BakaLLM outperformed the model with more parameters!

Instead of Cirno pic the graph

![Validation graph](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6adg0kohlnaxzz33r1uu.png)


| model_type | n_params  |       loss       |       ppl        |               note               |
|------------|-----------|------------------|------------------|----------------------------------|
| gpt2       | 590310912 | 2.97026801109314 | 19.4971443468238 | Cerebras-590M                    |
| gpt_neox   | 405334016 | 2.66211414337158 | 14.3265454754034 | Pythia-410M                      |
| gpt_neox   | 162322944 | 3.06171250343323 | 21.3641119680711 | Pythia-160M                      |
| baka_mamba | 182929408 | 3.19427084922791 | 24.3923814826904 | after 9 epoch ber 8batch (3h19m) |
| baka_mamba | 182929408 | 3.20950531959534 | 24.7668315275161 | after 8 epoch ber 8batch (3h24m) |
| baka_mamba | 182929408 | 3.21783852577209 | 24.9740809678157 | after 7 epoch ber 8batch (3h21m) |
| baka_mamba | 182929408 | 3.23828125       | 25.4898733561039 | after 6 epoch ber 8batch (3h33m) |
| baka_mamba | 182929408 | 3.26393222808838 | 26.152171522808  | after 5 epoch ber 8batch (3h08m) |
| gpt2       | 255977024 | 3.2076301574707  | 24.7204332188596 | Cerebras-GPT-256M                |
| baka_mamba | 182929408 | 3.30104160308838 | 27.1408942419521 | after 4 epoch ber 8batch (3h08m) |
| baka_mamba | 182929408 | 3.36562490463257 | 28.9515836260749 | after 3 epoch ber 8batch (3h12m) |
| baka_mamba | 182929408 | 3.47578120231628 | 32.3230695329532 | after 2 epoch ber 8batch (2h56m) |
| baka_mamba | 182929408 | 3.77265620231628 | 43.4954442322217 | after 1 epoch ber 8batch (3h8m)  |

The victory is in sight! 256M destroyed! Slammed! Torn to pieces! We will not talk about 160M pythia or that it took 9 epochs or that its general model not that particular take on wiki103 alone. Insignificant details will not stand in the way of such grandiose victory! 

One by one models are falling! The world is doomed! Yes!!

Back to drawing board.

Chilling out!
Dev Log (D-01 to D-04). Implementing neural networks from scratch.
Published: 2024-03-10 05:35:30

Disclaimer:-I am a noob.(So don't use this if you are learning something). 

Getting MNIST data (found this code in https://github.com/tinygrad/tinygrad). 

```
import numpy as np
import gzip
import requests

def fetch(url):
    response = requests.get(url)
    return response.content

def parse(file):
    return np.frombuffer(gzip.decompress(file), dtype=np.uint8).copy()
# Thank to https://github.com/tinygrad/tinygrad mnist example
BASE_URL = "https://storage.googleapis.com/cvdf-datasets/mnist/"
X_train = parse(fetch(f"{BASE_URL}train-images-idx3-ubyte.gz"))[0x10:].reshape((-1, 28*28)).astype(np.float64)
Y_train = parse(fetch(f"{BASE_URL}train-labels-idx1-ubyte.gz"))[8:].astype(np.int8)
X_test = parse(fetch(f"{BASE_URL}t10k-images-idx3-ubyte.gz"))[0x10:].reshape((-1, 28*28)).astype(np.float64)
Y_test = parse(fetch(f"{BASE_URL}t10k-labels-idx1-ubyte.gz"))[8:].astype(np.int8)

# Print the shapes of the loaded data
print("Shape of X_train:", X_train.shape)
print("Shape of Y_train:", Y_train.shape)
print("Shape of X_test:", X_test.shape)
print("Shape of Y_test:", Y_test.shape)
```

## Implementing NN. getting help from help from https://developer.ibm.com/articles/l-neural/
```
class Neuron:
    def __init__(self):
        # Weight is an vector.
        self.W =  np.random.uniform(-1.,1.,size=(784,)).astype(np.float64)
    def forward(self,X):
        self.wX = X.dot(self.W)
        return self.wX

    def sigmoid(self):
        if self.wX > 0:   
            z = np.exp(-self.wX)
            return 1/(1+z)
        else:
            z = np.exp(self.wX)
            return z/(1+z)
    def sigmoid2(self):
        return np.exp(self.wX) / (1 +  np.exp(self.wX))

    def tanH(self):
        z = np.exp(2*self.wX)
        return (z-1)/(z+1)

# neuron = Neuron()
# print(neuron.forward(train_data[4]))
# print(neuron.sigmoid())
```
I am stuck at my activation function bcz dot product of Input and weights is to large. 

```
class NLayer:
    neurons = []
    def __init__(self,number_of_neurons):
        for n in range(0,number_of_neurons):
            self.neurons.append(Neuron())

    def forward(self,X):
        for n in self.neurons:
            n.forward(X)
            print(n.tanH())

layer_1 = NLayer(784)
layer_1.forward(train_data[0])
```

```
class NNetwork:
    neuronsLayers = []
    def __init__(self):
        pass
    def train(self):
        # Train and update weights. 
        pass
    def test(self):
        # Don't update weights. check weights.
        pass
    def predict(self):
        # Run Model. 
        pass
```

I am still stuck at the error when executing the activation function code. OverFollow due to number being too large.
Free RPM System: Build a 7-Figure Business Today!
Tags: makemoneyonline, busine, webdev, javascript
Published: 2024-03-10 05:02:59




Introduction:
Discover how to build a successful online business with the Rapid Profit Machine (RPM). Developed by James Neville-Taylor, this system has helped him and hundreds of students generate substantial income online. For a limited time, access to the RPM system is free, along with over $4,715 worth of money-making bonuses.

Key Features:

Proven System: The RPM system has been developed based on James Neville-Taylor's experience and success in online marketing.
Free Traffic: Get access to free traffic that has generated over $2,794,245 online.
Comprehensive Training: Receive tools, training, and know-how to achieve results for free.
Real Results: The system has created multiple 6-figure success stories.
Benefits:

Free Access: For a limited time, unlock the RPM system and bonuses for free.
Money-Making Opportunities: Implement the strategies in the RPM system to fill your bank account with real money.
No More Wasting Time or Money: With the RPM system, you'll never have to worry about wasting your time or money again.
Support and Guidance: Join a community of like-minded individuals and receive support and guidance to succeed online.
[Claim Your Free RPM System Now and Start Building Your Online Empire!](https://shorturl.at/rGH69)
Passing Functions As Props In React
Tags: react, typescript, learning
Published: 2024-03-10 04:26:25

While working on refactoring code, I realized that I didn't fully understand callbacks. So, today's article is fundamental, but I decided to document this as part of my learning journey.

**Passing Props**
As the documentation states:

> React components use props to communicate with each other. Every parent component can pass information to its child components by giving them props.

**Passing a Function from Parent to Child**
This is a fundamental method of passing props from a parent component to a child component.

When clicking the "Click" button in the child component, it invokes the `handleClick` function passed from the parent component.

Parent.tsx

```
import Child from "./Child"

const Parent = () => {
  const handleClick = () => {
    console.log("button clicked")
  }

  return <Child handleClick={handleClick} />
}

export default Parent
```

Child.tsx

```
import { FC } from "react"

type ChildProps = {
  handleClick: () => void
}

const Child: FC<ChildProps> = ({ handleClick }) => {
  return (
    <div>
      <button onClick={handleClick}>Click</button>
    </div>
  )
}

export default Child
```

**Passing a Function from Child to Parent**
In this case, both the button and the function that logs "button clicked" reside in the child component, but the parent component renders the child component. Therefore, we need to "send" the function to its parent. We pass the `callback` as an argument to the `handleClick` function, and the handleClick function executes the `callback()` in the parent component.

Parent.tsx

```
import Child from "./Child"

const Parent = () => {
  const handleClick = (callback: () => void) => {
    callback()
  }

  return (
    <div>
      <Child handleClick={handleClick} />
    </div>
  )
}

export default Parent
```

Child.tsx

```
import { FC } from "react"

type ChildProps = {
  handleClick: (callback: () => void) => void
}

const Child: FC<ChildProps> = ({ handleClick }) => {
  const callback = () => {
    console.log("button clicked")
  }
  return (
    <div>
      <button onClick={() => handleClick(callback)}>Click</button>
    </div>
  )
}

export default Child
```

As projects grow larger and more complex, or when useContext is used, I tend to lose track of the flow and struggle to create components. I will continue learning about these concepts.