Skip to content

Instantly share code, notes, and snippets.

View chilversc's full-sized avatar

Chris Chilvers chilversc

View GitHub Profile
@chilversc
chilversc / gist:5100296
Created March 6, 2013 15:52
NHibernate Contains query bug - mutating a collection after a query has executed breaks queries in subsequent sessions
[Test]
public void UsersWithListContains_MutatingListDoesNotBreakOtherSessions()
{
using (var firstSession = OpenSession ()) {
var names = new List<string> { "ayende", "rahien" };
var query = (from user in firstSession.Query<User> ()
where names.Contains(user.Name)
select user).ToList();
@chilversc
chilversc / gist:5082299
Created March 4, 2013 13:41
Use jquery mobile with requirejs, delay pageinit function until scripts are loaded
<script src="/scripts/require.js" type="text/javascript"></script>
<script type="text/javascript">
requirejs.config({
paths: {
'jquery': 'jquery-1.9.1.min',
'jquery.mobile': 'jquery.mobile-1.3.0.min'
},
shim: {
'jquery.mobile': ['jquery', 'jquery.mobile-config']
}
@chilversc
chilversc / gist:5047785
Created February 27, 2013 13:08
Couple of VS macros, change insert tabs/spaces, removing trailing spaces and attach debugger to IIS Express
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics
Public Module Module1
Sub UseTabs()
@chilversc
chilversc / gist:4236568
Created December 7, 2012 21:11
MSSQL MERGE runs update triggers
-- This behavior is correct, just surprising if you havn't designed your trigger correctly.
-- Standard cause is designing a trigger that expects exactly 1 row and only 1 row to be changed
-- and doesn't account for if no rows are updated, or more than 1 row is updated.
create table foo (id int primary key, value nvarchar(255));
go
create trigger t_foo_update on foo for update as
set nocount on
@chilversc
chilversc / gist:4224461
Created December 6, 2012 13:32
reading xml fragments from a stream
void Main()
{
var stream = new StringReader("<begin><test>1</test> <test>2</test> <test>");
var reader = XmlReader.Create(stream);
// find the root element
MoveToNextElement(reader);
// find the first content element
MoveToNextElement(reader);
@chilversc
chilversc / gist:2253032
Created March 30, 2012 17:12
IE 8 JSON madness
<html>
<head>
<title></title>
<meta http-equiv="X-UA-Compatible" content="IE=8">
</head>
<body>
<h1>Test</h1>
<pre id="testout"></pre>
@chilversc
chilversc / gist:2050794
Created March 16, 2012 16:15
Powershell, copy multiple registry values
(gi SOURCE).Property | ?{$_ -like "Colour*"} | %{cpp SOURCE TARGET -Name $_}
D:.
\---Pyrus-2.0.0a4
+---.xmlregistry
| \---packages
| \---pyrus.net
| \---Pyrus
+---data
| +---pear2.php.net
| | \---PEAR2_Console_CommandLine
| \---pyrus.net
@chilversc
chilversc / sql query
Created December 14, 2011 23:33 — forked from anonymous/sql query
SELECT
os.orders_status_id,
os.date_added,
os.customer_notified,
os.comments,
o.customers_id,
o.customers_email_address,
o.orders_status,
o.date_purchased,
c.customers_id,
@chilversc
chilversc / fullcalendar.css
Created December 12, 2011 15:04
qtip positioning error
/*
* FullCalendar v1.5.1 Stylesheet
*
* Copyright (c) 2011 Adam Shaw
* Dual licensed under the MIT and GPL licenses, located in
* MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
*
* Date: Sat Apr 9 14:09:51 2011 -0700
*
*/