Skip to content

Instantly share code, notes, and snippets.

View zihotki's full-sized avatar

Vasili Puchko zihotki

  • Infront ASA
  • Amsterdam, Netherlands
View GitHub Profile
@zihotki
zihotki / EnumDropdownExtenstions.cs
Created September 5, 2012 09:27 — forked from danielrbradley/EnumDropdownExtenstions.cs
ASP.NET MVC Enumeration Dropdown Extensions
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text.RegularExpressions;
using System.Web.Mvc;
using System.Web.Mvc.Html;
namespace System.Web.Mvc.Html
{
@zihotki
zihotki / MenuLinkExtension.cs
Created September 14, 2012 22:21
asp.net mvc MenuLink extension
public static MvcHtmlString MenuLink(
this HtmlHelper helper,
string text, string action, string controller)
{
var routeData = helper.ViewContext.RouteData.Values;
var currentController = routeData["controller"];
var currentAction = routeData["action"];
if(String.Equals(action, currentAction as string,
StringComparison.OrdinalIgnoreCase)
/*
* Original Sample: http://craftycodeblog.com/2010/05/15/asp-net-mvc-render-partial-view-to-string/
*/
public class HomeController : Controller
{
public ActionResult Index()
{
string MyModelData = "";
@zihotki
zihotki / Export Table to Excel
Created October 10, 2013 19:42
Exporting html table to excel file
<script type="text/javascript">
function generate_excel(tableid) {
var table= document.getElementById(tableid);
var html = table.outerHTML;
window.open('data:application/vnd.ms-excel;base64,' + base64_encode(html));
}
function base64_encode (data) {
// http://kevin.vanzonneveld.net
// + original by: Tyler Akins (http://rumkin.com)
@zihotki
zihotki / LogRequestModule.cs
Created April 6, 2016 12:40
Autofac module to write to debug output component resolve and activation messages
public class LogRequestModule : Module
{
public int depth = 0;
protected override void AttachToComponentRegistration(IComponentRegistry componentRegistry,
IComponentRegistration registration)
{
registration.Preparing += RegistrationOnPreparing;
registration.Activating += RegistrationOnActivating;
//registration.Activated += RegistrationOnActivated;
@zihotki
zihotki / RecursiveStack.cs
Created May 31, 2016 21:03
Stack implementation using recursive links
using System;
public class Program
{
public static void Main()
{
var stack = new Stack();
stack.Push(5);
stack.Push(4);
stack.Push(3);
@zihotki
zihotki / .bash_profile
Created June 4, 2016 16:41
My personal settings for git
alias g=git
alias ls='/bin/ls -F --color=tty --show-control-chars'
alias ga='gitk --all&'
alias gs='git st'
@zihotki
zihotki / ngrxintro.md
Created March 15, 2017 21:31 — forked from btroncone/ngrxintro.md
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

@zihotki
zihotki / Lighter or Darker a Color.cs
Created December 17, 2017 00:17
.net C# make a color lighter or darker
/// <summary>
/// Creates color with corrected brightness.
/// </summary>
/// <param name="color">Color to correct.</param>
/// <param name="correctionFactor">The brightness correction factor. Must be between -1 and 1.
/// Negative values produce darker colors.</param>
/// <returns>
/// Corrected <see cref="Color"/> structure.
/// </returns>
public static Color ChangeColorBrightness(Color color, float correctionFactor)