Programming Tips 💡 – Telegram
Programming Tips 💡
51.6K subscribers
67 photos
10 videos
30 files
355 links
Programming & AI:
Tips 💡
Articles 📕
Resources 👾
Design Patterns 💎
Software Principles

🇳🇱 Contact: @MoienTajik

🎯 Buy ads: https://telega.io/c/ProgrammingTip
Download Telegram
Auth0: Introduction and Initial ASP.NET MVC Project Setup 🚀

The big selling points for Auth0, and other services like it, are that it removes you from having to worry about Auth/User Management and get to the part of your applications that bring value to your customers. 👥

As with Identity Server, Auth0 can use OpenID Connect (as well as a lot of other protocols), single sign-on and API Access Control.

https://news.1rj.ru/str/pgimg/94

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


#AspMvc #Auth0 #Authentication
@ProgrammingTip
Google it 😂🤦‍♂️


#Fun
@ProgrammingTip
Architecting Services with Design Patterns 💎

As the number of your services expands you're going to need to start thinking about how to organize them. 🗂

Applying these two design patterns can help, provided you understand all their variations.

With the current set of tools that come with the Microsoft .NET Framework, it's easy to create a service. ⚙️

But it's also easy to create what both Nayaki Nayyar and Benjamin Moreland described as a "junk drawer of services." 👾

If you're going to avoid that as the number of services in your organization increases, then you need to think about your architecture. 🤔

https://news.1rj.ru/str/pgimg/95

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


#CleanCode #DesignPatterns
@ProgrammingTip
5 More C# Extension Methods for the Stocking A Bonus Method For Enums ! 💥


1️⃣ ToInt()
We always have the familiar .ToString(), but what happens when we want to convert a simple string to an integer

🔹🔸🔹

2️⃣ OrdinalSuffix()
This extension method places a 'th', 'st', 'nd', 'rd', or 'th' to the end of the number. 🔚

🔸🔹🔸

3️⃣ Occurrence()
This just counts the number of occurrences in a string. 🔍

🔹🔸🔹

4️⃣ Join<T>()/Join()
With this extension method, you can take an array or List<string>() and make a comma-delimited list in no time or build a broken-up URL with dashes as the URL name.

🔸🔹🔸

5️⃣ ToQueryString()
Have you ever wanted to take a NameValueCollection and convert it into a query string for a URL ? 🌐

🔹🔸🔹

⚡️ Enums.ToList<T>() - Bonus Method

This Enums.ToList<T> static method is meant to take enumerations with denoscription attributes and convert them into a NameValueCollection for possibly a dropdown. 📜

🔸🔹🔸

https://news.1rj.ru/str/pgimg/96

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


#CSharp #ExtensionMethod
@ProgrammingTip
JavaScript — Null vs. Undefined ⚡️

Learn the differences and similarities between null and undefined in JavaScript. ⁉️

At first glance, null and undefined may seem the same, but they are far from it. ↔️

This article will explore the differences and similarities between null and undefined in JavaScript.

https://news.1rj.ru/str/pgimg/97

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


#JavaScript #Null
@ProgrammingTip
Use T4MVC to Remove Magic Strings in ASP.NET MVC Apps 🎩

ASP.NET MVC has a fascination with magic strings.

Basically any time you need to specify an action, a view, or controller, you use a magic string :

return RedirectToAction("Index", "Home", new { id = 4 });

return View("Details");

@Html.ActionLink("Back to details", "Detals", "User", new {id = 12}, new {@class = "backlink"});

@using (Html.BeginForm("Details", "User", FormMethod.Post))


The problem with magic strings is the same problem that ViewBag has ⚠️ :

1️⃣ There's no type checking.

2️⃣ The developer won't catch these errors until runtime, and sometimes not at all.

🔹🔸🔹🔸

T4MVC aims to remove magic strings from MVC and replace them with strongly-typed ActionResults.

It adds a bunch more overloads to methods such as ActionLink(), BeginForm(), and RedirectToAction() so that they can now accept ActionResults as parameters. 🗃

Thereby making them strongly-typed and removing their dependency on magic strings. 💎

Most importantly, it means we can take the above code samples and refactor them to look like this 🤙🏻 :

return RedirectToAction(MVC.Home.Index(4));

return View(MVC.User.Views.ViewNames.Details);

@Html.ActionLink("Back to details", MVC.User.Details(12), new {@class = "backlink"});

@using (Html.BeginForm(MVC.User.Details(), FormMethod.Post))



https://news.1rj.ru/str/pgimg/98

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


#AspMvc #CleanCode #T4MVC
@ProgrammingTip
Q&A: Successful Developer Career Strategies 💎

The field of computer science is huge, far too wide for anyone to master in all areas. 🌍

We all need to make difficult choices about how and where we spend our time.

It’s often said that in order to be successful in this industry you need to specialize. 🤓

But it’s also often said that you need a wide range of experience.

So what is more important : breadth or depth ⁉️

This is a very difficult question, and is why I asked for the advice of some of the very brightest minds in our industry. 👑

Our expert panel is comprised of the following seven developers 👥 :

