Skip to content

Instantly share code, notes, and snippets.

View hotgazpacho's full-sized avatar

Will Green hotgazpacho

View GitHub Profile
@hotgazpacho
hotgazpacho / gist:1125422
Created August 4, 2011 15:19
Is this a reasonable way to check if the user has write access to the given path?
bool CheckWriteAccessToDirectory(string directoryPath)
{
bool isWriteAccess = false;
try
{
var collection = Directory.GetAccessControl(directoryPath).GetAccessRules(true, true, typeof(NTAccount));
var fileSystemAccessRules = collection.Cast<FileSystemAccessRule>().ToList();
isWriteAccess = fileSystemAccessRules.Any(rule => rule.AccessControlType == AccessControlType.Allow)
&& fileSystemAccessRules.None(rule => rule.AccessControlType == AccessControlType.Deny);
}
@hotgazpacho
hotgazpacho / gist:1142231
Created August 12, 2011 15:03
Can I do this?
IDictionary<int, int> map = session
.GetNamedQuery("MyQuery")
.SetParameterList("ids", ids)
.SetResultTransformer(Transformers.AliasToEntityMap)
.List<Dictionary<int, int>>();
@hotgazpacho
hotgazpacho / gist:1213918
Created September 13, 2011 14:24
Looking up a Type, and converting it to a generic parameter for a method
public bool IsSurveillanceNoUnique(string surveillanceNo, SurveillanceType surveillanceType, SurveillanceContext surveillanceContext)
{
var sType = SurveillanceTypeMap[surveillanceType];
var methodInfo = _surveillances.GetType().GetMethod("IsSurveillanceNoUnique");
methodInfo = methodInfo.MakeGenericMethod(sType);
var unique = (bool) methodInfo.Invoke(_surveillances, new object[] {surveillanceNo, surveillanceContext});
return unique;
}
@hotgazpacho
hotgazpacho / gist:1246356
Created September 27, 2011 21:52
How do I write this as a QueryOver.Of<ExamResult>()
SELECT ~CAST((Count(ResultId) - SUM(CAST(SatisfiesPeriodicRequirement as INT))) as bit)
FROM ExamResults
WHERE SurveillanceId = 7927
StructureMap Exception Code: 207
Internal exception while creating Instance '10d5067c-3c42-43b4-884b-7a9307866c7a' of PluginType roundhouse.databases.Database, rh, Version=0.8.230.353, Culture=neutral, PublicKeyToken=null. Check the inner exception for more details.
@hotgazpacho
hotgazpacho / gist:1301411
Created October 20, 2011 15:20
Error when trying to restore a database from a backup using RoundhousE
Running RoundhousE v0.8.230.353 against (local) - IddealSuite.
Looking in C:\Dev\Iddeal\Database for scripts to run.
==================================================
Setup, Backup, Create/Restore/Drop
==================================================
Creating IddealSuite database on (local) server if it doesn't exist.
Restoring IddealSuite database on (local) server from path C:\Dev\Iddeal\Database\IddealSuite.bak.
RoundhousE encountered an error. You were running in a transaction though, so the database should be in the state it was in prior to this piece running. This does not include a drop/create or any creation of a database, as those items can not run in a transaction.
System.Data.SqlClient.SqlException: A transport-level error has occurred when sending the request to the server. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
@hotgazpacho
hotgazpacho / gist:1304308
Created October 21, 2011 16:55
JSON response
{"@id":"V9-6","comment":{"@id":"63-4","@author":"wgreen","@issueId":"V9-6","@deleted":"false","@text":"Acceptance Criteria presenters will be changed to batch up changes in memory rather than submit the directly. Then the Approval workflow will be intitiated. Only after this workflow is complete will the changes be sent to the domain (and thereby the database)","@shownForIssueAuthor":"false","@created":"1318432040908","replies":null},"field":[{"@name":"Priority","value":"Normal"},{"@name":"Type","value":"Feature"},{"@name":"State","value":"Fixed"},{"@name":"Assignee","value":"michael"},{"@name":"Subsystem","value":"No subsystem"},{"@name":"Fixed in build","value":"9.30.51.222"},{"@name":"links","value":{"@type":"Depend","@role":"is required for","$":"V9-3"}},{"@name":"projectShortName","value":"V9"},{"@name":"numberInProject","value":"6"},{"@name":"summary","value":"Entering a new reference value should require an approval by an IST Engineer and/or peer"},{"@name":"created","value":"1317928959793"},{"@name":"
@hotgazpacho
hotgazpacho / gist:1337022
Created November 3, 2011 16:48
.NET Duplicates Finder Fail
[12:40:04]: Step 7/8: Duplicates finder (.NET)
[12:40:04]: Starting: "C:\Program Files\Jet Brains\TeamCity\buildAgent\plugins\dotnet-dupfinder\bin\dupfinder.exe" --show-stats --show-text --discard-cost=70 --debug --normalize-types "--exclude-code-regions="Windows Form Designer generated code"" -e **/*.Designer.cs -e **/*.generated.cs -e **/*Tests/**/*.cs -e Misc/IddealTemplate/**/*.cs -e Tools/FileTruncationTask/**/*.cs -e Tools/SyncRepo/**/*.cs -e Tools/SchemaScan/**/*.cs -i **/*.cs -o 05A1B22A-DE6E-49ae-AA30-DC52A074EF22\result.xml
[12:40:04]: in directory: C:\ProgramData\JetBrains\TeamCity\buildAgent\work\8ef7d41dee6698f1
[12:40:05]: JetBrains Duplicates Finder for .NET
[12:40:05]: Running in 32-bit mode, .NET runtime 2.0.50727.4216 under Microsoft Windows NT 6.0.6002 Service Pack 2
[12:40:05]: dupFinder: Invalid option 'output'. Error: Output file is not specified
[12:40:05]: Try `dupFinder /help' for more information.
[12:40:05]: Process exited with code 1
[12:40:05]: Step Duplicates finder (.NET) failed
@hotgazpacho
hotgazpacho / WCFServiceTest.cs
Created November 16, 2011 02:52
WCF Service Test
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using ElmSelect.DomainModel;
using DataAccessLayer;
@hotgazpacho
hotgazpacho / Refactored.cs
Created November 16, 2011 03:41
WCF Service Test - Refactored
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using ElmSelect.DomainModel;
namespace WCFService