teleren/devto huggingface dataset:
A simple example to understand Module Augmentation in TypeScript
Tags: webdev, typescript, react, frontend
Published: 2024-02-29 00:41:10

## What is Module Augmentation

Imagine you're using a third-party library with a Vehicle class, which provides basic vehicle functionality. However, your project requires additional features not present in the original class. This is where module augmentation comes in handy.

Here's the original `Vehicle` class from the library:

```typescript
// vehicle.ts (in a third-party library)
export class Vehicle {
  constructor(public make: string, public model: string) {}

  startEngine() {
    console.log('Engine started');
  }
}
```

You want to add a `toggleHeadlights` method and a `headlightsOn` property to this `Vehicle` class. Here's how you can use module augmentation to achieve this.

## Implementing Module Augmentation

First, import the `Vehicle` class into your `index.ts` file:

```typescript
// index.ts
import { Vehicle } from "./vehicle";
```

Now, declare a module with the same path as the imported module and extend the `Vehicle` class interface:

```typescript
// index.ts
declare module "./vehicle" {
  interface Vehicle {
    headlightsOn: boolean;
    toggleHeadlights(): void;
  }
}
```

TypeScript will merge the original `Vehicle` class with the augmented interface, effectively adding the new properties and methods to the class.

Next, you need to provide the implementation for the `toggleHeadlights` method. This can be done by augmenting the prototype of the `Vehicle` class:

```typescript
// index.ts
Vehicle.prototype.toggleHeadlights = function() {
  this.headlightsOn = !this.headlightsOn;
  console.log(`Headlights ${this.headlightsOn ? 'on' : 'off'}`);
};
```

With these changes, you can now instantiate a `Vehicle` and use both the original and the new augmented functionalities:

```typescript
// index.ts
const myCar = new Vehicle('Tesla', 'Model S');

myCar.startEngine(); // Engine started
myCar.toggleHeadlights(); // Headlights on
console.log(`Are the headlights on? ${myCar.headlightsOn}`); // Are the headlights on? true
```

## Why Not Just Declare Another Class?

Why didn't we declare a new class extending the Vehicle class? While that is a common approach, there are scenarios where you might not be able to extend a class directly, such as when the class is not exported or when you want to patch the class without creating a subclass. Module augmentation is a powerful tool for these situations.



