Skip to content

Instantly share code, notes, and snippets.

ALTER PROC sp_generate_inserts
(
@table_name varchar(776), -- The table/view for which the INSERT statements will be generated using the existing data
@target_table varchar(776) = NULL, -- Use this parameter to specify a different table name into which the data will be inserted
@include_column_list bit = 1, -- Use this parameter to include/ommit column list in the generated INSERT statement
@from varchar(800) = NULL, -- Use this parameter to filter the rows based on a filter condition (using WHERE)
@include_timestamp bit = 0, -- Specify 1 for this parameter, if you want to include the TIMESTAMP/ROWVERSION column's data in the INSERT statement
@debug_mode bit = 0, -- If @debug_mode is set to 1, the SQL statements constructed by this procedure will be printed for later examination
@owner varchar(64) = NULL, -- Use this parameter if you are not the owner of the table
[Trait("Category", "Spike")]
public class OomBuilder
{
const string StaticConverter = @"
public static {{To}} To{{To}}({{From}} src)
{
return new {{To}}
{
{{#each Matches}}
{{this}} = src.{{this}},{{/each}}
public static TValue GetValueOrDefault<TKey, TValue> (this Dictionary<TKey, TValue> d, TKey key, TValue defaultValue = default(TValue))
{
TValue value;
return d.TryGetValue(key, out value) ? value : defaultValue;
}
@robfe
robfe / SomethingDataContext.cs
Created March 5, 2014 22:38
EF Datacontext.WaitForMicroOutageToPass (for sql on azure)
void WaitForMicroOutageToPass() //call this from your constructor
{
if (!Database.Exists())
{
return;
}
var connection = Database.Connection;
for (int i = 0; i < 10; i++)
{
@robfe
robfe / Example.xaml
Created January 19, 2014 22:56
Render ZXing qrcodes into a geometry for a WPF path
<Path Name="imageBarcodeEncoder" Fill="Black" Width="200" Height="200" Data="[set this from a GeometryBarcodeWriter]"/>
@robfe
robfe / MultiplexedOperationDispatcher.cs
Created January 13, 2014 04:40
Ensures that specific observables complete in serial (by a particular key)
public static class MultiplexedOperationDispatcher
{
static readonly Subject<Tuple<string, IObservable<Unit>>> Operations = new Subject<Tuple<string, IObservable<Unit>>>();
static MultiplexedOperationDispatcher()
{
Operations.GroupBy(x => x.Item1).Subscribe(g => g.Select(x => x.Item2).Concat().Subscribe());
}
public static IObservable<T> DispatchedByLockKey<T>(this IObservable<T> source, string lockKey)
@robfe
robfe / ObservableCollectionExtensions.cs
Created October 7, 2013 22:51
[RX] A live selectmany for items currently inside an observable collection
public static IObservable<TResult> SelectMany<TSource, TResult>(this ObservableCollection<TSource> collection, Func<TSource, IObservable<TResult>> selector)
{
return Observable.Create<TResult>(observer =>
{
// assume events are raised on the same thread (i.e. dispatcher), so we don't need a concurrent dictionary
var subscriptions = new Dictionary<TSource, IDisposable>();
foreach (var source in collection)
{
//subscribe selector to all items already in the collection
@robfe
robfe / Xunit.cs
Created October 1, 2013 21:37
Hack a Fact subclass into your current project to make specflow skip any tests with pending steps. Ultra dirty/unfinished
extern alias rxu; //alias the xunit dll to "rxu" - Real X Unit
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using TechTalk.SpecFlow;
namespace Xunit
{
public class FactAttribute:rxu.Xunit.FactAttribute

TypeScript (0.9.1)

The Language

Type Checks

Primitives

A primitive type is a number, bool, string or void.

Before type check:

@robfe
robfe / Tuples.tt
Last active December 21, 2015 00:09
Create as many n-tuples as you like
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Runtime.Remoting.Messaging" #>
<#@ output extension=".Designer.cs" #>
using System.Collections.Generic;
namespace <#=CallContext.GetData("NamespaceHint")#>
{