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 / 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;
@uzbekdev1
uzbekdev1 / Dockerfile
Created March 27, 2021 10:37 — forked from grant/Dockerfile
Run Node 12 Dockerfile
# Use the official Node.js 12 image.
# https://hub.docker.com/_/node
FROM node:12
# Create and change to the app directory.
WORKDIR /usr/src/app
# Copy application dependency manifests to the container image.
# A wildcard is used to ensure both package.json AND package-lock.json are copied.
# Copying this separately prevents re-running npm install on every code change.
COPY package*.json ./
# Install production dependencies.
@uzbekdev1
uzbekdev1 / CarController.cs
Created March 3, 2021 09:12 — forked from johnnyreilly/CarController.cs
Unit testing ModelState using Moq
using System.Web.Mvc;
namespace MyApp
{
public class CarController : Controller
{
//...
public ActionResult Edit(CarModel model)
{
@uzbekdev1
uzbekdev1 / pdf_metadata_cleanup.md
Created February 16, 2021 13:40 — forked from righettod/pdf_metadata_cleanup.md
Java and C# code to cleanup the metadata from a PDF document.

Code sample

All librairies used are free and open source.

Java

/* 
  See https://pdfbox.apache.org 
  See https://mvnrepository.com/artifact/org.apache.pdfbox/pdfbox for released artifacts