اشتراک‌ها
معرفی کتابخانه های مربوط به پایتون
پایتون زبانی است شی گرا , سطح بالا و مفسر ؛ که در سال 1991 و در هلند توسط خودوفان روسوم طراحی شد.
فلسفهٔ ایجاد آن تاکید بر دو هدف اصلی خوانایی بالای برنامه‌های نوشته شده و کوتاهی و بازدهی نسبی بالای آن بود.
کلمات کلیدی و اصلی این زبان به صورت حداقلی تهیه شده‌اند و در مقابل کتابخانه‌هایی که در اختیار کاربر است بسیار وسیع هستند. یک کار غیر معمول که در طراحی این زبان انجام گرفته استفاده از فاصله و جلوبردن متن برنامه برای مشخص کردن بلوک‌های مختلف کد است. سایت زیر مجموعه ای از کتابخانه‌های پایتون می‌باشد. 

 

معرفی کتابخانه های مربوط به پایتون
اشتراک‌ها
کار با HubContext در ASP.NET Core SignalR

In this section, I’m going to cover how you can use SignalR outside of a Hub. In most asp.net core applications, you will likely want to communicate with the connect clients from within your application but outside of a Hub. You can accomplish this by using the HubContext.

For example, an ASP.NET Core MVC Controller or any other class that is instantiated by ASP.NET Core’s Dependency Injection.

The HubContext allows you to send messages to your connected clients. It has many of the same features to communicate with clients as when you are inside of a Hub.  

کار با HubContext در ASP.NET Core SignalR
اشتراک‌ها
کتاب رایگان Java Succinctly Part 1

Java is a high-level, cross-platform, object-oriented programming language that allows applications to be written once and run on a multitude of different devices. Java applications are ubiquitous, and the language is consistently ranked as one of the most popular and dominant in the world. Christopher Rose’s Java Succinctly Part 1 describes the foundations of Java–from printing a line of text to the console, to inheritance hierarchies in object-oriented programming. The e-book covers practical aspects of programming, such as debugging and using an IDE, as well as the core mechanics of the language.

Table of Contents
  1. Introduction
  2. Getting Started
  3. Writing Output
  4. Reading Input
  5. Data Types and Variables
  6. Operators and Expressions
  7. Control Structures
  8. Object-Oriented Programming
  9. Example Programs and Conclusion 
کتاب رایگان Java Succinctly Part 1
اشتراک‌ها
کتابخانه‌ی Formo برای مدیریت فایل‌های Config
The settings

<appSettings>
    <add key="RetryAttempts" value="5" />
    <add key="ApplicationBuildDate" value="11/4/1999 6:23 AM" />
</appSettings>

The code

dynamic config = new Configuration();
var retryAttempts1 = config.RetryAttempts;                 // returns 5 as a string
var retryAttempts2 = config.RetryAttempts(10);             // returns 5 if found in config, else 10
var retryAttempts3 = config.RetryAttempts(userInput, 10);  // returns 5 if it exists in config, else userInput i
کتابخانه‌ی Formo برای مدیریت فایل‌های Config
اشتراک‌ها
دقیقا چه اتفاقی برای Parler رخ داد؟

Parler relied on several external services for security; but when those services were yanked away (due to Parler hosting neo-nazi and insurrectionist content), their code took the absence of such services as a reason to approve whatever action the user was trying to take. It’s the equivalent of your house security system letting everyone in if the phone-line goes down. There’s so much more to the Parler hack, from the lack of rate-limiting to the ability for people to pull down 60-70TBs of information from Parler’s AWS hosted storage, which — to add insult to injury, results in a massive egress bill from AWS to Parler, on top of AWS no longer hosting Parler. 

دقیقا چه اتفاقی برای Parler رخ داد؟
اشتراک‌ها
2.Visual Studio 2017 15.9 منتشر شد

These are the customer-reported issues addressed in 15.9.2:

2.Visual Studio 2017 15.9 منتشر شد
مطالب
دسته بندی کردن لاگ‌ها در Serilog

