Skip to content

Instantly share code, notes, and snippets.

View dcrosby42's full-sized avatar

David Crosby dcrosby42

  • Cisco Systems, Inc.
  • Grand Rapids MI
View GitHub Profile
#import "SpecHelper.h"
#import "CrozSpecialObjectionModule.h"
SPEC_BEGIN(CrozSpecialObjectionModuleSpec)
describe(@"ClassName", ^{
__block CrozSpecialObjectionModule *target = nil;
__block UIWindow *window = nil;
beforeEach(^{
@dcrosby42
dcrosby42 / CrozSpecialObjectionModule.m
Created July 21, 2011 15:52
Imple of objection module .m
#import "CrozSpecialObjectionModule.h"
@implementation CrozSpecialObjectionModule
@synthesize window = _window;
- (id) initWithWindow:(UIWindow *)window {
if ((self = [super init])) {
_window = [window retain];
}
return self;
@dcrosby42
dcrosby42 / CrozSpecialObjectionModule.h
Created July 21, 2011 15:50
Imple of objection module
#import <Foundation/Foundation.h>
@interface CrozSpecialObjectionModule : ObjectionModule {
UIWindow *_window;
}
@property (nonatomic, readonly, retain) IBOutlet UIWindow *window;
- (id) initWithWindow:(UIWindow *)window;
@end
@dcrosby42
dcrosby42 / hex_string_example_uses.rb
Created July 6, 2011 05:18
Example uses of HexString, extracted from README.md
# Load HexString and automatically extend String:
require 'hex_string'
# Convert data to human-readable hex tuples:
>> "hello".to_hex_string
=> "68 65 6c 6c 6f"
# Compact a hex string into its data equivalent:
>> "77 6f 72 6c 64".to_byte_string
=> "world"
@dcrosby42
dcrosby42 / hex_string_example_uses.rb
Created July 6, 2011 04:58
Example uses of HexString, extracted from README.md
# Load HexString and automatically extend String:
require 'hex_string'
# Convert data to human-readable hex tuples:
>> "hello".to_hex_string
=> "68 65 6c 6c 6f"
# Compact a hex string into its data equivalent:
>> "77 6f 72 6c 64".to_byte_string
=> "world"
@dcrosby42
dcrosby42 / myGRcitypoints issue #2
Created March 9, 2011 15:37
Vendor "Wes" cannot submit vendor info.
System.Data.SqlClient.SqlException (0x80131904): String or binary data would be truncated.
The statement has been terminated.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result
@dcrosby42
dcrosby42 / Build_msbuild.xml
Created February 1, 2011 05:40
Sample MSBuild file for running MigratorDotNet migrations
<Project DefaultTargets="All" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask AssemblyFile="Lib\Migrator.MSBuild.dll" TaskName="Migrator.MSBuild.Migrate" />
<PropertyGroup>
<To>-1</To>
<Env>Development</Env>
<ConnectionString Condition="'$(Env)'=='Development'">Database=myapp_dev;Data Source=localhost;User Id=myuser;Password=abc123</ConnectionString>
<ConnectionString Condition="'$(Env)'=='Test'">Database=myapp_test;Data Source=test_db_server;User Id=myuser;Password=abc123</ConnectionString>
<ConnectionString Condition="'$(Env)'=='Production'">Database=myapp_prod;Data Source=prod_db_server;User Id=myuser;Password=abc123</ConnectionString>
@dcrosby42
dcrosby42 / Global_asax.cs
Created February 1, 2011 05:16
Example snippet of Application_Start to execute migrations at startup
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
var assembly = Assembly.GetAssembly(typeof(MvcApplication));
var connectString = ConfigurationManager.ConnectStrings(“ApplicationServices”).ConnectionString;
var migrator = new Migrator(“SqlServer”, connectString, assembly);
@dcrosby42
dcrosby42 / MigrationTestHelper.cs
Created February 1, 2011 05:08
Utility code that uses MigratorDotNet to execute full sweep migrations.
namespace UnitTests.TestHelpers
{
public class MigrationTestHelper
{
public static readonly string Provider = "SqlServer";
public static readonly string ConnectString = "Database=myapp_test;Data Source=localhost;User Id=myUser;Password=abc123";
public static Migrator.Migrator GetMigrator()
{
var assembly = Assembly.GetAssembly(typeof(BootstrapAspDotNetAuthTables));
@dcrosby42
dcrosby42 / FullMigrationTest.cs
Created February 1, 2011 05:05
Sample code for a migration test using C# and MigratorDotNet for an ASP.NET MVC 2 web app
namespace UnitTests
{
public class FullMigrationTest
{
public static string[] AllExpectedTables = new[]
{
"BlogPost",
"Attachment",
"Photo",