Skip to content

Instantly share code, notes, and snippets.

@sinairv
sinairv / ThreadStaticDemo.cs
Created June 27, 2017 23:55
ThreadStatic demo
using System;
using System.Threading;
using System.Threading.Tasks;
namespace ThreadStaticDemo
{
public class Program
{
public static void Main(string[] args)
{
@sinairv
sinairv / DevEnvSetup.ps1
Last active June 6, 2017 06:12
Dev Environment Setup with Chocolatey
choco install -y conemu
choco install -y googlechrome
choco install -y --allowemptychecksum paint.net
choco install -y vlc
choco install -y 7zip.install
choco install -y notepadplusplus.install
choco install -y git.install
choco install -y visualstudiocode
choco install -y tortoisegit
choco install -y notepad2
@sinairv
sinairv / Input-Output-Go-WPF-GUI-Template.linq
Last active September 6, 2019 18:15
LinqPad Input-Output-Go WPF GUI Template
enum TextBoxMode
{
SingleLine,
MultiLine
}
TextBox CreateTextBox(string label, TextBoxMode textBoxMode)
{
var lbl = new Label();
lbl.Content = $"{label}:";
@sinairv
sinairv / CardView.cs
Created August 8, 2016 05:59
CardView Windows Forms Control
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace WinFormsImage
{
public class CardView : PictureBox
{
public CardView()
@sinairv
sinairv / LabeledPictureBox.cs
Created August 8, 2016 01:48
LabeledPictureBox control for Windows Forms
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
// Winfows Forms picture box that shows a hovering label in the centre
namespace WinFormsImage
{
public class LabeledPictureBox : PictureBox
@sinairv
sinairv / UnityInterceptorsDemo.cs
Created August 13, 2015 05:13
A demo of unity interceptors
using Microsoft.Practices.Unity.InterceptionExtension;
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace UnityInterceptionTest01
{
// You can create your own custom behaviors by implementing the IInterceptionBehavior
// interface. The interception behaviors are added to a pipeline and are called for
// each invocation of that pipeline.
@sinairv
sinairv / PerformanceMeasurement.cs
Created August 4, 2015 02:15
Performance Measurement
const int WarmUpCount = 3;
const int TestCount = 100;
var stopWatch = new Stopwatch();
stopWatch.Reset();
for (int i = 0; i < WarmUpCount + TestCount; i++)
{
if(i >= WarmUpCount)
stopWatch.Start();
@sinairv
sinairv / CsvWriter.cs
Last active August 29, 2015 14:16
A simple implementation of a CSV Writer in C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
namespace Utilities
{
public class CsvWriter
@sinairv
sinairv / MousewheelControl.md
Last active December 28, 2015 02:09
Windows Forms: How to make mouse wheel event on the child controls scroll the parent panel

Make the form implement IMessageFilter and implement it as follows:

public bool PreFilterMessage(ref Message m)
{
    if (m.Msg == 0x20a)
    {
        // WM_MOUSEWHEEL, find the control at screen position m.LParam
        Point pos = new Point(m.LParam.ToInt32() & 0xffff, m.LParam.ToInt32() >> 16);
 IntPtr hWnd = WindowFromPoint(pos);
@sinairv
sinairv / GetFormattedDate.sql
Created January 21, 2013 02:28
Get Formatted Date SQL Helper Function
IF EXISTS
(SELECT * FROM sys.objects
WHERE object_id = OBJECT_ID(N'GetFormattedDate')
AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[GetFormattedDate]
GO
CREATE FUNCTION [dbo].[GetFormattedDate]
(
@TheDate DATETIME, @Format VARCHAR(MAX)