teleren/devto huggingface dataset:
Utils classes bury the lead
Tags: designpatterns
Published: 2024-03-17 16:35:35

## Happy to be here!

In [my recent article](https://www.jeromethibaud.com/en/blog/utils-considered-harmful/), I relate a discussion I've had many times over: Utils classes are 'bad'. "Bad how" you ask? Like crossing the streams? I believe it's about information or the lack thereof. I  discuss the problems with creating utility classes and I offer solutions for improving code organization and usability. 

> Think about your code as a product and other developers as your users.

## The issues with 'Utils'

The name 'Utils' provides no valuable information, making it difficult for developers to understand the purpose of the code.

Lack of discoverability can lead to duplication, as developers might miss existing methods and create new ones.

Utility methods are often provided through static methods, which can cause challenges in testability and flexibility.


## A few suggestions to make it better
To address these issues, I suggest a few things:

Consider the problem domain and choose informative names for your code, placing it near relevant domain types.

Leverage design patterns and language features to increase usability.

Organize code in a predictable way and providing information at each level of the source code hierarchy.

Ask questions about the intent, context, relationships, and problem domain to determine the best name and location for your code.

Use design patterns like the decorator pattern to add functionality to existing Types.

Avoid static methods to support testability and flexibility.

Utilize language features like extension methods and metaprogramming, especially when working with external libraries.

## Conclusion
By following these guidelines, you can create more maintainable and discoverable code, ultimately saving time and effort in the long run. 

You can read [the full story on my site](https://www.jeromethibaud.com/en/blog/utils-considered-harmful/)

Thank you for reading, I hope this was helpful.
Polymorphic Type Support in SignalR Hubs
Tags: dotnet, csharp, beginners, aspnet
Published: 2024-03-17 16:26:45


SignalR, a real-time communication library for .NET applications, introduces exciting new features. The article demonstrates the concept of polymorphic type support within SignalR Hubs.

## Overview

Traditionally, SignalR Hub methods expected derived classes as input parameters. However, with the latest enhancements, Hub methods can now accept base classes, enabling more flexible and polymorphic scenarios. This enhancement simplifies code and promotes better design practices.

## Implementation Example

Let’s explore an example using C#:
```
    using Microsoft.AspNetCore.SignalR;
    public class MyHub : Hub
    {
        public void ProcessPerson(JsonPerson person)
        {
            if (person is JsonPersonExtended)
            {
                // Handle JsonPersonExtended logic
            }
            else if (person is JsonPersonExtended2)
            {
                // Handle JsonPersonExtended2 logic
            }
            else
            {
                // Handle other cases
            }
        }
    }
    [JsonPolymorphic]
    [JsonDerivedType(typeof(JsonPersonExtended), nameof(JsonPersonExtended))]
    [JsonDerivedType(typeof(JsonPersonExtended2), nameof(JsonPersonExtended2))]
    private class JsonPerson
    {
        public string Name { get; set; }
        public Person Child { get; set; }
        public Person Parent { get; set; }
    }
    private class JsonPersonExtended : JsonPerson
    {
        public int Age { get; set; }
    }
    private class JsonPersonExtended2 : JsonPerson
    {
        public string Location { get; set; }
    }
```
## Explanation

 1. MyHub: A SignalR Hub that defines the ProcessPerson method. This method accepts a JsonPerson object, which can be either the base class or its derived types.

 2. JsonPerson: The base class representing a person. It includes common properties such as Name, Child, and Parent.

 3. JsonPersonExtended and JsonPersonExtended2: Derived classes that extend JsonPerson. They introduce additional properties (Age and Location, respectively).

## Conclusion

By embracing polymorphism, SignalR Hubs become more versatile and adaptable. Developers can now handle diverse data structures efficiently, making real-time communication even more powerful.

### Clap if you believe in unicorns & well-structured paragraphs! 🦄📝

### Socials: [C# Publication](https://medium.com/c-sharp-progarmming) | [LinkedIn](https://www.linkedin.com/in/sukhpinder-singh-532284a2/) | [Instagram](https://www.instagram.com/sukhpindersukh/) | [Twitter](https://twitter.com/sukhsukhpinder) | [Dev.to](https://dev.to/ssukhpinder)

![buymeacoffee](https://cdn-images-1.medium.com/max/2000/1*Dpw8-hNGI2fDmosV4E8DVQ.png)
Aprendizados sobre sistemas operacionais – Parte 1
Published: 2024-03-17 16:21:34

_Neste artigo falarei sobre conceitos que eu aprendi lendo os livros “Modern Operating Systems” do Tanenbaum e “Understanding the Linux Kernel” de Daniel Bovet & Marco Cesati._
Vamos para o que interessa:
* Um computador moderno consiste em um ou mais processadores, alguma quantidade de memória principal (RAM), discos rígidos (HDD/SSD), impressoras, um teclado, um mouse, um monitor, interfaces de rede e vários outros dispositivos de entrada/saída (I/O).

![Imagem representando a comunicação entre software e hardware](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/drq3o3sj19xjymq3u52p.png)

*  O hardware consiste de chips, placas, discos, um teclado e outros objetos físicos. Em cima do hardware fica o software.
* A maioria dos computadores possuem 2 modos de operação: o modo Kernel e o modo Usuário. O sistema operacional, a peça de software mais fundamental (como Windows, Linux, MacOS), executa no modo Kernel (ou modo de supervisor). Nesse modo, ele tem acesso completo a todo o hardware e pode executar qualquer instrução que a máquina seja capaz de executar. O resto do software roda no modo de usuário, em que somente um conjunto menor de instruções de máquina estão disponíveis. Em particular, as instruções que afetam o controle da máquina ou que realizam I/O são proibidas no modo usuário (programas de aplicações).
* O  “User Interface Program”, shell ou GUI (Graphical User Interface), é o software de modo usuário de nível mais baixo e eles permitem o usuário iniciar outros programas.
* Uma distinção importante entre o SO e softwares normais é que se um usuário não gostar de um certo programa de email, ele é livre para usar um diferente ou escrever o seu próprio; ele não é livre para escrever o seu próprio clock interrupt handler, que faz parte do SO e é protegido pelo hardware contra tentativas do usuário de modifica-lo.
* Alguns sistemas embarcados (embedded software) podem não conter um modo kernel.
* Existem programas que permitem o usuário trocar de senha, ou seja, eles possuem funções privilegiadas. Eles não fazem parte do SO e não são executados no modo Kernel, portanto, devem ser protegidos de uma forma especial.
* O código fonte de sistemas operacionais chegam a 5 milhões de linhas de código ou mais.
Snippets
Tags: opengl
Published: 2024-03-17 15:58:35

Get screen dimension.

```c
RECT rect;
GetWindowRect(wnd, &rect);
#define SCREEN_WIDTH  rect.right
#define SCREEN_HEIGHT rect.bottom
```

Is keyboard key or mouse button down?

See: https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes

```c
GetAsyncKeyState(VK_SPACE)
```

Get mouse location.

```c
POINT point;
GetCursorPos(&point);
#define MOUSE_X point.x
#define MOUSE_Y point.y
```

Load texture from file (using GDI+).

```c
ULONG_PTR token;
GdiplusStartupInput gsi = { .GdiplusVersion = 1 };
GdiplusStartup(&token, &gsi, 0);
// ...
GpBitmap* bitmap;
GdipCreateBitmapFromFile(L"texture.jpg", &bitmap);
BitmapData data = {};
GdipBitmapLockBits(bitmap, 0, 0, PixelFormat32bppARGB, &data);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, data.Width, data.Height, 0, GL_BGRA, GL_UNSIGNED_BYTE, data.Scan0);
GdipBitmapUnlockBits(bitmap, &data);
GdipDisposeImage(bitmap);
```
HTML - 13. ATRIBUT ID ELEMENT HTML | iAppTech.id
Tags: webdev, beginners, programming, html
Published: 2024-03-17 15:56:16


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

Welcome to iAppTech.id! 🚀

📚 Materi:
HTML — 13. ATRIBUT ID ELEMENT HTML pada Web, watch it!

👋 Halo, iAppTechers!
Kami adalah channel yang berfokus pada pembahasan seputar Frontend Development. Di sini, kami membawa Anda ke dalam dunia desain antarmuka, pengembangan web, dan segala hal seputar Frontend.

🔗 Playlist HTML:
https://www.youtube.com/playlist?list=PLc6PvCQzjsh_kCOlaz4ZFr8s708gNNVSv

💬 Disclaimer:
Channel ini saya buat khususnya untuk saya pribadi, dikarnakan menurut saya ketika saya belajar harus membuat konten, kenapa? karna menurut saya hal terbaik ketika belajar adalah mengaplikasikannya kembali, ditambah saya paham bagaimana jangka memori otak saya yang lama-lama tergerus oleh usia kedepannya, makanya saya buat channel ini untuk e-Library pengetahuan saya dibidang IT khususnya Frontend Developer. Ditambah saya juga mempunyai salah satu prinsip yaitu:

"Jika seorang manusia meninggal dunia, terputuslah amalnya, kecuali dari tiga hal: sedekah jariyah, ilmu yang bermanfaat dan anak shaleh yang berdoa untuknya." (HR. Muslim).

🖥️ Apa yang Akan Kamu Temukan di Sini?
Dapatkan wawasan mendalam tentang berbagai teknologi frontend, tutorial praktis, tips & trik, serta eksplorasi proyek-proyek menarik. Kami akan memandu Anda melalui dunia seru Frontend Development!

☕ Traktir Saya Ngopi:
 https://saweria.co/appardana

🔔 Berlangganan Untuk Konten Berkualitas:
Jangan lupa tekan tombol subscribe untuk tetap terkini dengan konten-konten menarik kami. Kami sangat bersemangat untuk berbagi pengetahuan dan pengalaman dengan Anda!

⏰ Jadwal Ngonten: Setiap Selasa dan Kamis, pastikan Anda tidak ketinggalan!

🤝 Mari Bergabung dalam Komunitas:
- https://www.youtube.com/c/iapptech
- https://discord.com/channels/1171443162108141679/1171443165123854421

Terima kasih telah bergabung dengan iAppTech.id. Mari bersama-sama memperkaya pemahaman kita tentang Frontend Development!

✨ Don't forget, ngopi heula… ✨

iAppTech #iAppTechId #Frontend #frontenddeveloper #programming #programmer #web #webdevelopment #Aditria #Pardana #AditriaPardana
Top Bình Thuận AZ
Published: 2024-03-17 15:54:34

Bắt nguồn từ cuộc thi tình yêu quê hương Bình Thuận do Zmar tổ chức Top Bình Thuận AZ được xây dựng với tầm nhìn trở thành trang web hàng đầu cung cấp thông tin đa dạng và đáng tin cậy về tỉnh Bình Thuận từ lịch sử, văn hóa, du lịch, địa điểm nổi tiếng, đặc sản ẩm thực, đến những câu chuyện và thông tin cập nhật mới nhất về đời sống, sự kiện xã hội, kinh tế góp phần giới thiệu vẻ đẹp văn hóa và tiềm năng phát triển của tỉnh
#topbinhthuan, #topbinhthuan, #topbinhthuanaz, #topbinhthuanaz, #tinhbinhthuan, #tinhbinhthuan
[https://topbinhthuanaz.com](https://topbinhthuanaz.com)
[https://www.reddit.com/user/topbinhthuanaz](https://www.reddit.com/user/topbinhthuanaz)
[https://www.pinterest.com/topbinhthuanaz/](https://www.pinterest.com/topbinhthuanaz/)
[https://www.linkedin.com/in/topbinhthuanaz](https://www.linkedin.com/in/topbinhthuanaz)
[https://www.youtube.com/@topbinhthuanaz](https://www.youtube.com/@topbinhthuanaz)
[https://www.facebook.com/profile.php?id=61552589969453](https://www.facebook.com/profile.php?id=61552589969453)
[https://twitter.com/topbinhthuanaz](https://twitter.com/topbinhthuanaz)
[https://www.instagram.com/topbinhthuanaz](https://www.instagram.com/topbinhthuanaz)
SQL MASTERY - P00 ( Introduction to SQL and It's Technicality
Tags: sql, learning, tutorial, series
Published: 2024-03-17 15:54:20

When we hear the word SQL, the first thing that pops up in our head is data. What exactly does SQL mean? It stands for Structured Query Language. Using SQL, we can write queries which will help us to manipulate data in mystical ways. Data is the fuel in the market. One who knows how to deal with data has a superpower to manipulate the market.

Umm... Data! Now the question comes up: what is actually "DATA"? So, the data itself is divided into further categories: Structured, Semi-Structured, and Unstructured data. Structured data is organized into a specific format, like tables in a database, with clearly defined fields. Semi-structured data doesn't have a rigid structure like structured data but may have some organizational elements, like tags or keys, such as XML or JSON files. Unstructured data has no predefined format and includes things like text documents, images, and videos. By now, you know what data is—it's your name, place location, or anything that you can imagine about yourself on a digital platform. Even your digital footprints are themselves data to predict your area of interest.

In this series, we are going to cover Structured data, as the name suggests itself, "Structured Query Language". Oh! So data is everywhere, but how and where do we store this messy thing? While talking about Data, a Database is something that comes complimentary or vice versa is true. So, you might have heard of MySQL, PostgreSQL, Oracle, MongoDB, etc. These are termed as databases. Database systems are software applications designed to store, manage, and manipulate data. In simple words, a database is a platform where we will be storing lots and lots of data, and by using query languages like SQL, we can play along with data using SQL. These languages provide mechanisms for creating, updating, querying, and administering databases. Going further, we are going to learn more about MySQL, as this is one of the most common, and in the future, we will cover Google BigQuery for heavy datasets.

Now you know what you are jumping into. From the next post, we will start with the real gaming, first with installation and then write the first query to read data.
"CSS Transform: The Cool Stuff You Can Do with Your Web Design"
Tags: webdev, design, css, programming
Published: 2024-03-17 15:34:39

**Introduction:**
Hey there! Today, I want to talk to you about something super cool called CSS transform. It's like having magical powers for your web designs! With CSS transform, you can make things on your webpage move, resize, and even spin around. Let's dive in and see what awesome things you can do with it!

**1. Scaling - Making Things Big or Small:**
Imagine you have a picture on your website, but it's too big and takes up too much space. No worries! With CSS transform, you can shrink it down to make it smaller using the `scale()` trick. Or maybe you want to make something stand out and be really big – you can do that too!

**2. Rotating - Spinning Things Around:**
Ever wanted to make something on your webpage spin like a top? With CSS transform's `rotate()` magic, you can do just that! You can make text or images rotate in any direction you want, adding a fun touch to your designs.

**3. Skewing - Twisting and Turning:**
Now, let's get a bit funky! CSS transform's `skew()` spell lets you twist and turn elements on your webpage. It's like looking at something from a different angle. You can make cool shapes and patterns by skewing things around.

**4. Translating - Moving Things Around:**
Want to make things move around on your webpage? CSS transform's `translate()` power lets you do just that! You can make elements slide or bounce across the screen, adding some excitement to your website.

**5. Combining Transformations - Superpowers Unleashed:**
But guess what's even cooler? You can combine all these transformations together to create even more awesome effects! Imagine making a picture grow bigger while spinning and sliding across the screen – that's some serious superhero stuff right there!

**Conclusion:**
So there you have it – CSS transform is like having a bag of magical tricks for your web designs! Whether you want to make things bigger, spin them around, or even make them dance across the screen, CSS transform has got you covered. So go ahead, experiment with these cool tricks, and let your creativity soar as you create amazing web designs!
Just completed Day 7 of my Data Structures and Algorithms challenge!
Published: 2024-03-17 15:43:41


Just completed Day 7 of my Data Structures and Algorithms challenge! Explored array searching, optimized array merging techniques, and implemented bubble sort.Check out the code and progress on my GitHub [Repo](https://github.com/mrfahid/Dsa-with-me-aur-chai-learning.git). Excited for Day 8! #DSA #CodingChallenge #ProgrammingGrowth
Just completed Day 7 of my Data Structures and Algorithms challenge!
Published: 2024-03-17 15:43:32


Just completed Day 7 of my Data Structures and Algorithms challenge! Explored array searching, optimized array merging techniques, and implemented bubble sort.Check out the code and progress on my GitHub [Repo](https://github.com/mrfahid/Dsa-with-me-aur-chai-learning.git). Excited for Day 8! #DSA #CodingChallenge #ProgrammingGrowth
Minimal Game Window
Tags: opengl
Published: 2024-03-17 15:39:04

```c
#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/wglext.h>

void main() {
    // Create full screen window
    HWND wnd = CreateWindow("STATIC", 0, WS_POPUP | WS_MAXIMIZE | WS_VISIBLE, 0,  0,  0,  0,  0,  0,  0,  0);
    HDC dc = GetDC(wnd);

    // Set pixel format
    PIXELFORMATDESCRIPTOR pfd = { .dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER };
    SetPixelFormat(dc, ChoosePixelFormat(dc, &pfd), &pfd);

    // Intialize OpenGL context
    wglMakeCurrent(dc, wglCreateContext(dc));

    // Enable vsync
    ((PFNWGLSWAPINTERVALEXTPROC) wglGetProcAddress("wglSwapIntervalEXT"))(1);

    // More OpenGL initialization code here...

	while (TRUE) {
        // Process window message
		MSG msg;
        if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }

        // Break loop on ALT+F4
        if (GetAsyncKeyState(VK_MENU) && GetAsyncKeyState(VK_F4)) {
            break;
        }

        // Draw using OpenGL here...

        SwapBuffers(dc);
	}
}
```
DevEnv Setup
Tags: opengl
Published: 2024-03-17 15:29:02

Download and extract TCC.

```
http://download.savannah.gnu.org/releases/tinycc/tcc-0.9.27-win64-bin.zip
```

Download and extract TCC Winapi.

```
http://download.savannah.gnu.org/releases/tinycc/winapi-full-for-0.9.27.zip
```

Download and extract MinGW.

```
https://github.com/brechtsanders/winlibs_mingw/releases/download/13.2.0mcf-11.0.1-ucrt-r3/winlibs-x86_64-mcf-seh-gcc-13.2.0-mingw-w64ucrt-11.0.1-r3.7z
```

Copy `wglext.h` from MinGW to TCC.

Generate required TCC defs.

```
tcc -impdef user32.dll -o lib\user32.def
tcc -impdef gdi32.dll -o lib\gdi32.def
tcc -impdef opengl32.dll -o lib\opengl32.def
tcc -impdef glu32.dll -o lib\glu32.def
```

Create run script.

```
@echo off
%dp~0tcc -run -luser32 -lgdi32 -lopengl32 -lglu32 %*
```
Java program to find Nth fibonacci number
Tags: java, programming, coding
Published: 2024-03-17 15:19:09

Fibonacci sequence computation is a classical problem. Traditionally, methods like recursive and iterative algorithms have been employed, but they tend to exhibit exponential time complexity, which becomes impractical for large inputs. The program given below introduces a novel approach to compute the nth Fibonacci number efficiently using matrix exponentiation in Java.

## Matrix Exponentiation for Fibonacci Computation:
The crux of the proposed solution lies in representing the Fibonacci recurrence relation as a matrix exponentiation problem. Consider the `matrix M = [[1, 1], [1, 0]],` and let `F(n)` represent the nth Fibonacci number. By raising the matrix M to the power of `n-1` using recursive matrix exponentiation, we obtain the desired result in logarithmic time complexity.

```
import java.util.*;
public class NthFibonacci {
static final int MOD = (int) 1e9 + 7;

//Method to perform matrix multiplication
static long[][] multiply(long[][] A, long[][] B) {
int rowA = A.length;
int colA = A[0].length;
int colB = B[0].length;
long[][] C = new long[rowA][colB];
for (int i = 0; i < rowA; i++) {
for (int j = 0; j < colB; j++) {
for (int k = 0; k < colA; k++) {
C[i][j] = (C[i][j] + (A[i][k] * B[k][j]) % MOD) % MOD;
}
}
}
return C;
}

//Method to perform matrix exponentiation
static long[][] power(long[][] M, int n) {
if (n == 1) return M;
long[][] half = power(M, n / 2);
long[][] result = multiply(half, half);
if (n % 2 == 1) result = multiply(result, M);
return result;
}

//Method to find the Nth Fibonacci number using matrix exponentiation
public static int fibonacciNumber(int n) {
if (n <= 1) return n;
long[][] M = {{1, 1}, {1, 0}};
long[][] result = power(M, n - 1);
return (int) result[0][0];
}

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
System.out.println(fibonacciNumber(n));
scanner.close();
}
}
```
The **_power _**method calculates the matrix raised to the `power of N`. It uses recursion and optimizes the process by halving the exponent at each step. The method called **_multiply _**performs matrix multiplication. This is a key operation in the matrix exponentiation technique.

This program efficiently calculates the nth Fibonacci number using matrix exponentiation, which has a time complexity of `O(log n)`, making it much faster than the traditional recursive approach with `O(2^n)` time complexity.
English translation Study
Published: 2024-03-17 15:08:04

1.get them up to date  let somthing is newest；
e.g. reinstall code to get them to date;
2.Volta makes global installs a first-class part of the JavaScript tooling experience,
makes somthing be be is omit
e.g. my teacher make me a good person
making them both convenient and safe to use

3.Volta's functionality depends on creating symlinks, so you must either:
Enable Developer Mode (recommended)
Run Volta with elevated privileges (not recommended)
  unfamiliar word:functionality symlinks;elevated privileges
4.These two features combined mean that Volta solves the problem of global packages. 
combined modify These two features; These two features combined  
is subject; combined can be front of These two features;