Skip to content

Instantly share code, notes, and snippets.

/// <summary>
/// Utilties for reflection
/// </summary>
public static class ReflectionExtensions
{
/// <summary>
/// Get all the fields of a class
/// </summary>
/// <param name="type">Type object of that class</param>
/// <returns></returns>
using System.Collections.Generic;
using System.Linq;
 
namespace NumberToWordsLib
{
 /// <summary>
 /// Number to word languages
 /// </summary>
 public enum Language
 {
@Jalalx
Jalalx / LevenshteinDistance.cs
Created February 4, 2015 19:07
The Levenshtein distance between two strings is defined as the minimum number of edits needed to transform one string into the other, with the allowable edit operations being insertion, deletion, or substitution of a single character.
using System;
/// <summary>
/// Contains approximate string matching
/// </summary>
static class LevenshteinDistance
{
/// <summary>
/// Compute the distance between two strings.
/// </summary>
/*
How to capture the whole screen:
var image = ScreenCapture.CaptureDesktop();
image.Save(@"C:\temp\snippetsource.jpg", ImageFormat.Jpeg);
How to capture the active window:
var image = ScreenCapture.CaptureActiveWindow();
image.Save(@"C:\temp\snippetsource.jpg", ImageFormat.Jpeg);
*/
public class ScreenCapture
{
@Jalalx
Jalalx / IranianSystemEncoding.cs
Created January 14, 2015 13:51
Iranian system encoding standard
class IranianSystemEncoding
{
static char[] ByteToChar;
static Byte[][] CharToByte;
static IranianSystemEncoding()
{
InitializeData();
}
@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
@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" #>
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
<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"
@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" />