Skip to content

Instantly share code, notes, and snippets.

View vcsjones's full-sized avatar

Kevin Jones vcsjones

View GitHub Profile
SELECT
up.UserId
,XOR(up.Flags)
FROM
UserPermissions up
GROUP BY
up.UserId
@vcsjones
vcsjones / sample.cs
Last active December 17, 2015 07:59
public class ClientGroup
{
private List<Client> _clients = new List<Client>();
private void Add(Client oClient) {
_clients.Add(oClient);
}
public void Add(string sMessyString){
this.Add(Client.ReturnClientObjectFromStringAfterConvert(sMessyString));
}
@vcsjones
vcsjones / git.ps1
Created May 8, 2013 18:33
Determine if there are any uncommitted revisions.
$svnUncommited = (git svn find-rev HEAD) -eq $null
@vcsjones
vcsjones / ismethodempty.cs
Last active December 15, 2015 19:19
Determines with a rather naive way of determining at run time if a method is empty.
Action<int> gfa = k => { };
var il = gfa.Method.GetMethodBody().GetILAsByteArray().Where(b => b != OpCodes.Nop.Value).ToArray();
if (il.Length == 0 || (il.Length == 1 && il[0] == OpCodes.Ret.Value))
{
Debug.WriteLine("Empty!");
}
else
{
Debug.WriteLine("Not empty!");
}
NSNumber* __strong* numbers[] = {
&major, &minor, &revision, &build
};
@vcsjones
vcsjones / gist:4457406
Created January 4, 2013 21:57
CTE to query the business days of the current week.
SET DATEFIRST 1;
WITH [week]([date]) AS
(
SELECT
DATEADD(week, DATEDIFF(week, 0, GETDATE()), 0)
UNION ALL
SELECT
[date]+1 FROM [week]
WHERE
DATEPART(dw, [date]+1) <= 5
//Don't Want
Func<bool, bool> someFunc = null;
someFunc = b => someFunc(b);
//Want (Mono C# compiler can do this)
Func<bool, bool> someFunc = b => someFunc(b);
@vcsjones
vcsjones / gist:3426684
Created August 22, 2012 15:18
HandleAsp4Rendering
[Test]
public void ShouldHandleAspNet4Rendering()
{
var text = string.Format("Hello World");
multiline.Text = text;
doPostBack.Click();
Assert.AreEqual(text, multiline.Text);
}
@vcsjones
vcsjones / gist:2711667
Created May 16, 2012 16:05
Capture All Monitors
[STAThread]
static void Main()
{
var size = Screen.AllScreens.Aggregate(Size.Empty, (sz, screen) =>
{
var boundHeight = screen.Bounds.Y + screen.Bounds.Height;
var boundWidth = screen.Bounds.X + screen.Bounds.Width;
return new Size(boundWidth > sz.Width? boundWidth : sz.Width, boundHeight > sz.Height? boundHeight : sz.Height);
});
using (var bitmap = new Bitmap(size.Width, size.Height))
@vcsjones
vcsjones / gist:2659633
Created May 11, 2012 13:34
LDP GUID Fixer
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics
Imports System.Text
Public Module EditorMacro