Skip to content

Instantly share code, notes, and snippets.

View bezzad's full-sized avatar
:octocat:
Hi

Behzad Khosravifar bezzad

:octocat:
Hi
View GitHub Profile
@hadisfr
hadisfr / outline-server-setup.md
Last active May 24, 2024 05:44 — forked from okeehou/outline-server-setup.md
How to setup an Outline VPN Server on Ubuntu 16.04

How to setup an Outline VPN Server on Ubuntu 16.04 Server

This guide will show you how to install Outline Server on an Ubuntu 16.04 Server and use Outline Manager.

Install Outline Manager

Outline Manager supports Windows, macOS and Linux.

Outline Manager for Windows

@abouzarnouri
abouzarnouri / RateLimiter.cs
Last active April 30, 2018 09:45
Simple invocation rate checker
using System;
using System.Runtime.Caching;
namespace Hasin.Taaghche.Utilities
{
// Use this class to put restriction on the number of invocations of an endpoint in your system by a given input.
// E.g., when a user wants to login with "test@test.com", call CanProceed("test@test.com") to check if she can do that.
public class RateLimiter
{
private readonly MemoryCache _cache;
@bezzad
bezzad / DataTableExtensions.cs
Last active April 23, 2017 12:56
Extension methods for convert `DataTable` to any other types like: Generic Type `T` , dynamic object
public static class Extension
{
public static IList<T> ToList<T>(this DataTable dt, bool isFirstRowColumnsHeader = false) where T : new()
{
var results = new List<T>();
if (dt != null && dt.Rows.Count > 0)
{
var columns = dt.Columns.Cast<DataColumn>().ToList();
var rows = dt.Rows.Cast<DataRow>().ToList();
@bezzad
bezzad / VSSolutionInspection.tt
Created January 9, 2017 12:30 — forked from cairey/VSSolutionInspection.tt
Inspect the Visual Studio solution and project settings using T4 template code gen.
<#@ template language="C#" debug="true" hostSpecific="true" #>
<#@ output extension=".cs" #>
<#@ Assembly Name="System.Core.dll" #>
<#@ assembly name="EnvDTE" #>
<#@ Assembly Name="System.Windows.Forms.dll" #>
<#@ Assembly name="System.Configuration"#>
<#@ import namespace="System" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Diagnostics" #>
<#@ import namespace="System.Linq" #>
@bezzad
bezzad / Bundle Extension
Last active December 29, 2016 05:46 — forked from deanhume/Bundle Extension
An ASP.NET MVC bundle extension file to handle optional HTML attributes such as async, defer, and media for CSS links.
namespace Optimization.Custom
{
using System.Collections.Generic;
using System.Web;
using System.Text;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
/// <summary>
@huoxudong125
huoxudong125 / Readme.md.md
Last active January 21, 2021 04:42
WPF Get ActualWidth & ActualHeight and assign to ViewModel.

OneWayToSource Binding seems broken in .NET 4.0

@bezzad
bezzad / NumericTextBox.cs
Last active August 30, 2016 08:08
C#.Net Numeric TextBox by thousand separator like: 123,456,789
public class NumericTextBox : TextBox
{
private const char Delete = (char)8;
private const char Backspace = '\b';
public bool IsNumeric { get; set; } = false;
public new string Text
{
get { return IsNumeric ? base.Text?.Replace(",", "") : base.Text; }
@bezzad
bezzad / VersionUpdater.tt
Created July 18, 2016 13:06
Auto .net project version updater by TextTemplete (.tt)
<#@ template language="C#" hostspecific="true" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Text.RegularExpressions" #>
<#@ output extension=".txt" #>
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
@zhiguangwang
zhiguangwang / README.md
Last active June 2, 2024 07:50
Installing and running shadowsocks on Ubuntu Server

Installing and running shadowsocks on Ubuntu Server

16.10 yakkety and above

  1. Install the the shadowsocks-libev package from apt repository.

     sudo apt update
     sudo apt install shadowsocks-libev
    
  2. Save ss.json as /etc/shadowsocks-libev/config.json.

@vgerbase
vgerbase / smtp.cs
Last active August 20, 2022 09:49
C# code to switch off certificate validation
{
...
ServicePointManager.ServerCertificateValidationCallback =
delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) {
return true;
};
smtpclient.Send();
...
}