اشتراک‌ها
کامپوننت ها در AngularJs 2
this post, we are going to talk about Components, which elegantly replace the mix of controllers, scopes, and directives from Angular 1 
کامپوننت ها در AngularJs 2
اشتراک‌ها
بررسی چالش‌های استفاده از UTC و TimeZones در برنامه‌های تحت وب مبتنی‌بر ‪.NET

Using UTC in Applications

Using UTC dates for data is a pretty common and necessary practice but it definitely adds some complexity when managing dates as you always have to remember to properly adjust dates. For display purposes this is pretty straight forward, but for query operations there’s a bit of mental overhead to ensure your date math adds up properly.

No easy solutions, but I hope this post and some of the helpers make life a little easier for you – I know they do for me. 

بررسی چالش‌های استفاده از UTC و TimeZones در برنامه‌های تحت وب مبتنی‌بر ‪.NET
اشتراک‌ها
پیاده‌سازی فرآیند Impersonation در ASP.NET Core

Impersonation Process

Impersonation is when an admin user is logged in with the same privileges as a user, but without knowing their password or other credentials. I’ve used this in couple applications and it was invaluable for support cases and debugging user permissions. 

[Authorize(Roles = "Admin")] // <-- Make sure only admins can access this 
public async Task<IActionResult> ImpersonateUser(String userId)
{
    var currentUserId = User.GetUserId();

    var impersonatedUser = await _userManager.FindByIdAsync(userId);

    var userPrincipal = await _signInManager.CreateUserPrincipalAsync(impersonatedUser);

    userPrincipal.Identities.First().AddClaim(new Claim("OriginalUserId", currentUserId));
    userPrincipal.Identities.First().AddClaim(new Claim("IsImpersonating", "true"));

    // sign out the current user
    await _signInManager.SignOutAsync();

    await HttpContext.Authentication.SignInAsync(cookieOptions.ApplicationCookieAuthenticationScheme, userPrincipal);

    return RedirectToAction("Index", "Home");
}


پیاده‌سازی فرآیند Impersonation در ASP.NET Core
بازخوردهای پروژه‌ها
متود IsIn
متاسفانه من ابزار لازم را برای pull request ندارم برای همین به جاش اینجا مواردی را که دوست دارم ارائه میدهم:
        /// <summary>
        /// (Syntactic Sugar) Checks if the given value is among a list of values or not.
        /// </summary>
        /// <remarks>
        /// This method is for syntactic sugar. What it actually does is to allow developers to wrtie a code like this
        /// <code>
        /// xVariable.IsIn(MyEnum.Value1,MyEnum.Value2)
        /// </code>
        /// Instead of these codes:
        /// <code>
        /// new []{ MyEnum.Value1, MyEnum.Value2 }.Contains(xVariable);
        /// </code>
        /// Or more commonly:
        /// <code>
        /// xVariable == MyEnum.Value1 || xVariable == MyEnum.Value2
        /// </code>
        /// </remarks>
        /// <typeparam name="T"></typeparam>
        /// <param name="source"></param>
        /// <param name="list"></param>
        /// <returns></returns>
        public static bool IsIn<T>(this T source, params T[] list)
        {
            Func<T, T, bool> compare = (v1, v2) => EqualityComparer<T>.Default.Equals(v1, v2);
            return list.Any(item => compare(item, source));
        }
اشتراک‌ها
آیا SPA همان قسمت Front-end است؟

It is common when working on a web application, comprised of a server-side Web API, running on a framework like ASP.NET or NestJS, and a client-side Single Page Application (SPA), running on a framework like Angular, to refer to the server-side as "the back-end" and to the client-side as "the front-end". I've been a culprit of this until recently.  

آیا SPA همان قسمت Front-end است؟
اشتراک‌ها
Visual Studio 2017 نگارش 15.5.4 منتشر شد

These are the customer-reported issues addressed in this release:
- The debugger cannot continue running the process. Operation not supported. Unknown error: 0x9233000b.
- Recent Projects and Solutions not populated once executed.
- Full build every time with 15.5.
- Wrong IntelliSense errors are still shown on VS 15.5.2 for Visual Basic projects.
- VS2017 15.5.2 Unresolved references when "Allow parallel project initialization" is enabled.
- Upgrading to 15.5.2: cannot launch nor repair VS.
- VS2017 Installation issue.
- Unable to install because of BSoD.

Visual Studio 2017 نگارش 15.5.4 منتشر شد
اشتراک‌ها
استفاده از GoogleMaps در Android (پایه)
Without a doubt, maps are one of the most useful tools for users when included in an app. This tutorial is the first in a series going over Google Maps v2 for Android. It will cover setting up the Google Maps API through the Google Developer Console, including a map fragment in your applications, displaying the user's location, adding markers, drawing on the map, and some general methods that will add utility to your app.
Intermediate  & Advanced
استفاده از GoogleMaps در Android (پایه)
نظرات مطالب
React 16x - قسمت 30 - React Hooks - بخش 1 - معرفی useState و useEffect
یکبار متن را مطالعه کنید؛ قسمت «استفاده از مقدار قبلی state توسط useState ».
« ... اعمال این متد نیز ممکن است در صف قرار گیرد. یعنی اگر پس از فراخوانی this.setState، سعی در خواندن state به روز شده را داشته باشیم، ممکن است مقدار اشتباهی را دریافت کنیم ...»
اگر می‌خواهید به این زمان دقیق به روز رسانی در همانجا دسترسی پیدا کنید باید از callback آن به صورت زیر استفاده کنید (چون فراخوانی تنظیم state یک عمل غیرهمزمان است، جهت اعلام نیاز به به‌روز رسانی UI و بلافاصله پس از فراخوانی آن (این اعلام درخواست)، کدهای پس از آن اجرا می‌شوند):
this.setState({ name: "myname" }, () => {                              
        //callback
        // this function will be executed after the state change occurs
        console.log(this.state.name) // myname
      });
معادل این قطعه کد با هوک‌ها به صورت زیر است:
useEffect(() => console.log("re-render because x changed:", x), [x]);
//[x] is a dependency array, useEffect will run only when x changes.
نیاز به یک useEffect هست که به تغییرات x واکنش نشان دهد. callback آن پس از به روز رسانی x فراخوانی می‌شود.
نظرات مطالب
استفاده از modal dialogs مجموعه Twitter Bootstrap برای گرفتن تائید از کاربر
نیاز به یک سری تغییرات در CSS و JS دارد:
.modal.modal-wide .modal-dialog {
  width: 90%;
}
.modal-wide .modal-body {
  overflow-y: auto;
}

/* irrelevant styling */
body { text-align: center; }
body p { 
  max-width: 400px; 
  margin: 20px auto; 
}
#tallModal .modal-body p { margin-bottom: 900px }

// when .modal-wide opened, set content-body height based on browser 
// height; 200 is appx height of modal padding, modal title and button bar

$(".modal-wide").on("show.bs.modal", function() {
  var height = $(window).height() - 200;
  $(this).find(".modal-body").css("max-height", height);
});
مثال قابل اجرا
+ یک مثال دیگر: ^