Scott Allen
Mark Seemann
Julie Lerman
Kyle Simpson
Troy Hunt
Oren Eini
Cory House

https://news.1rj.ru/str/pgimg/99

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


#QA #Strategy
@ProgrammingTip
ASP.NET Core Interview Questions 💼

This post is about ASP.NET Core Interview Questions. ⁉️

These questions are directly tied to ASP.NET Core.

They are not meant to serve as only questions that you would ask a candidate during an interview.

Use these to assess if the candidate has any knowledge about ASP.NET Core. 👓

The questions should serve as guidelines for core ASP.NET Core concepts that candidate should be familiar with. 👪

https://news.1rj.ru/str/pgimg/100

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


#AspMvc #AspCore #Core #Interview
@ProgrammingTip
Generating Friendly URLs in ASP.NET MVC 🦄

Have a look at the following URL 👀 :

http://www.amazon.com/gp/product/1617292397/ref=s9_psimh_gw_p14_d4_i1?pf_rd_m=ATVPDKIKX0DER&pf_rd_s=desktop-1&pf_rd_r=0TFM5Q6WM6KD9NPNG9G7&pf_rd_t=36701&pf_rd_p=2079475242&pf_rd_i=desktop


Do you have any idea what the URL is pointing to by just looking at itMost likely not.

Now look at this one 💎 :

http://www.dpreview.com/articles/9485436827/the-big-beast-hands-on-with-the-panasonic-lumix-dmc-gx8


Any ideaWell it would seem that it is an article about a hands-on with the Panasonic Lumix DMX-GX8. 🖥

In today’s blog post I would like to demonstrate how to generate “friendly URLs” in your ASP.NET applications.

Friendly not just in the sense that someone can look at it and figure out what the URL is pointing to, but more importantly friendly for search engines. 🌐

https://news.1rj.ru/str/pgimg/101

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


#AspMvc #SEO
@ProgrammingTip
Fasify.io ⚡️

An efficient server implies a lower cost of the infrastructure, a better responsiveness under load and happy users. 🤓

How can you efficiently handle the resources of your server, knowing that you are serving the highest number of requests as possible, without sacrificing security validations and handy development ⁉️

Enter Fastify. Fastify is a web framework highly focused on providing the best developer experience with the least overhead and a powerful plugin architecture. It is inspired by Hapi and Express and as far as we know, it is one of the fastest web frameworks in town. 🔥

Install 📥
npm install fastify --save


🔹🔸🔹🔸


[ Example ]

// Require the framework and instantiate it
const fastify = require("fastify") ()

// Declare a route
fastify.get("/", function (request, reply) {
reply.send({ hello: "world" })
})

fastify.listen(3000, function (err) {
if (err) throw err
console.log(`server listening on ${fastify.server.address().port}`)
})


🔹🔸🔹🔸


[ Async-Example ]

const fastify = require('fastify')()

fastify.get('/', async (request, reply) => {
reply.type('application/json').code(200)
return { hello: 'world' }
})

fastify.listen(3000, function (err) {
if (err) throw err
console.log(`server listening on ${fastify.server.address().port}`)
})


https://news.1rj.ru/str/pgimg/102


[ Website ] : https://www.fastify.io


#JavaScript #NPM #Fastify
@ProgrammingTip
Anatomy of an ASP.NET Identity PasswordHash 🔐

Have you ever looked at a user record in an ASP.NET Identity’s users table and wondered just what is being saved on the PasswordHash column

It looks like this (it’s in base64) :
AQAAAAEAACcQAAAAEJSPbbFM1aeXB8fGRV7RRamLpjzktAF7FjwDWtFx35eol4AxN6vm4zWR9EApc7WPsQ


Apart from maybe satisfying your curiosity, what could you benefit from knowing exactly what’s on that seemingly random sequence of characters

Well, you could confidently update from different versions of ASP.NET Identity. 🌀

Also, if you ever get tired of ASP.NET Identity for whatever reason, you could move your user accounts to whatever alternative you found that might be better.

Or, you just want to have a simple users’ table and not have to deal with all of what you need to know to make ASP.NET Identity work. 👥

All of this while still being able to move your user accounts to ASP.NET Identity some day if you choose to do so. ♻️

https://news.1rj.ru/str/pgimg/103

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


#AspMvc #Identity
@ProgrammingTip
The Clean Coder.pdf
2.8 MB
The Clean Coder : A Code of Conduct for Professional Programmers📕

Author : Robert C. Martin 🖊

Level : Advanced 💎


#Book #CleanCode
@ProgrammingTip
Mocky 🤖

Mock your HTTP responses to test your REST API. 👾

Mocky is a simple app which allows to generate custom HTTP responses. 🌐

It's helpful when you have to request a build-in-progress WS, when you want to mock the backend response in a singleapp, or when you want to test your WS client.

Is Mocky online
Yes, Mocky is online, free and unlimited. 💸

https://news.1rj.ru/str/pgimg/104

[ Website ] : mocky.io


#Mock #Rest
@ProgrammingTip
NopCommerce ID-Less URL Structure Demystified 💎

