Skip to content

Instantly share code, notes, and snippets.

@underwhelmed
underwhelmed / hosts
Created October 20, 2010 14:25
Best Time Saving Method
127.0.0.1 twitter.com
@underwhelmed
underwhelmed / DateTime.cs
Created October 22, 2010 16:12
What's wrong with this method?
public bool IsValidSmallDateTime(DateTime date)
{
return date >= Convert.ToDateTime("1/1/1900") || date <= Convert.ToDateTime("6/6/2079");
}
Imports System.Data.SqlClient
Imports System.Collections.Generic
Imports SD.LLBLGen.Pro.ORMSupportClasses
Public Interface ISqlBulkCopyWrapper
Sub WriteToServer(ByVal destTableName As String, ByVal table As DataTable, ByVal mappings As IEnumerable(Of SqlBulkCopyColumnMapping), ByRef tran As ITransaction)
End Interface
Public Class SqlBulkCopyWrapper
Implements ISqlBulkCopyWrapper
<div id="content">
<section class="pages">
<section class="full_page">
<h1>Login to the Website</h1>
<form>
....
</form>
</section>
</section>
</div>
Feature: Contact Form
In order to provide feedback
As a user
I want to contact the website owners online
Scenario: Submitting with valid information
Given I am on the contact page
When I fill in "Name" with "Steve Perry"
And I fill in "Email" with "test@example.com"
@underwhelmed
underwhelmed / ControllerCookie_Test.cs
Created January 7, 2011 20:23
Testing setting of cookies in an ASP.NET MVC 2 Controller
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult ADLogin()
{
//Delete the cookie passed to this page
if (!Request.Cookies["_CognitionAuthCheck"] == null)
{
HttpCookie myCookie = new HttpCookie("_CognitionAuthCheck");
myCookie.Expires = DateTime.Now().AddDays(-1D);
Response.Cookies.Add(myCookie);
}
[Test]
public void FailWhenTheFirstNameIsTooLong()
{
var svc = new UserImportValidationService(_userRepo, _divRepo, _jcRepo, _locRepo);
var user = new UserRecord();
user.UserLoginID = "VALID";
user.FirstName = "This is really long and shouldn't be imported because we said that the first name and last name fields should only be less than 50 characters. It's pretty arbitrary, but that's what the database can hold so that's why we're doing it that way. Groundhog Day was a sweet movie.";
Validation val = svc.IsValid(user);
@underwhelmed
underwhelmed / Fast.sql
Created January 17, 2011 17:52
This is generated by LLBLGen .UpdateMulti() using Self Servicing
declare @DateRemovedUTC datetime,@DateRemovedTimeZoneLookupID tinyint,@DateRemovedByID bigint,@IsAssigned bit,@PositionID6 bigint,@PositionID1 bigint,@ExtendedPropertyID2 int,@PositionID3 bigint,@IsExclusion4 bit,@IsCurriculumExcluded5 bit
select @DateRemovedUTC='2011-01-14 22:56:19',@DateRemovedTimeZoneLookupID=43,@DateRemovedByID=1,@IsAssigned=0,@PositionID6=70,@PositionID1=70,@ExtendedPropertyID2=6,@PositionID3=70,@IsExclusion4=0,@IsCurriculumExcluded5=0
UPDATE [Cognition].[dbo].[PositionUsers] SET [DateRemovedUTC]=@DateRemovedUTC,[DateRemovedTimeZoneLookupID]=@DateRemovedTimeZoneLookupID,[DateRemovedByID]=@DateRemovedByID,[IsAssigned]=@IsAssigned FROM ( (SELECT DISTINCT
[Cognition].[dbo].[Users].[UserID] FROM (((( [Cognition].[dbo].[Users] INNER JOIN [Cognition].[dbo].[PositionFilterDivision] [LPA_P3] ON
[Cognition].[dbo].[Users].[DivisionID] = [LPA_P3].[DivisionID]) INNER JOIN [Cognition].[dbo].[PositionFilter] [LPA_P2] ON [LPA_P2].[ID]=[LPA_P3].[ID]) INNER JOIN
[Cognition].[dbo].[PositionFilter
@underwhelmed
underwhelmed / result.txt
Created January 19, 2011 00:10
dates in a cucumber table need to be in YYYY MM DD format
(::) failed steps (::)
Validation failed: Start at can't be blank, End at can't be blank (ActiveRecord::RecordInvalid)
./features/step_definitions/view_calendar_steps.rb:7:in `block (2 levels) in <top (required)>'
./features/step_definitions/view_calendar_steps.rb:6:in `each'
./features/step_definitions/view_calendar_steps.rb:6:in `/^I have an Event with the following attributes:$/'
features/view_calendar_detail.feature:8:in `Given I have an Event with the following attributes:'
@underwhelmed
underwhelmed / RecordStringConverter.cs
Created January 26, 2011 16:41
How I would implement storing the record line with the storage object using FileHelpers
using System;
using FileHelpers;
using NUnit.Framework;
namespace FileHelpers.Tests.Converters
{
[TestFixture]
public class RecordStringConverter.cs
{
FileHelperEngine<UserRecord> engine = new FileHelperEngine<UserRecord>();