Skip to content

Instantly share code, notes, and snippets.

View scottmcarthur's full-sized avatar

Scott McArthur scottmcarthur

  • Edinburgh, United Kingdom
View GitHub Profile
@scottmcarthur
scottmcarthur / SelectBoxComponent.js
Last active December 29, 2015 04:19
Ember.js Bootstrap 3 Select Box. Creates a dynamically populated drop down list, that is styled using Bootstrap 3.
App.SelectBoxComponent = Ember.Component.extend({
// Container is <div class="btn-group app-selectbox">
classNames: ["btn-group", "app-selectbox"],
tagName: "div",
// Set attribute "fullWidth=true" to expand 100%
fullWidth: false,
classNameBindings: ["fullWidth"],
// Source data (the same as Ember.Select)
@scottmcarthur
scottmcarthur / Handlebars Remote
Created December 27, 2013 09:29
Remote Handlebars File
<h1>Hello World</h1>
Hello {{name}}
<strong>I was loaded from a URL!</strong>
@scottmcarthur
scottmcarthur / ServiceStackApp.cs
Created January 13, 2014 12:51
ServiceStack Upload with Multipart. (Working)
using System;
using ServiceStack;
namespace Testv4
{
class MainClass
{
public static void Main()
{
var appHost = new AppHost(500);
@scottmcarthur
scottmcarthur / Program.cs
Last active January 4, 2016 02:39
Deferred Validation Example. This example uses a custom validator plugin that is a substitute for the ServiceStack standard ValidationFeature plugin. When a custom attribute of `MyRoleAttribute` is applied to the request DTO, then the validation will not be run, allowing the MyRoleAttribute to run the validation checks once it has completed. Req…
using System;
using System.Linq;
using ServiceStack.ServiceInterface;
using ServiceStack.ServiceHost;
using ServiceStack.WebHost.Endpoints;
using ServiceStack.Common.Web;
using ServiceStack.Logging;
using ServiceStack.FluentValidation.Results;
using ServiceStack.Text;
using ServiceStack.ServiceInterface.Validation;
@scottmcarthur
scottmcarthur / Program.cs
Created January 23, 2014 12:00
Basic Authentication, Multiple repositories - ServiceStack v4
using System;
using System.Linq;
using ServiceStack;
using ServiceStack.Auth;
using ServiceStack.Web;
using System.Net;
using System.Text;
using System.Collections.Generic;
namespace Testv4
@scottmcarthur
scottmcarthur / CheckDatabaseModel.cs
Last active January 4, 2016 08:38
How to automatically detect database model changes in ServiceStack.OrmLite, and have the database update automatically.
public void CheckDatabaseModel(Type modelType)
{
// Get the referenced model version
string modelVersion = Assembly.GetAssembly(modelType).GetName().Version.ToString();
// Determine the last model version number from the configuration
var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var lastModelVersion = config.AppSettings.Settings["DatabaseModelVersion"];
// Determine if the model has changed
@scottmcarthur
scottmcarthur / Program.cs
Last active August 29, 2015 13:55
Demo of ServiceStack Form Post Collection Data
using System;
using ServiceStack;
namespace Tests.Recipe
{
class MainClass
{
public static void Main()
{
// Very basic console host
@scottmcarthur
scottmcarthur / program.cs
Created February 1, 2014 09:26
ServiceStack IoC injection example (v4)
using System;
using ServiceStack;
namespace Tests.Recipe
{
class MainClass
{
public static void Main()
{
// Very basic console host
@scottmcarthur
scottmcarthur / program.cs
Last active August 29, 2015 13:55
ServiceStack IoC Lifetime Test (v3)
using System;
using ServiceStack.ServiceInterface;
using ServiceStack.ServiceHost;
using ServiceStack.WebHost.Endpoints;
using Funq;
namespace Testv3
{
class MainClass
{
@scottmcarthur
scottmcarthur / program.cs
Created February 9, 2014 12:23
Transparent encoding/decoding Id properties in ServiceStack v4
using System;
using ServiceStack;
using System.Text;
using ServiceStack.Web;
namespace ComplexIdTest
{
class MainClass
{
public static void Main()