Skip to content

Instantly share code, notes, and snippets.

View rasoulian's full-sized avatar
😎
Focusing

Ali Rasoulian rasoulian

😎
Focusing
View GitHub Profile
@hayashih
hayashih / RedirectNoTrailingSlashUrl.cs
Created November 29, 2010 11:29
ASP.NET MVC Grobal.asax.cs sample for redirect no trailing slash url.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.Security;
namespace MyMvcWebSite
{
@mgroves
mgroves / CustomerController.cs
Created February 15, 2012 03:38
Audit ActionFilter in ASP.NET MVC
public class CustomerController : Controller
{
public ViewResult Index()
{
return View();
}
public ViewResult Edit()
{
var existingCustomer = new Customer();
@maartenba
maartenba / DomainTemplateRoute - GetVirtualPath
Last active May 15, 2023 07:30
ASP.NET MVC 6 / ASP.NET 5 Domain Routing + Tenant Middleware
public string GetVirtualPath(VirtualPathContext context)
{
foreach (var matcherParameter in _matcher.Template.Parameters)
{
context.Values.Remove(matcherParameter.Name); // make sure none of the domain-placeholders are appended as query string parameters
}
return _innerRoute.GetVirtualPath(context);
}
@kiichi
kiichi / ImageResizeTest.cs
Last active July 1, 2023 07:56
Image Resize Example in C#
// Add System.Drawing as a reference.
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
namespace ImageResizeTest {
class Program {
static void Main(string[] args) {
string path = @"C:\\Users\kiichi\work\ImageResizeTest\geo-elevation.png";
Resize(path, 600, 600);
Tmux is a "terminal multiplexer", it enables a number of terminals to be accessed and controlled from a single terminal.
If you use Debian/Ubuntu, you can just run apt-get install tmux, and voila.
Since the title was about centos 7, then do the following step to install tmux.
(1). tmux has a library dependency on libevent which, of course, isn’t installed by default.
$ wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
$ tar xzvf libevent-2.0.21-stable.tar.gz
$ cd libevent-2.0.21-stable
$ ./configure && make
@karbyninc
karbyninc / ExceptionHandlers.cs
Last active July 4, 2018 10:38
Handling Errors in Web API Using Exception Filters and Exception Handlers
public override void OnException(HttpActionExecutedContext actionExecutedContext)
@karbyninc
karbyninc / StrategyPattern.cs
Last active July 4, 2018 10:34
The Strategy Pattern
namespace StrategyPattern.Contracts
{
public interface IDiscountStrategy
{
decimal ApplyDiscount(decimal price);
}
}
@marisks
marisks / CreatedAndModifiedDateInterceptor.cs
Created February 27, 2016 06:46
Entity Framework soft delete, modiefied and created date interceptors
using System;
using System.Data.Entity.Core.Common.CommandTrees;
using System.Data.Entity.Core.Metadata.Edm;
using System.Data.Entity.Infrastructure.Interception;
using System.Linq;
public class CreatedAndModifiedDateInterceptor : IDbCommandTreeInterceptor
{
public const string CreatedColumnName = "Created";
public const string ModifiedColumnName = "Modified";
@btroncone
btroncone / ngrxintro.md
Last active June 26, 2024 08:27
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series

Comprehensive Introduction to @ngrx/store

By: @BTroncone

Also check out my lesson @ngrx/store in 10 minutes on egghead.io!

Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!

Table of Contents

@ayende
ayende / LetsEncryptClient.cs
Created January 11, 2018 22:26
ACME v2 client for Let's Encrypt
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading;
using System.Threading.Tasks;