Programming Tips πŸ’‘
51.6K subscribers
67 photos
10 videos
30 files
354 links
Programming & AI:
Tips πŸ’‘
Articles πŸ“•
Resources πŸ‘Ύ
Design Patterns πŸ’Ž
Software Principles βœ…

πŸ‡³πŸ‡± Contact: @MoienTajik

🎯 Buy ads: https://telega.io/c/ProgrammingTip
Download Telegram
Cool, the " Ranges " feature is planned for C# 7.3❗️

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

γ€°γ€°γ€°γ€°γ€°γ€°
#CSharp
@ProgrammingTip
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
All Kyle Simpson's (You Don't Know JS author) courses are free πŸ’Έ untill the next monday❗️

https://t.me/pgimg/71

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

γ€°γ€°γ€°γ€°γ€°γ€°
#JavaScript #ES6 #Tutorial
@ProgrammingTip
Semantic UI React βš›οΈ

Semantic UI React is the official React integration for Semantic UI .πŸ™…πŸ»β€β™‚οΈ

πŸ”Έ jQuery Free
πŸ”Ή Declarative API
πŸ”Έ Augmentation
πŸ”Ή Shorthand Props
πŸ”Έ Sub Components
πŸ”Ή Auto Controlled State

https://t.me/pgimg/72

[ Usage ] : https://react.semantic-ui.com/usage

[ Website ] : https://react.semantic-ui.com

γ€°γ€°γ€°γ€°γ€°γ€°
#React #Semantic #FrontEnd
@ProgrammingTip
The difference between ForEach, and For… In πŸ’«

This is going to be a quick introduction to foreach, and for...in in JavaScript. ☝🏻

This article was written to introduce you to new methods that you can you can use instead of always using for loops.⚑️

https://t.me/pgimg/73

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

γ€°γ€°γ€°γ€°γ€°γ€°
#JavaScript
@ProgrammingTip
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
Improving ASP.NET MVC Routing Configuration βœ…

This post covers some ways you can improve the testability and reduce framework coupling when configuring routing in an ASP.NET MVC application. πŸ”₯

https://t.me/pgimg/75

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

γ€°γ€°γ€°γ€°γ€°γ€°
#AspMvc #Decoupling
@ProgrammingTip
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
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
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
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
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
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
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
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
Writing CV πŸ˜‚
γ€°γ€°γ€°γ€°γ€°γ€°
#Fun #NoSQL
@ProgrammingTip
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
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
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
Automatic ModelState Validation in ASP.NET MVC πŸ”₯

How many times have you seen or written code like this ♻️ :

[HttpPost]
public ActionResult Index(SomeModel model)
{
if (ModelState.IsValid)
{
return View();
}

// do something
return RedirectToAction("index");
}


Stop repeating ModelState checks in your ASP.NET MVC controller actions. ❌

Wouldn’t it be nice if all we had to do was like this ? ⚑️

[HttpPost]
[ValidateModelState]
public ActionResult Index(SomeModel model)
{
// if we get here, ModelState is valid
// save to db etc.
return RedirectToAction("index");
}


https://t.me/pgimg/89

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

γ€°γ€°γ€°γ€°γ€°γ€°
#AspMvc #CleanCode
@ProgrammingTip