Skip to content

Instantly share code, notes, and snippets.

View vcsjones's full-sized avatar

Kevin Jones vcsjones

View GitHub Profile
@vcsjones
vcsjones / gist:2631595
Created May 8, 2012 00:13
A Terrible Idea
public async Task<string> Foo
{
set
{
}
get
{
}
}
public class IFoo
{
public object Current { get; set; }
public bool MoveNext()
{
return whatever;
}
}
public class Bar
@vcsjones
vcsjones / gist:1989421
Created March 6, 2012 22:24
Parsing different DateTime formats
'Make sure this import is at the top of the file:
Imports System.Globalization
'And the actual code:
Public Function ParseDateTime(ByVal dateTimeString As String) As DateTime?
Dim dt As DateTime
'Try to parse the date time...
If DateTime.TryParseExact(dateTimeString, New String() {"yyyyMMdd", "yyyy-MM-dd"}, CultureInfo.CurrentCulture, DateTimeStyles.None, dt) Then
@AfterMethod(alwaysRun = true)
public void shutDownDriver(ITestResult result) throws IOException {
}@AfterMethod(alwaysRun = true)
public void shutDownDriver(ITestResult result) throws IOException {
// Update SauceLabs result
if(testbed.equals("saucelab")) {
String jobID = ((RemoteWebDriver)driver).getSessionId().toString();
SauceREST client = new SauceREST("username", "key");
Map<String, Object>sauceJob = new HashMap<String, Object>();
@vcsjones
vcsjones / updatesauceLabsresults
Created January 3, 2012 19:48 — forked from tarun3kumar/updatesauceLabsresults.java
Update SauceLabs Results
```java
@AfterMethod(alwaysRun = true)
public void shutDownDriver(ITestResult result) throws IOException {
}@AfterMethod(alwaysRun = true)
public void shutDownDriver(ITestResult result) throws IOException {
// Update SauceLabs result
if(testbed.equals("saucelab")) {
String jobID = ((RemoteWebDriver)driver).getSessionId().toString();
SauceREST client = new SauceREST("username", "key");
@vcsjones
vcsjones / gist:1444744
Created December 7, 2011 21:28
OracleParameter throwing exception
OracleParameter paramString = new OracleParameter();
paramString.Value = OracleString.Null;
var sizeStr = paramString.Size; //barf
OracleParameter paramBinary = new OracleParameter();
paramBinary.Value = OracleBinary.Null;
var sizeBin = paramBinary.Size; //barf
class Program
{
static void Main(string[] args)
{
var foo = (MyType<string>) "cat";
}
}
public class MyType<t>
{
using (var timer = new System.Timers.Timer(2){AutoReset = false, Enabled = false})
{
using (var latch = new ManualResetEventSlim(false))
{
timer.Elapsed += (a, o) => latch.Set();
timer.Start();
latch.Wait();
}
}
@vcsjones
vcsjones / gist:1108373
Created July 26, 2011 23:39
NHibernate 3 Query
ISession mySession = //Get your session object.
var myUsers = from user in mySession.Query<User>() where user.Name == "Kevin" select user;
@vcsjones
vcsjones / gist:724486
Created December 2, 2010 00:00
CaptainHook Example
public class RequireTargetProcessNumber : PreCommitHook
{
protected override bool HandleHookEvent(ITransactionInfo commit)
{
string commitMessage = commit.LogMessage;
if (!HasTargetProcessNumber(commitMessage))
{
this.Context.Output.WriteError("TargetProcess Number was not specified in commit message.");
return false;
}