Skip to content

Instantly share code, notes, and snippets.

View Jalalx's full-sized avatar

Jalal Amini Robati Jalalx

View GitHub Profile
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Web.Http.Dependencies;
using Ninject;
using Ninject.Syntax;
public class NinjectDependencyScope : IDependencyScope
{
private IResolutionRoot resolver;
@Jalalx
Jalalx / PersianDateExtensionMethods.cs
Last active October 11, 2016 13:02
Some persian extension methods
// source code orginaly from http://www.dotnettips.info/post/1244/
/*
Use as extension method:
var date1 = DateTime.Now.ToPesianDateString("yyyy/MM/dd");
var date2 = DateTime.Now.ToPeianDateString("dddd, dd MMMM,yyyy");
//Output:
//1391/12/13
//یکشنبه, 13 اسفند,1391
@Jalalx
Jalalx / MessageBoxManager.cs
Last active December 25, 2015 10:49
Localize System MessageBox in C#
#pragma warning disable 0618
using System;
using System.Text;
using System.Runtime.InteropServices;
using System.Security.Permissions;
[assembly: SecurityPermission(SecurityAction.RequestMinimum, UnmanagedCode = true)]
namespace System.Windows.Forms
{
public class MessageBoxManager
class AStar
{
private static bool InBounds(int x, int y, bool[,] map)
{
if (x >= 0 && y >= 0 && y < map.GetLength(0) && x < map.GetLength(1))
return true;
return false;
}
class Node : IComparable<Node>
{
public int H
{
get
{
return Math.Abs(X - TargetNode.Position.X) +
Math.Abs(Y - TargetNode.Position.Y);
}
}
@Jalalx
Jalalx / ninja.vstheme
Created September 12, 2014 16:25
A very dark theme for Microsoft Visual Studio 2012
<Themes>
<Theme Name="Ninja" GUID="{18d95dec-1d05-4e75-b38a-b107a53d5fc4}">
<Category Name="Autos" GUID="{a7ee6bee-d0aa-4b2f-ad9d-748276a725f6}">
<Color Name="ChangedText">
<Foreground Type="CT_RAW" Source="FFF7A1A1" />
</Color>
</Category>
<Category Name="Cider" GUID="{92d153ee-57d7-431f-a739-0931ca3f7f70}">
<Color Name="ToolWindow">
<Background Type="CT_RAW" Source="FF252526" />
<Button Width="15" Height="15" Panel.ZIndex="999" VerticalAlignment="Top" HorizontalAlignment="Right" Padding="5">
<Button.Template>
<ControlTemplate TargetType="Button">
<Grid Background="Transparent">
<!-- The background of the button, as an ellipse. -->
<Ellipse x:Name="backgroundEllipse" />
<!-- A path that renders a cross. -->
<Path x:Name="ButtonPath"
Margin="3"
Create Function dbo.[UDF_Gregorian_To_Persian] (@date datetime)
Returns nvarchar(50)
as
Begin
Declare @depoch as bigint
Declare @cycle as bigint
Declare @cyear as bigint
Declare @ycycle as bigint
Declare @aux1 as bigint
Declare @aux2 as bigint
@Jalalx
Jalalx / ViewGenerator.tt
Created December 22, 2014 17:41
Install t4toolbox before using this code
<#@ template language="C#" debug="false" hostspecific="false" #>
<#@ output extension=".txt" #>
<#@ assembly name="System" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="System.Data.Entity" #>
<#@ assembly name="EnvDTE" #>
<#@ include file="t4toolbox.tt" #>
<#@ import namespace="EnvDTE" #>
<#@ import namespace="System" #>
<#@ import namespace="System.Collections" #>
@Jalalx
Jalalx / Ribbon.xaml
Last active August 29, 2015 14:12
MetroStyle ribbon for Microsoft WPF Ribbon Controls
ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="Ribbon">
<Setter Property="Background" Value="White"/>
<Setter Property="Foreground" Value="Black"/>
<Setter Property="BorderBrush" Value="{x:Null}"/>
<!-- TODO Template