در Serilog لاگ‌ها به صورت ترتیبی در فایل و یا در Elasticsearch ذخیره میشوند. این لاگ‌ها زمانیکه تعداد کاربران سایت زیاد میشوند و تعداد آن‌ها نیز افزایش می‌یابد، به صورت تصادفی ( به ازای ریکوئست کاربران ) در Elasticsearch و یا فایل متنی ذخیره میشوند. برای مثال یک کاربر مشغول ثبت سفارش است و کاربر دیگری عملیات استرداد را انجام میدهد و لاگ این دو کاربر به صورت همزمان به مقصد مورد نظر شما ( Elasticsearch و یا فایل متنی ) ارسال میشوند و لاگ‌ها شکل نامرتبی را به خود میگیرند و عملا نمیتوانید یک سفارش را پیگیری کنید. هر چقدر تعداد کاربران و ریکوئست‌ها بیشتر شود، تقریبا پیدا کردن لاگ‌های مربوط به یک اکشن یا api کاملا سخت و یا غیرممکن میشود. اما با استفاده از Serilog.Context.LogContext.PushProperty میتوانید یک scope را تعریف کنید که شامل یک نام و یک مقدار است و تمامی لاگ‌های داخل آن scope، شامل همان نام و مقداری هستند که شما آن‌ها را ایجاد کرده‌اید.
public IActionResult ConfirmOrder(Order order)
{
    using (Serilog.Context.LogContext.PushProperty("OrderId", order.Id))
    {
        _logger.LogInformation("Check order validation");
        //DoSomething
        _logger.LogInformation("Order validation successfully");
        //DoSomething
        _orderService.ConfirmOrder(order);
        _logger.LogInformation("Order confirmed successfully");
    }
    return Ok();
}
با این کار تمامی لاگ‌های ثبت شده در scope مربوط به OrderId، شامل یک پراپرتی به نام OrderId و مقدار order . Id هستند که با این کار میتوانید تمامی ریکوست‌های مربوط به یک اکشن خاص را با آیدی سفارش پیدا کنید. حتی اگر در متد ConfirmOrder مربوط به orderService هم از ILogger استفاده کرده باشید، تمامی لاگ‌های مربوط به orderService هم شامل پراپرتی OrderId هستند. یک نمونه از لاگ‌ها:
{
   "Timestamp":"2020-10-20T23:01:01.0492132+03:30",
   "Level":"Information",
   "MessageTemplate":"Order Confirmed successfully",
   "Properties":{
      "SourceContext":"SerilogExamlpe.WebApplication.Controllers.WeatherForecastController",
      "ActionId":"870582be-312f-4065-88eb-5675e2df4928",
      "ActionName":"SerilogExamlpe.WebApplication.Controllers.WeatherForecastController.Get (SerilogExamlpe.WebApplication)",
      "RequestId":"0HM3L5QM34E6K:00000001",
      "RequestPath":"/weatherforecast",
      "SpanId":"|da92fcac-4169ab4e937de2ae.",
      "TraceId":"da92fcac-4169ab4e937de2ae",
      "ParentId":"",
      "OrderId":12345,//<-- NOTE THIS
      "MachineName":"FARHAD-PC",
      "Environment":"Development"
   }
}
لاگ ثبت شده، مربوط به آخرین لاگ نوشته شده است؛ با مقدار "Order Confirmed successfully". در این لاگ، پراپرتی OrderId را با مقدار 12345 مشاهده میکنید؛ در حالیکه ما فقط یک متن را ثبت کرده‌ایم، ولی در لاگ ثبت شده، اطلاعات اضافه‌ای را برای لاگ ثبت کرده‌است. با این کار میتوانید تمامی لاگ‌های مربوط به سفارش با آیدی 12345 را به راحتی پیدا کنید.
اگر از Serilog استفاده نمیکنید و از ILogger خود دات نت برای ثبت لاگها استفاده میکنید، میتوانید به جای PushProperty از متد BeginScope به صورت زیر استفاده کنید:
using (_logger.BeginScope("OrderId : {orderId}", 12345))
همچنین میتوانید یک میان افزار را ایجاد کنید که آی‌دی و آی‌پی کاربر را در تمامی لاگ‌ها ذخیره کند :
app.Use(async (httpContext, next) =>
{
    //Get username  
    var username = httpContext.User.Identity.IsAuthenticated ? httpContext.User.Identity.Name : "anonymous";
    LogContext.PushProperty("User", username);

    //Get remote IP address  
    var ip = httpContext.Connection.RemoteIpAddress.ToString();
    LogContext.PushProperty("IP", !String.IsNullOrWhiteSpace(ip) ? ip : "unknown");

    await next.Invoke();
});
با این  کار تمامی لاگ‌ها شامل پراپرتی‌های User و IP می‌باشند.