Skip to content

Instantly share code, notes, and snippets.

View chaliy's full-sized avatar

Mykhailo Chalyi (Mike Chaliy) chaliy

  • Ukraine, Lviv
  • 07:27 (UTC +03:00)
  • X @chaliy
View GitHub Profile
@chaliy
chaliy / readonly_collection_nhib.cs
Created May 21, 2010 14:46
Readonly collection property for NHibernate
private readonly IList<ProductImageAssignee> _images = new List<ProductImageAssignee>();
public virtual IEnumerable<ProductImageAssignee> Images { get { return _images; } }
@chaliy
chaliy / remove_duples.sql
Created June 8, 2010 09:31
Solution to remove duples from SQL table
-- Stupid solution to remove duples from sql table...
DECLARE @temp TABLE
(
[Col1] [uniqueidentifier] NOT NULL,
[Col2] [uniqueidentifier] NOT NULL
)
INSERT INTO @temp
SELECT DISTINCT [Col1] ,[Col2]
@chaliy
chaliy / catalogue_photos.fsx
Created July 25, 2010 10:45
Copy photo files by EXIF infromation.
#r "WindowsBase.dll"
#r "PresentationCore.dll"
#r "System.Xaml.dll"
(*
Script to copy all photos from flash card to
some folder in form of /Year/Month/Day of the DateTaken
DateTaken is retrieved from EXIF infroamtion.
To make this script work, you have ensure that all
applicable WIC codecs are installed. For example
@chaliy
chaliy / non_blocking_api_dot_net.cs
Created July 27, 2010 14:55
Node.NET: Non blocking API .NET
using System;
using System.IO;
using System.Net;
using System.Security.AccessControl;
using System.Text;
namespace SimpleExample
{
class Program
{
@chaliy
chaliy / non_blocking_api_dot_net.fs
Created July 27, 2010 15:16
F# async worflow example
open System.IO
open System.Net
open System.Text
async {
let file = File.OpenRead("Program.fs")
let! stuff = file.AsyncRead(250)
printfn "%A" (Encoding.Default.GetString(stuff))
@chaliy
chaliy / ArrayValue.cs
Created August 6, 2010 15:29
ArrayValue<T>
[Serializable]
public struct ArrayValue<T> : IEnumerable<T>
{
private List<T> _under;
public ArrayValue(IEnumerable<T> under)
{
_under = new List<T>(under);
}
@chaliy
chaliy / CreateObjWithInvoike.cs
Created August 8, 2010 13:30
reateObjWithInvoike
class Program
{
public static void Main()
{
var ctor = typeof (R).GetConstructor(new Type[] {typeof (string)});
var result = (R)ctor.Invoke(new object[]{"a"});
result.Test();
}
@chaliy
chaliy / DateTime2UserType.cs
Created August 26, 2010 18:26
IUserType for SQL datetime2
using System;
using System.Data;
using NHibernate;
using NHibernate.SqlTypes;
using NHibernate.UserTypes;
namespace Infrastructure.Data.NHibernate.UserTypes
{
public class DateTime2UserType : IUserType
{
@chaliy
chaliy / BaseRepositoryStub.cs
Created August 29, 2010 18:04
BaseRepositoryStub.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Castle.MicroKernel;
using Castle.MicroKernel.Registration;
using Commons.DomainDesign.Model;
namespace Inventory.Tests.Stubs
{
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
ToolsVersion="4.0" >
<ItemGroup>
<DeployFiles Include="..\Output\**\*.*" />
</ItemGroup>
<Target Name="Deploy" DependsOnTargets="_Clean">
<!-- For now Output folder does not even existis -->
<!-- MSBuild will build all stuff an put to Output folder -->