TGViewer
Channel Public Channel
Programming & AI Tips 💡

Programming & AI Tips 💡

@programmingtip

Programming & AI:
Tips 💡
Articles 📕
AI & LLMs 👾
Design, Architecture, Principles ✅

🇳🇱 Contact: @MoienTajik
Subscribers
46.3K
Photos
67
Videos
11
Links
375

Showing posts older than #374 · Back to latest

Older Posts 20 shown
Post #373 3.51K
Send ETag headers in ASP.NET Core ✨

ASP.NET Core doesn’t add an ETag header automatically to HTTP responses from MVC action methods or Razor Pages. ❌

We have to implement that ourselves to provide the users with true Conditional GET support that honors the If-None-Match request header. ✅

Wouldn’t it be nice if all we had to do was to register it using app.UseETagger() like this❓

https://t.me/pgimg/88

[ Article ] : http://bit.do/etags

〰〰〰〰〰〰
#AspMvc #AspCore #ETag
@ProgrammingTip
Telegram Programming Tips Resources
Post #371 3.78K
Quick Tip: How to pass visual alerts with an HTMLHelper⚠️

It will display a Bootstrap alert if there is a message passed through the ViewModel. 💥

This message can be a success, error, warning, or informational message. 🌈

The nice thing about the ViewMessage HtmlHelper is that if we don't pass it into our views, it won't display anything. 🎛

https://t.me/pgimg/87

[ Article ] : http://bit.do/alhl

〰〰〰〰〰〰
#AspMvc #CleanCode
@ProgrammingTip
Telegram Programming Tips Resources
Post #370 4.21K
Xamarin VS Ionic VS React Native 🔥

Traditionally, Android applications are developed in Java, and iOS ones are written in Swift and Objective-C. ⚛️

Nevertheless, there exist plenty of other alternate tools that can be used instead. 👨🏻‍💻

Xamarin, React Native and Ionic are popular examples of such tools. 💎

What is their purpose❓
What makes them different❓
Which of them is the best❓

We’ll try to answer these questions in the article below. ⬇️

https://t.me/pgimg/86

[ Article ] : http://bit.do/cpfo

〰〰〰〰〰〰
#Xamarin #ReactNative #Ionic
@ProgrammingTip
Telegram Programming Tips Resources
Post #368 3.7K
Passport.Js ⚡️

Passport is authentication middleware for Node.js.

Extremely flexible and modular, Passport can be unobtrusively dropped in to any Express-based web application. 🔥

A comprehensive set of strategies support authentication using a username and password, Facebook, Twitter, and more. 🐦

https://t.me/pgimg/85

[ Website ] : passportjs.org

〰〰〰〰〰〰
#JavaScript #NodeJs #Authentication
@ProgrammingTip
Telegram Programming Tips Resources
Post #367 3.42K
dbForge Event Profiler ⚡️

dbForge Event Profiler for SQL Server is a FREE tool that allows you to capture and analyze SQL Server events. ☁️

The events and data columns are stored in a physical trace file for later examination. 📋

You can use this information to identify and troubleshoot many SQL Server-related problems. 🐞

https://t.me/pgimg/83

[ Download ] : https://t.me/pgimg/84
[ Website ] : http://bit.do/dbfor

〰〰〰〰〰〰
#SQLServer #Profiler #DbForge
@ProgrammingTip
Telegram Programming Tips Resources
Post #366 3.23K
JavaScript - Map vs. ForEach 🗺

What’s the difference between Map and ForEach in JavaScript❓

Let’s first take a look at the definitions on MDN 🌀 :
• forEach() ➖ executes a provided function once for each array element.

• map() ➖ creates a new array with the results of calling a provided function on every element in the calling array.

What exactly does this mean❔

https://t.me/pgimg/81

[ Article ] : http://bit.do/mapjs

〰〰〰〰〰〰
#JavaScript #ForEach #Map
@ProgrammingTip
Telegram Programming Tips Resources
Post #365 3.13K
Keyv 🗂

Keyv provides a consistent interface for key-value storage across multiple backends via storage adapters. ⚡️

It supports TTL based expiry, making it suitable as a cache or a persistent key-value store. ⏰

By default everything is stored in memory, you can optionally also install a storage adapter. 🗄

Supported Storage Adapters ✅ :
• Redis
• Mongo
• SQLite
• Postgres
• MySQL

https://t.me/pgimg/80

[ Website ] : http://bit.do/keyv

〰〰〰〰〰〰
#JavaScript #KeyValue #Storage
@ProgrammingTip
Telegram Programming Tips Resources
Post #364 3.06K
Polly 🕊

Polly is a .NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner. ♻️


Installing via NuGet 🗃 :
Install-Package Polly


Usage :
public class Mailer
{
public static bool SendEmail()
{
Console.WriteLine("Sending Mail ...");

// simulate error
Random rnd = new Random();
var rndNumber = rnd.Next(1, 10);
if (rndNumber != 3)
throw new SmtpFailedRecipientException();

Console.WriteLine("Mail Sent successfully");
return true;
}
}


We retry to send the email 3 times if something failed ❌ :

var policy = Policy.Handle<SmtpFailedRecipientException>().Retry(3);
policy.Execute(Mailer.SendEmail);


🔹🔸🔹🔸

https://t.me/pgimg/79

[ Github ] : http://bit.do/pollyc

〰〰〰〰〰〰
#CSharp #RetryPattern
@ProgrammingTip
Telegram Programming Tips Resources
Post #363 3.03K
Fluent Validation ⚠️

A small validation library for .NET that uses a fluent interface and lambda expressions for building validation rules. 🚫

