Skip to content

Instantly share code, notes, and snippets.

@NeilRobbins
NeilRobbins / UsefulCommands.sh
Last active August 29, 2015 13:56
Useful linux commands
#==== change text file end-of-line from DOS (Windows) to Linux ====#
find . -name "*.sh" -exec sed -i 's/\r\+$//g' '{}' \;
#==== hardware/system info ====
numactl --hardware
dmesg
@NeilRobbins
NeilRobbins / SimpleTypeAlias.cs
Created March 28, 2014 12:06
Simple Type Aliasing in C#
public class WeekKey
{
private int value;
public static implicit operator int(WeekKey weekKey) { return weekKey.value; }
public static implicit operator WeekKey(int weekKey) { return new WeekKey { value = weekKey }; }
}
@NeilRobbins
NeilRobbins / VerticaParameterIssue2.cs
Created April 16, 2014 12:00
Demonstrates an issue with Vertica 6.1.3 where VerticaCommands with parameters cannot contain more than one statement.
public static void M(string[] args)
{
var builder = new VerticaConnectionStringBuilder
{
Host = "54.83.238.208",
Database = "Test",
User = "dbadmin",
Password = "password",
Port = 5433,
Pooling = true,
@NeilRobbins
NeilRobbins / drop_schema_cascade.sql
Created June 10, 2014 09:49
Drop a schema with all of its tables in SQL Server. Note that this won't clean up objects other than tables.
-- DROP THE CONSTRAINTS
DECLARE @database nvarchar(50);
DECLARE @schemaName nvarchar(50);
DECLARE @sql nvarchar(300);
SET @database = ''; -- set the catalog name
SET @schemaName = ''; -- set the database name
SELECT @sql = 'USE ' + @database +';';
EXEC sp_executesql @sql;
@NeilRobbins
NeilRobbins / alias.cs
Last active August 29, 2015 14:02
Aliasing in C#
public abstract class Alias
{
protected readonly string Value;
protected Alias(string value)
{
if (value == null) throw new ArgumentNullException("value");
if (string.Empty.Equals(value, StringComparison.InvariantCultureIgnoreCase))
throw new ArgumentException("Value must not be empty.", "value");
Value = value;
Put the commands to execute in here
@NeilRobbins
NeilRobbins / static_webserver.sh
Created August 9, 2014 20:20
start a simple webserver to serve static files
twistd -n web -p 8888 --path .
// So the question is - how would I configure OpenRasta to enable the below, where a real-world URI might look like (and any number of FooId
// arguments may be supplied):
// /queries/FooReportResource?LastReportDate=2010-05-23Z&ApplicableFoos=FooId1,FooId2,FooId3,FooId4
public class Configuration : IConfigurationSource
{
public void Configure()
{
using (OpenRastaConfiguration.Manual)
{
public interface IHandleCommands<TCommand> where TCommand : IAmACommand
{
void Handle(TCommand command);
}
public interface IAmACommand
{
Guid AggregateId { get; }
}
Type actual = Given.AType("Foo", With.A.Constructor(
With.A.Parameter("bar", Of.AType("Bar", With.A.DefaultConstructor))
, With.A.Parameter("baz", Of.AType("Baz",
With.A.Constructor(With.A.Parameter("fizz", Of.AType("Fizz", With.A.DefaultConstructor)))))
, With.A.Parameter("buzz", Of.AnExistingType<int>())));