Skip to content

Instantly share code, notes, and snippets.

public static TItem MaxBy<TItem, TValue>(this IEnumerable<TItem> items, Func<TItem, TValue> selector)
where TValue : IComparable
{
if (items == null)
throw new ArgumentNullException("items");
if (selector == null)
throw new ArgumentNullException("selector");
TItem maxItem = items.FirstOrDefault();
@derjabkin
derjabkin / gist:11145781
Created April 21, 2014 15:22
Build eXpand with Self-Compiled DX-Assemblies
msbuild xpand.build /t:Copy;NuGetPackage /p:Version=13.2.9.100;SkipFixReferences=true;SkipDashboard=true
@derjabkin
derjabkin / Proc_BackupDatabaseDailyWithLog.sql
Created November 11, 2013 07:16
Daily backup of full logged databases with log backup.
if not OBJECT_ID('dbo.Proc_BackupDatabaseDailyWithLog') is null
Drop Proc dbo.Proc_BackupDatabaseDailyWithLog
go
Create Proc dbo.Proc_BackupDatabaseDailyWithLog(
@DbName sysname,
@TargetPath nvarchar(1000)) as
@derjabkin
derjabkin / Proc_BackupDatabaseDailyWithLog.sql
Created November 9, 2013 19:01
Daily database and hourly log backup on Microsoft SQL Sever
if not OBJECT_ID('dbo.Proc_BackupDatabaseDailyWithLog') is null
Drop Proc dbo.Proc_BackupDatabaseDailyWithLog
go
Create Proc dbo.Proc_BackupDatabaseDailyWithLog(
@DbName sysname,
@TargetPath nvarchar(1000)) as
@derjabkin
derjabkin / gist:6549465
Created September 13, 2013 11:24
XAF ASP.NET Shortcut for an action
public class ActionContainerHolderEx : ActionContainerHolder
{
protected override DevExpress.ExpressApp.Web.Templates.ActionContainers.Menu.MenuActionItemBase CreateSimpleActionItem(DevExpress.ExpressApp.Actions.SimpleAction simpleAction)
{
SimpleActionMenuActionItem item = base.CreateSimpleActionItem(simpleAction) as SimpleActionMenuActionItem;
if (item != null)
{
ModificationsController controller = item.Action.Controller as ModificationsController;
@derjabkin
derjabkin / gist:6422015
Created September 3, 2013 10:08
XAF: Enabling Mask on DateEdits in ASP.NET
public class DateTimeMaskController : ViewController<DetailView>
{
protected override void OnViewControlsCreated()
{
base.OnViewControlsCreated();
foreach (var viewItem in View.Items)
{
ASPxDateTimePropertyEditor editor = viewItem as ASPxDateTimePropertyEditor;
if (editor != null)
editor.ControlCreated += (s, e) =>
@derjabkin
derjabkin / gist:5966330
Created July 10, 2013 13:36
AddHashCodes (untested)
private static int AddHashCodes(params object[] fields)
{
return BitConverter.ToInt32(BitConverter.GetBytes(fields.Select(f => f == null ? 0L : f.GetHashCode()).Sum()),0);
}
@derjabkin
derjabkin / gist:5966269
Created July 10, 2013 13:26
IList<T> covariance wrapper
public class ListWrapper<TSource, TDest> : IList<TDest>
where TDest : class
where TSource : TDest
{
private readonly IList<TSource> list;
public ListWrapper(IList<TSource> list)
{
this.list = list;
}
@derjabkin
derjabkin / gist:5517390
Created May 4, 2013 12:43
Virtual Box add custom screen resolution
VBoxManage setextradata "<VMName>" "CustomVideoMode1" "1600x900x32"
@derjabkin
derjabkin / gist:5487903
Created April 30, 2013 10:34
SQL Server: Delete all Constraints for a column
Create Proc [dbo].[Proc_DropConstraints]
@TableName sysname,
@ColumnName sysname
as
Declare @SQL nvarchar(1000)
Declare RS Cursor local read_only for
Select 'Alter Table ' + @TableName+