Skip to content

Instantly share code, notes, and snippets.

# create rvmrc file
create_file ".rvmrc", "rvm 1.9.2@#{app_name}"
gem "haml-rails"
# hpricot and ruby_parser required by haml
gem "hpricot", :group => :development
gem "ruby_parser", :group => :development
gem "nifty-generators"
gem "simple_form"
gem "jquery-rails"
@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>();
@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 / 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
[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 / 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);
}
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"
<div id="content">
<section class="pages">
<section class="full_page">
<h1>Login to the Website</h1>
<form>
....
</form>
</section>
</section>
</div>
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
@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");
}