> This article is inspired by the post [Module Augmentation in TypeScript](https://www.digitalocean.com/community/tutorials/typescript-module-augmentation#enter-module-augmentation)
Unlocking Code Reusability and Flexibility with Upcasting in Java
Tags: java, oop, programming, beginners
Published: 2024-02-29 00:29:27

In Java programming, upcasting might seem like a cryptic concept, but its practical benefits are immense. Let's cut through the jargon and explore how upcasting can supercharge your code.

### What is Upcasting?

Upcasting allows you to treat a subclass instance as its superclass during compile-time, while preserving its true identity during runtime. Imagine you have a superclass `Noodle` and a subclass `BiangBiang`:

```java
class Noodle {
  protected double lengthInCentimeters;
  protected double widthInCentimeters;
  protected String shape;
  protected String ingredients;
  protected String texture = "brittle";
  
  Noodle(double lenInCent, double wthInCent, String shp, String ingr) {
    this.lengthInCentimeters = lenInCent;
    this.widthInCentimeters = wthInCent;
    this.shape = shp;
    this.ingredients = ingr;
  }
  
  public void cook() {
    this.texture = "cooked";
  }
}
```

```java
class BiangBiang extends Noodle {
  BiangBiang() {
    super(50.0, 5.0, "flat", "high-gluten flour, salt, water");
  }
}
```

```java
class Dinner {
  private void makeNoodles(Noodle noodle, String sauce) {
    noodle.cook();
    System.out.println("Mixing " + noodle.texture + " noodles made from " + noodle.ingredients + " with " + sauce + ".");
    System.out.println("Dinner is served!"); 
  }

  public static void main(String[] args) {
    Dinner noodlesDinner = new Dinner();
    Noodle myNoodle = new BiangBiang();
    noodlesDinner.makeNoodles(myNoodle, "soy sauce and chili oil");
  }
}
```

Focus on this particular line:
```java
Noodle myNoodle = new BiangBiang();
```

Here, `myNoodle` is recognized as a `Noodle` by the compiler, even though it's a `BiangBiang` at runtime. This allows us to tap into `Noodle`-specific features while enjoying the specialized behavior of `BiangBiang`. 

For example, in Dinner class, the makeNoodles() method is called with the BiangBiang object and a sauce as arguments, resulting in the preparation of BiangBiang noodles for dinner.

### Why Does it Matter?

**1. Boosts Code Reusability:** With upcasting, you can use methods designed for the superclass (`Noodle`) with its subclasses (`BiangBiang`). No need to duplicate code or create separate methods for each subclass. It's a time-saver and keeps your codebase tidy.

**2. Enhances Flexibility:** By focusing on coding with superclasses, you gain the freedom to tweak functionality without affecting subclasses. Want to upgrade `Noodle` behavior? No problem. It won't impact `BiangBiang` or other subclasses. It's coding agility at its finest.

### In Summary

Upcasting is not just another OOP concept; it's a game-changer. It empowers developers to write cleaner, more adaptable code while minimizing redundancy. Look to embrace upcasting, and watch your codebase become more efficient and maintainable.

### Credits

Dinner, Noodle, BiangBiang code from codecademy.

Whoever thought about the idea of upcasting is a genius!
Exploring Object-Oriented Programming in PHP
Tags: php, oop, beginners, programming
Published: 2024-02-29 00:28:57

## Introduction

Object-oriented programming (OOP) is a popular programming paradigm that has gained widespread use in recent years. It focuses on creating objects that contain both data and methods, which interact with one another to perform tasks. This article delves into object-oriented programming in PHP, a leading programming language in web development.

## Advantages of OOP in PHP

- **Code Reusability:** Objects can be created and reused across different parts of the code, enhancing maintainability and updatability.
- **Modularity:** OOP facilitates breaking down code into smaller, manageable parts, improving organization and reducing complexity.
- **Easier Debugging and Troubleshooting:** Since errors are typically isolated to specific objects, identifying and fixing bugs becomes more straightforward.

## Disadvantages of OOP in PHP

- **Steeper Learning Curve:** The concepts of objects and classes can be challenging for beginners, especially those accustomed to procedural programming.
- **Potential Performance Overheads:** OOP might introduce some performance penalties compared to procedural programming due to its abstract nature.

## Key Features of OOP in PHP

PHP is equipped with several OOP features that enhance its functionality and flexibility:

- **Class and Object Declarations:** The fundamental building blocks of OOP, allowing for the encapsulation of data and functions.
- **Inheritance:** Enables new classes to inherit properties and methods from existing classes, promoting code reuse.
- **Polymorphism:** Allows objects to be treated as instances of their parent class, not just as their own type.
- **Encapsulation:** Encloses the data and methods of an object, safeguarding against unauthorized access and modification.

### Example: Basic Class and Object in PHP

```php
<?php
class Car {
    public $color;
    public $model;
    
    public function __construct($color, $model) {
        $this->color = $color;
        $this->model = $model;
    }
    
    public function getMessage() {
        return "My car is a " . $this->color . " " . $this->model . "!";
    }
}

$myCar = new Car("black", "Volvo");
echo $myCar->getMessage();
?>
```

This simple example demonstrates defining a **Car** class and creating an object of that class, showcasing the encapsulation of data **(color, model)** and methods **(__construct, getMessage)**.

## Conclusion

Exploring object-oriented programming in PHP offers significant benefits, such as code reusability, enhanced modularity, and streamlined debugging. While it presents a learning curve and potential performance concerns, the advantages it brings to complex web development projects are substantial. Mastering OOP in PHP is invaluable, empowering developers to create more efficient, scalable, and maintainable web applications.
AI Runner preview: improvement to real time voice chat
Tags: ai, llm, stablediffusion, python
Published: 2024-02-29 00:19:42

---
title: AI Runner preview: improvement to real time voice chat
published: true
description: 
tags: ai,llm,stablediffusion,python
# Use a ratio of 100:42 for best results.
# published_at: 2024-02-29 00:10 +0000
---

I pushed some updates today which improve the performance of the voice chat.

This video showcases a conversation between myself an an evil chatbot.

{% embed https://www.youtube.com/watch?v=AahiwSY_gN0 %}
Suluck
Published: 2024-02-29 00:19:35

<a href="https://suluck.vn/"><b>Suluck</b></a> có nhiều năm kinh nghiệm thực thi các dự án lớn về vệ sinh công nghiệp chuyên nghiệp cho nhiều tập đoàn lớn trên thị trường. Suluck luôn là đơn vị uy tín, hàng đầu cho các đối tác lớn lựa chọn. Suluck cam kết mang đến cho Quý khách hàng dịch vụ tận tâm nhất, giá thành cạnh tranh nhất trên thị trường.
Website: <a href="https://suluck.vn/"><b>https://suluck.vn/</b></a>
- Address: 33 Đường Cầu Diễn - Bắc Từ Liêm - Hà Nội
- Email: vesinhsuluck@gmail.com
- Phone: +84939223268
#suluck #suluckvesinhcongnghiep #suluckvesinhnhaxuong
- Social:
<a href="https://www.facebook.com/vesinhcongnghiepsuluck"><b>https://www.facebook.com/vesinhcongnghiepsuluck</b></a>
<a href="https://www.youtube.com/channel/UC7vonDsP3mHbuk9B4lFL4RA"><b>https://www.youtube.com/channel/UC7vonDsP3mHbuk9B4lFL4RA</b></a>
<a href="https://www.pinterest.com/suluckvn/"><b>https://www.pinterest.com/suluckvn/</b></a>
<a href="https://twitter.com/suluckvn"><b>https://twitter.com/suluckvn</b></a>
<a href="https://www.flickr.com/people/suluckvn/"><b>https://www.flickr.com/people/suluckvn/</b></a>
<a href="https://www.linkedin.com/in/suluckvn/"><b>https://www.linkedin.com/in/suluckvn/</b></a>
<a href="https://vimeo.com/suluckvn"><b>https://vimeo.com/suluckvn</b></a>
<a href="https://www.reddit.com/user/suluckvn"><b>https://www.reddit.com/user/suluckvn</b></a>
<a href="https://about.me/suluckvn"><b>https://about.me/suluckvn</b></a>
<a href="https://www.tumblr.com/suluckvn"><b>https://www.tumblr.com/suluckvn</b></a>
Top 5 Remote Jobs for Fullstack Devs
Tags: webdev, fullstack, jobs, remotejobs
Published: 2024-02-29 00:12:20

💻 Mastering Fullstack Freedom: A Top 5 Remote Opportunities for Fullstack Developers 🚀

Are you ready to elevate your career from anywhere in the world? Explore the top remote opportunities for Fullstack Devs!

📣 Job Search #1:
📢 Position: Senior Fullstack Engineer - Vue.js (100% Remote)
🏢 Company: Slides With Friends
📍 Location: Remote.
📅 Date: 2024-02-27
🔗 View: https://www.opentoworkremote.com/view/719860



📣 Job Search #2:
📢 Position: Web3 Fullstack Engineer
🏢 Company: Flood
📍 Location: Remote.
📅 Date: 2024-02-26
💰 Salary: $70k - $110k
🔗 View: https://www.opentoworkremote.com/view/719818



📣 Job Search #3:
📢 Position: Sr. Fullstack Software Engineer, Merchant Experience
🏢 Company: Recharge
📍 Location: Remote.
📅 Date: 2024-02-17
🔗 View: https://www.opentoworkremote.com/view/705394



📣 Job Search #4:
📢 Position: Bio&Pathology Field(AI) Sr Fullstack Dev Free time zone
🏢 Company: LifeAnalytics,,Co.LTD
📍 Location: Remote.
📅 Date: 2024-02-16
🔗 View: https://www.opentoworkremote.com/view/701564



📣 Job Search #5:
📢 Position: Senior Fullstack Engineer
🏢 Company: Syndica
📍 Location: Remote.
📅 Date: 2024-02-09
🔗 View: https://www.opentoworkremote.com/view/667854


Your dream job awaits, no matter where you are, Best of Luck!
📢 Neo4J Ninjas as Kaggle dataset 🥷
Tags: neo4j, datascience, kaggle, showdev
Published: 2024-02-28 23:45:29

## 💭 Intro

I recently got a bronze medal for the Kaggle notebook that was preparing data about [Neo4J Ninja](https://neo4j.com/ninjas-program/):

{% twitter 1758611860520354151 %}

👉 This made me think that **these data were valuable and interesting people so I decided to publish:**

- **A well documented** Dataset
- **An original notebook** that show how to play with dataset and produce original content


## 🎯 What you'll learn

You'll learn how to:

- **🕹️ Play with Neo4J Ninja dataset with a very few lines of code**
- **🔗 Use and join many datasets** together to **unveil unprecedented knowledge**
- **📊 `KPI`s summarized** in captivating dataviz, and very cool and fun stuff

Hopefully you'll enjoy this content as much as I did while building it.

[![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/krr0e9pgh5uhhdiv1irf.png)](https://www.kaggle.com/code/adriensales/neo4j-ninjas-reporting-for-dummies)

## 🍿 Demo

Enough talks, let's head on the dataset unboxing:

{% youtube OuIGTYsFj8w %}


## 🔖 Neo4J Ninjas `duckdb` dataset 🦆

{% embed https://www.kaggle.com/datasets/adriensales/neo4j-ninjas-duckdb-dataset %}
First Setup to programm a discord bot in python
Tags: discord, python, beginners, learning
Published: 2024-02-28 23:38:06

Hey, you want to create a bot?
Then you are in the right post for that.
Questions are always welcome and I wish you happy coding.

As a smallsidenote: I wrote this to get myself and the world a good explanation of what i programmed. The bot developed in this project is a multipurposebot called ModNPC. You can add him by this clicking this: [Just a link](https://discord.com/api/oauth2/authorize?client_id=1144006301765095484&permissions=8&scope=bot).

In this small article we will talk about the basics to create a bot and what you need to develop a bot.

First you need to create a bot. Do this on this website:
[https://discord.com/developers/applications](https://discord.com/developers/applications)
Create a new bot. After that get your token from this menu: 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vxwrgn5qmlz3ufhigcze.png)
Please save it and dont share it with anybody u dont trust. It can easily cause server to collapse. After that i recommand, activating this checkboxes: 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tcegydx9wtzzz1jb6yhc.png)
Also activate the permissions your bot need to operate normally: 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/teyjciux4u6kbzj2eox7.png)

For developing your bot u will debug a lot. For this create an own discord server. After that invite your bot over the developer portal on this server: 

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

Dont forget to activate in the first checkerbox bot. After that you choose which rights your bot should have with this link. After this just copy the link, enter in your browser and add the bot to the right server. 

For programming a bot, you need to install these libs by entering this in your terminal:
`pip install discord.ext.context`
`py -3 -m pip install -U discord.py update-command: pip install --upgrade discord.py`

This is what you need to develop a bot.
Day 916 : The Platform
Tags: hiphop, code, coding, lifelongdev
Published: 2024-02-28 23:34:36

_liner notes_:
- Professional : Had a meeting to start the day to help someone put some Web Components I made into their application. We got it done pretty quickly. Some of it was mostly figuring out how to turn off Server Side Rendering. haha Then I had a very long meeting where I did the presentation that I created yesterday. It was again talking about Web Components and why I chose to go in that direction instead of building a framework-specific set of components. I had to take a break afterwards, but I think we have a good direction to go into. haha Then I worked on looking at some documentation to implement a new functionality.

- Personal : Last night, I just finished up my presentation that I presented today and went through some tracks for the radio show. Got to bed pretty late.

![Brown moss covered valley in Tombstone Park, YT, Canada with mountain ranges on both sides under dark dense clouds](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qfsmeek0rrb5njplmi4t.jpg)

Going to work on putting together the social media posts for the projects I pick up on Bandcamp. Need to get caught up with where I left off on my code along application. I want to see if I can get it working in the online IDE. I'll be using the platform for work so I want to get it working in the next couple of weeks. I want to get a basic MVP working and then add my own customizations for my own use. Getting to work!

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube DEVVGCK1Pl4 %}
Fix Memory Exhausted Issue in Laravel Tests
Tags: php, laravel, phpunit, pest
Published: 2024-02-28 22:09:45

Quick and easy tip, sometimes a test could take too much time/memory, you can set your local environment `memory_limit`, but take in mind that you should repeat this process on every environment (local, staging, production) and all development team environments should add this configuration, not best solution right? 

Fortunately. **PHPUnit** provides a simple solution for this cases you can set a `memory_limit` value that would instruct the memory limit only when the app runs tests.

In your `phpunit.xml` file add this configuration:

```xml
<php>
 ...
 <ini name="memory_limit" value="512M"/>
</php>
```
Enable ContainerLogV2 on AKS
Tags: azure, aks, devops, tutorial
Published: 2024-02-28 22:09:43

ContainerLogV2 provides additional data over ContainerLog (which is v1). The additional data includes
- ContainerName
- PodName
- PodNamespace

To enable ContainerLogV2 on an existing AKS cluster, you need to create a configmap. Here's how you do this

- Download the [template ConfigMap YAML file](https://aka.ms/container-azm-ms-agentconfig) for ContainerLog
- Set containerlog_schema_version = "v2" in the yaml file
- Update the exclude_namespaces under `log_collection_settings.stdout` and `log_collection_settings.stderr` as per your use case
- Save the changes
- Connect to Kubernetes cluster using CLI
```
kubectx my-cluster
```
- Run the following command to create the configmap.
```
kubectl apply -f container-azm-ms-agentconfig.yaml
```
- Done

I hope this helps. Refer to [Container insights log schema](https://learn.microsoft.com/en-us/azure/azure-monitor/containers/container-insights-logs-schema) and [Configure data collection in Container insights using ConfigMap](https://learn.microsoft.com/en-us/azure/azure-monitor/containers/container-insights-data-collection-configmap) for more insights.
Monitoring HP HBA H240 with telegraf and grafana
Published: 2024-02-28 21:58:17

---
title: Monitoring HP HBA H240 with telegraf and grafana
published: true
description: 
tags: 
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2024-02-28 21:47 +0000
---

I've recently got an HP SAS HBA H240 for my home lab to manage eight SAS SSD Pm1633a drives for better IOPs - who doesn't need that to run OpenShift at home right ? Given the HBA240's tendency to heat up, especially in a workstation setup, it's important to keep an eye on temperatures (Controller and SSDs).

To tackle this, I wrote a simple Python script that parses SSA CLI output into JSON format. This makes it easy to feed the data into Telegraf, enabling straightforward monitoring with Grafana.

Just a quick post to share this and for posterity...
I don't get into telegraf and grafana now, just comment if you want telegraf conf / grafana panel.

https://gist.github.com/XReyRobert/f3d6177d2b50b4198ea9f8896437c5b8
Handshake: Next.js boilerplate for OAuth with 200+ APIs
Tags: nextjs, opensource, javascript
Published: 2024-02-28 21:39:15


Today, we're excited to announce Handshake.

[Handshake](https://github.com/fiberinc/handshake) is a new open-source project that helps developers obtain access tokens to popular APIs. It abstracts away the complexities of OAuth for over 200 apps while giving teams the flexibility and observability they need.

## How it works

Handshake is a Next.js app that you can set up and deploy to Vercel within minutes. Just clone our repo and modify the `app/options.ts` file to configure the OAuth providers you need.

```ts
// app/options.ts
import { Salesforce, HandshakeOptions } from "handshake"

const options: HandshakeOptions = {
	// ...
	handlers: [
		Salesforce({
			clientId: "YOUR_CLIENT_ID",
			clientSecret: "YOUR_CLIENT_SECRET",
			scopes: [...]
		})
	],
}

export default options
```

Then, deploy your Handshake instance to a subdomain such as `handshake.yourdomain.com`. Finally, to request access tokens for an API (eg. Salesforce) from a user, redirect them to `/auth/salesforce/redirect` and let Handshake handle the rest.

## Why we built this

Our goal at Fiber is to help developers build delightful integrations. To that end, we've been handling OAuth for some clients since our very first week as a company. As of today, we've taken thousands of end users through the process, and learned quite a bit on the way. Handshake is the product of that learning.

We didn't originally plan on offering something like Handshake. Personally, I didn't believe the pain was big enough to justify our attention. So we continued to handle OAuth for some clients as an bonus feature, without advertising it anywhere.

As time went on, we noticed a good amount of inbound interest in Fiber came from companies only looking for help with OAuth. Whenever we politely turned away these customers, we tried to point them towards good open-source solutions but couldn't find anything worth recommending. The projects we found usually fell into two categories: _stale_ or _bloated_. The latter included projects that had moved beyond handling OAuth to incorporate lots of extra integration features. In the process, they lost flexibility and harmed developer experience.

## Our plan

Our plan for Handshake is this to **keep it open** and to **keep it simple.** The goal is to help developers get access to their users' third-party accounts. We won't try to pack unrelated features into it, or offer an enterprise version to make money. ([Fiber](https://fiber.dev) is how we make money ;).

That's it. We hope Handshake is useful to you. We're committed to keeping improving this project around for years to come.

Check out our documentation at [handshake.cook](https://handshake.cool) and [take us for a spin on Github](https://github.com/fiberinc/handshake). We'll love to hear your thoughts.