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
@bezzad
bezzad / outline-server-setup.md
Created November 7, 2022 16:17 — forked from hadisfr/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

@bezzad
bezzad / BinarySearch
Last active October 22, 2019 07:07
Binary search implementation to search a value of type T1 within a list of T2 type which comparable by value argument.
using System;
using System.Collections.Generic;
public static class Helper
{
/// <summary>
/// Searches a section of the list for a given element using a binary search
/// algorithm.
/// </summary>
/// <param name="items">list of <see cref="TItems"/>, which must be searched within</param>
@bezzad
bezzad / AspMvcCamelCaseJson
Created October 22, 2019 06:32
Return JSON data in a camelCase format from an ASP.NET WebAPI controller.
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
@bezzad
bezzad / animation-using-angularjs-ui-router-and-nganimate.markdown
Last active November 10, 2018 08:16
Animation using AngularJS ui-router and ngAnimate

Animation using AngularJS ui-router and ngAnimate

Feel free to use this code if you are using AngularJS Framework in your application. This will help you easily create beautiful animated wizards or cover other UI scenarios that require a step-by-step interactions. Better used for single-page apps.

A Pen by Behzad Khosravifar on CodePen.

License.

@bezzad
bezzad / StartIIS.cs
Created July 22, 2018 10:32
Programmatically start IIS Express from code.
public static class IISExpress
{
private static readonly List<string> sites = new List<string>();
private static readonly List<string> paths = new List<string>();
public static void StartIISExpress(string site, int port = 7329)
{
if(!sites.Contains(site.ToLower()))
sites.Add(site.ToLower());
else return;
@bezzad
bezzad / ObservableConcurrentDictionary.cs
Last active July 22, 2018 10:30
Provides a thread-safe dictionary for use with data binding.
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Threading;
namespace System.Collections.Generic
{
/// <summary>
@bezzad
bezzad / AsyncHelper.cs
Last active May 30, 2018 10:03
Run an async Task<T> method synchronously
public static class AsyncHelper
{
/// <summary>
/// Execute's an async Task method which has a void return value synchronously
/// </summary>
/// <param name="task">Task method to execute</param>
public static void RunSync(this Func<Task> task)
{
var oldContext = SynchronizationContext.Current;
var synch = new ExclusiveSynchronizationContext();
@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>