Skip to content

Instantly share code, notes, and snippets.

Some stuff
git checkout my-branch
git rebase master
git checkout master
git merge my-branch
public static class TimeExt
{
private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public static long ToUnixTimeStamp(this DateTime dateTime)
{
DateTime ut = dateTime.ToUniversalTime();
var unixTimeStamp = (long)(ut - Epoch).TotalMilliseconds;
return unixTimeStamp;
}
public class ChildPropertyChangedEventArgs : PropertyChangedEventArgs
{
public ChildPropertyChangedEventArgs(object child, string propertyName)
: base(propertyName)
{
Child = child;
}
public ChildPropertyChangedEventArgs(object sender, PropertyChangedEventArgs e)
: base(e.PropertyName)
public static class FileUtility
{
private const char PrefixChar = '%';
private static readonly int MaxLength;
private static readonly Dictionary<char,char[]> Illegals;
static FileUtility()
{
List<char> illegal = new List<char> { PrefixChar };
illegal.AddRange(Path.GetInvalidFileNameChars());
MaxLength = illegal.Select(x => ((int)x).ToString().Length).Max();
<Window x:Class="ListViewBox.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<DataTemplate x:Key="Boxes" DataType="{x:Type system:DateTime}">
<Border Background="Beige" Height="200" Width="299">
<TextBlock Text="{Binding DayOfWeek}"></TextBlock>
</Border>
public static class Gac
{
/// <summary>
///
/// </summary>
/// <param name="pattern">Default search pattern "*interop*.dll"</param>
/// <returns></returns>
public static IEnumerable<FileInfo> InteropDlls(string pattern = "*interop*.dll")
{
var gac = AllFiles(new DirectoryInfo(@"C:\Windows\Assembly"), pattern)
public struct Code : IEquatable<Code>
{
public Code(ushort major, ushort minor)
: this()
{
Major = major;
Minor = minor;
}
public static Code ErrorCode { get { return new Code(ushort.MaxValue, ushort.MaxValue); } }
public ushort Major { get; private set; }
public static class IconsRepository
{
private static readonly Dictionary<string, Icon> CachedIcons = new Dictionary<string, Icon>();
private static readonly Dictionary<string, BitmapImage> CachedBitmapImages = new Dictionary<string, BitmapImage>();
[DllImport("shell32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, out SHFILEINFO psfi, uint cbFileInfo, uint uFlags);
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static class OcExt
{
public static void InvokeAdd<T>(this ObservableCollection<T> collection, T newItem)
{
collection.Invoke(()=>collection.Add(newItem));
}
public static void InvokeAddRange<T>(this ObservableCollection<T> collection, IEnumerable<T> newItems)
{
collection.Invoke(() =>
{
public class GridViewColumn : DependencyObject
{
public static readonly DependencyProperty ColumnWidthProperty =
DependencyProperty.RegisterAttached("ColumnWidth", typeof(GridLength), typeof(GridViewColumn), new PropertyMetadata(new GridLength(1, GridUnitType.Star),OnWidthChanged));
private static readonly Dictionary<GridView, Dictionary<System.Windows.Controls.GridViewColumn, GridLength>> GridViews = new Dictionary<GridView, Dictionary<System.Windows.Controls.GridViewColumn, GridLength>>();
/// <summary>
/// Sets the value of the attached property ScrollGroup.