Skip to content

Instantly share code, notes, and snippets.

View uzbekdev1's full-sized avatar
🌴
On vacation

Elyor Latipov uzbekdev1

🌴
On vacation
View GitHub Profile
@uzbekdev1
uzbekdev1 / Dockerfile
Created June 2, 2021 13:03 — forked from artisticcheese/Dockerfile
Dockerfile to build IIS + nanoserver + ASP.NET core
# escape=`
# Image with NET CORE installation to extract executables for final image
FROM microsoft/aspnetcore:2.0.0-nanoserver As CoreBuild
# Middleware image used to extract ASP.NET core module
From microsoft/iis as WindowsBuild
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'Continue'; $verbosePreference='Continue';"]
# Installing NET CORE webhosting in middleware image so latest module and configuration schema is extracted for final image
ADD https://download.microsoft.com/download/B/1/D/B1D7D5BF-3920-47AA-94BD-7A6E48822F18/DotNetCore.2.0.0-WindowsHosting.exe ".\hosting.exe"
@uzbekdev1
uzbekdev1 / CountryCodes.json
Created May 30, 2021 09:59 — forked from anubhavshrimal/CountryCodes.json
Country and Dial or Phone codes in JSON format
[
{
"name": "Afghanistan",
"dial_code": "+93",
"code": "AF"
},
{
"name": "Aland Islands",
"dial_code": "+358",
"code": "AX"
@uzbekdev1
uzbekdev1 / gist:3b62179fe6e0cab9f3b649075f97e100
Created May 14, 2021 21:50 — forked from darkfall/gist:1656050
A simple class that converts a image to a icon in c# without losing image color data, unlike System.Drawing.Icon; ico with png data requires Windows Vista or above
class PngIconConverter
{
/* input image with width = height is suggested to get the best result */
/* png support in icon was introduced in Windows Vista */
public static bool Convert(System.IO.Stream input_stream, System.IO.Stream output_stream, int size, bool keep_aspect_ratio = false)
{
System.Drawing.Bitmap input_bit = (System.Drawing.Bitmap)System.Drawing.Bitmap.FromStream(input_stream);
if (input_bit != null)
{
int width, height;
@uzbekdev1
uzbekdev1 / gist:5569699f95128f3e69b4f359bb775f52
Created April 28, 2021 08:27 — forked from shanselman/gist:992458
Trying to improve ASP.NET MVC Unobtrusive validation with localization
<script>
$(document).ready(function () {
//Ask ASP.NET what culture we prefer, because we stuck it in a meta tag
var data = $("meta[name='accept-language']").attr("content")
//Tell jQuery to figure it out also on the client side.
$.global.preferCulture(data);
//Tell the validator, for example,
// that we want numbers parsed a certain way!
@uzbekdev1
uzbekdev1 / MetaAcceptLanguage.cs
Created April 28, 2021 08:26 — forked from hellraiser75/MetaAcceptLanguage.cs
Setting globalization in jQuery
namespace System.Web.Mvc
{
public static class LocalizationHelpers
{
public static IHtmlString MetaAcceptLanguage<t>(this HtmlHelper<t> html)
{
var acceptLanguage = HttpUtility.HtmlAttributeEncode(Threading.Thread.CurrentThread.CurrentUICulture.ToString());
return new HtmlString(String.Format("<meta name="\" accept-language\""="" content="\" {0}\""="">",acceptLanguage));
}
}
@uzbekdev1
uzbekdev1 / nginxproxy.md
Created April 9, 2021 08:32 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@uzbekdev1
uzbekdev1 / nginx.conf.j2
Created April 7, 2021 22:50 — forked from RiFi2k/nginx.conf.j2
Trellis nginx.conf file to include setting the real IP from Cloudflare if you use their DNS and SSL certs - https://github.com/roots/trellis/blob/master/roles/nginx/templates/nginx.conf.j2
# {{ ansible_managed }}
# nginx Configuration File
# http://wiki.nginx.org/Configuration
# Run as a less privileged user for security reasons.
user {{ nginx_user }};
# How many worker threads to run;
# "auto" sets it to the number of CPU cores available in the system, and
@uzbekdev1
uzbekdev1 / nuxt.config.js
Created March 30, 2021 17:39 — forked from rvanzon/nuxt.config.js
A way to use vue-chartjs as a plugin of Nuxt.js
// just an example. A cleaner way is to wrap the showLine-stuff in a dedicated component
<template>
<div>
<my-line v-if="showLine" :data="lineData" :options="options">
</div>
</template>
<script>
export default {
data () {
@uzbekdev1
uzbekdev1 / Program.cs
Created March 30, 2021 09:52 — forked from ThatRendle/Program.cs
Get server URLs in .NET Core 3.1 app
public static async Task Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
var task = host.RunAsync();
var serverAddresses = host.Services.GetRequiredService<IServer>()
.Features
.Get<IServerAddressesFeature>();
@uzbekdev1
uzbekdev1 / ObjectComparer.cs
Created March 27, 2021 17:44 — forked from danielkillyevo/ObjectComparer.cs
c# object deep comparison
public class ObjectComparer
{
public static bool Equals(object left, object right)
{
//Compare the references
if (object.ReferenceEquals(right, null))
return false;
if (object.ReferenceEquals(left, right))
return true;