The link for my NopLite - nopCommerce Responsive Theme is :
http://www.pronopcommerce.com/noplite-nopcommerce-responsive-theme


You don't see ANY integer in the URL, but nopCommerce somehow knows how to map from the URL to the appropriate ID.

On the other hand, the nopCommerce 2.65 URL for my NopLite theme would have been 👎🏻 :
http://www.pronopcommerce.com/p/7/noplite-nopcommerce-responsive-theme


Note the '7' somewhere in between the URL, that's the Integer Product ID. 🗃

So the question is, how does nopCommerce 2.70 and 2.80 know the ID without looking the ID

https://news.1rj.ru/str/pgimg/105

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


#AspMvc #Routing #NopCommerce
@ProgrammingTip
Pretty Checkbox 🌈

A pure CSS library to beautify checkbox and radio buttons.

Framework Compatability 🔥 :
• Angular
• Bootstrap
• React
• Vue

https://news.1rj.ru/str/pgimg/106

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


#CSS #Library
@ProgrammingTip
HTTP codes as Valentine’s Day comics 💙

With Valentine’s Day around the corner, it is a time for romantic hopefuls to ask out the object of their affection, and await an answer. 🤠

It could be a simple “yes,” a sad “no,” or a cryptic “I don’t think about you that way, but maybe we can grab a coffee tomorrow

Which brings us to HTTP (Hypertext Transfer Protocol) codes. 🌐

When a URL is typed in a browser, a request is sent out to the server and the browser awaits an answer, just like in our scenario. ♻️

These answers come in the form of an HTTP code, which is a three-digit number that maps to an answer. 2️⃣0️⃣0️⃣

With the image of Valentine’s Day in mind, here are a few likely scenarios. 😆❤️

https://news.1rj.ru/str/pgimg/107

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


#HTTP #Valentine #Fun
@ProgrammingTip
Pug 🐶

Pug is a high-performance template engine heavily influenced by Haml and implemented with JavaScript for Node.js and browsers.

Pug is a clean, whitespace sensitive syntax for writing html. 🌐

Here is a simple example 💎 :
doctype html
html(lang="en")
head
noscript= pageTitle
noscript(type='text/javanoscript').
if (foo) bar(1 + 5)
body
h1 Pug - node template engine
#container.col
if youAreUsingPug
p You are amazing
else
p Get on it!
p.
Pug is a terse and simple templating language with a
strong focus on performance and powerful features.


Becomes :
<!DOCTYPE html>
<html lang="en">
<head>
<noscript>Pug</noscript>
<noscript type="text/javanoscript">
if (foo) bar(1 + 5)
</noscript>
</head>
<body>
<h1>Pug - node template engine</h1>
<div id="container" class="col">
<p>You are amazing</p>
<p>Pug is a terse and simple templating language with a strong focus on performance and powerful features.</p>
</div>
</body>
</html>


🔸🔹🔸🔹

Implementations in other languages 👾
Ports with very close syntax, adapted to other languages :
• PHP
• Java
• Python
• Ruby
• C# (ASP.NET Core)

https://news.1rj.ru/str/pgimg/108

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


#ViewEngine #TemplateEngine
@ProgrammingTip
Using Google reCAPTCHA in ASP.NET MVC 👾

reCAPTCHA is a free service that protects your website from spam and abuse.

reCAPTCHA uses an advanced risk analysis engine and adaptive Captchas to keep automated software from engaging in abusive activities on your site. 🚫

It does this while letting your valid users pass through with ease. 💎

This article shows how to integrate reCAPTCHA version 2.0 into an ASP.NET MVC website in clean way. ⚡️


Article Author : @MoienTJ

https://news.1rj.ru/str/pgimg/109

[ Article ] : bit.do/recaptcha


#reCaptcha #AspMvc
@ProgrammingTip
Securing ASP.NET Core 2.0 Applications with JWTs + Auth0 🔑

JSON Web Tokens, often shortened with JWTs, are gathering more and more popularity in the Web environment. 🌐

It is an open standard that allows transmitting data between parties as a JSON object in a compact and secure way. 🔁

They are usually used in authentication and information exchange scenarios, since the data transmitted between a source and a target are digitally signed so that they can be easily verified and trusted.

Let's take a look at how to set up a ASP.NET Core 2 application with JWT support by creating a Web API application.

https://news.1rj.ru/str/pgimg/110

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


#AspMvc #Core #JWT
@ProgrammingTip
A Pattern is a solution to a problem in a context.

We're going to step throught each of these parts, context, problem and solution :

The context is the situation in which the pattern applies. This should be a recurring situation. 👨🏻‍🔧

The problem refers to the goal you are trying acheive in this context, but it also refers to any constraints that occur in the context. 🏆

The solution is what you're after : a general design that anyone can apply which resolves the goal and set of constraints. 🏅

Example
Problem: How do I get to work on time

Context: I've locked my keys in the car. 🗝

Solution: Break the window, get in the car, start the engine and drive to work. 🚗


"If you find yourself in a context with a problem that has a goal that is affected by a set of constraints, then you can apply a design that resolves the goal and constraints and leads to a solution."



#DesignPatterns #Tips
@ProgrammingTip