NuGet Packages :
Install-Package FluentValidation


For ASP.NET MVC integration :
Install-Package FluentValidation.MVC5


For ASP.NET Core :
Install-Package FluentValidation.AspNetCore


🔹🔸🔹🔸

Example :

public class PersonValidator : AbstractValidator<Person>
{
public PersonValidator()
{
RuleFor(x => x.ID).NotEmpty();

RuleFor(x => x.FirstName)
.NotEmpty()
.WithMessage("{PropertyName} is required !")
.MinimumLength(5)
.WithMessage("Minimum length for {PropertyName} is {MinLength} !");

RuleFor(x => x.LastName)
.NotEmpty()
.WithMessage("{PropertyName} is required !")
.MinimumLength(5)
.WithMessage("Minimum length for {PropertyName} is {MinLength} !");

RuleFor(x => x.Email)
.NotEmpty()
.WithMessage("{PropertyName} is required !")
.EmailAddress()
.WithMessage("{PropertyName} is not valid !");
}
}


🔹🔸🔹🔸

https://t.me/pgimg/78

[ Github ] : http://bit.do/flval

〰〰〰〰〰〰
#CSharp #AspMvc #Validation
@ProgrammingTip
Telegram Programming Tips Resources
Post #362 2.83K
Writing middleware for use in Express.js apps 🔥

Overview 🔎
Middleware functions are functions that have access to the request object (req), the response object (res), and the next function in the application’s request-response cycle.

The next function is a function in the Express router which, when invoked, executes the middleware succeeding the current middleware. ⏭

Middleware can perform 💎
• Execute any code.
• Make changes to the request and the response objects.
• End the request-response cycle.
• Call the next middleware in the stack.

🔸🔹🔸🔹

Configurable middleware 📥
If you need your middleware to be configurable, export a function which accepts an options object or other parameters, which, then returns the middleware implementation based on the input parameters.

in my-middleware.js


module.exports = function(options) {
return function(req, res, next) {
// Implement the middleware function
next();
}
}


🔸🔹🔸🔹

Usage Middleware 📤
The middleware can now be used as shown below.

const mddleware = require('./my-middleware.js')
app.use(mddleware({ option1: '1', option2: '2' }))


https://t.me/pgimg/77

〰〰〰〰〰〰
#JavaScript #Express #Middleware
@ProgrammingTip
Telegram Programming Tips Resources
Post #361 2.67K
Why I am in love with ES6❓

ES6 brings many new features to vanilla javascript making the language do more with less syntax. 🔥

New features like let and fat arrows let us manage scope very easily too. 🙇🏻

Some of ES6 new features 💎 :
• Fat arrows
• Rest/Spread Operators
• Object Deconstruction
• Default Parameters
• import & export keywords

https://t.me/pgimg/76

[ Article ] : http://bit.do/es6

〰〰〰〰〰〰
#JavaScript #ES6
@ProgrammingTip
Telegram Programming Tips Resources
Post #359 2.87K
Angular 4 Custom Validation for Template Driven forms 🅰️

This article consists an example for a custom email validator using regex. 🌐

Angular 4 Already has a built-in validator for this “ng-pattern”. ⚠️

But this article is more focused on creating a base for custom validators so you could improve and use it for other use cases. 💎

Usage :
<input type="email" emailvalidator>



https://t.me/pgimg/74

[ Website ] : http://bit.do/anva

〰〰〰〰〰〰
#JavaScript #Angular #Forms
@ProgrammingTip
Telegram Programming Tips Resources
Post #355 2.7K
What is Dynamic Proxy❓

A proxy, in its most general form, is a class functioning as an interface to something else. ↗️

The proxy could interface to anything :
• A network connection 🌐
• A large object in memory 🗂
• A file 📄
• Some other resource that is expensive or impossible to duplicate. 💸

🔹🔸🔹🔸🔹🔸

One way of thinking about proxies, is by the analogy to The Matrix 🕶 by Krzysztof Koźmic 🤔 :

“People in the matrix aren’t the actual people ( “The spoon does not exist”, remember❓)

They’re proxies to the actual people that can be… wherever.🌍

They look like ones, they behave like ones, but at the same time, they are not them actually.🙅🏻‍♂️

Another implication is the fact that different rules apply to proxies.✳️

Proxies can be what the proxied objects are, but they can be more (flying, running away from bullets, that kind of stuff).✈️

One more important thing, is that proxies ultimately delegate the behavior to the actual objects behind them (kind of like – “if you’re killed in the matrix, you die in the real life as well”☠️).”


A dynamic proxy is a proxy that is generated on the fly at runtime. ✅

https://t.me/pgimg/70

〰〰〰〰〰〰
#Proxy #DynamicProxy
@ProgrammingTip
Telegram Programming Tips Resources
Post #353 2.99K
File Ultimate 🔥

File manager control for integrating file browsing, upload & download features into your ASP.NET MVC & WebForms application or site rapidly. 💎

Supports ✨ :
• ASP.NET Web Forms ( C# )
• ASP.NET Web Forms ( VB )
• ASP.NET MVC ( C# )
• ASP.NET MVC ( VB )

Features ⚡️ :
• Browse and manage files with access control.

• Accept files with the advanced upload functionality.

• Offer a structured and neat download area.

• Preview documents (70+ file formats, including PDF © Microsoft Office), images, audios and videos.

🔹🔸🔹🔸

https://t.me/pgimg/69

[ Github ] : http://bit.do/fgit
[ Demo ] : http://bit.do/fmade

〰〰〰〰〰〰
#AspMvc #FileManager #Uploader
@ProgrammingTip
Telegram Programming Tips Resources
Older posts →
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →