Skip to content

Instantly share code, notes, and snippets.

View chaliy's full-sized avatar

Mykhailo Chalyi (Mike Chaliy) chaliy

  • Ukraine
  • 11:18 (UTC +03:00)
  • X @chaliy
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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; } }
type Order = {
Number : string
Date : DateTime
Items : {
ProductSKU : string
Quantity : int
} list
}
// Code
exception MyError of string
// and generate stuff
[Serializable, CompilationMapping(SourceConstructFlags.Exception)]
public class MyError : Exception, IStructuralEquatable
{
internal string Data0@;
let versions = new Table(db, "__MoveVersions")
(** first version **)
versions.Columns.Add(new Column(versions, "Sequence", DataType.NVarChar(450)))
versions.Columns.Add(new Column(versions, "Version", DataType.NVarChar(450)))
versions.Columns.Add(new Column(versions, "PreviousVersion", DataType.NVarChar(450)))
versions.Columns.Add(new Column(versions, "LastUpdated", DataType.DateTime))
(** or second version **)