Skip to content

Instantly share code, notes, and snippets.

View ritasker's full-sized avatar

Richard Tasker ritasker

View GitHub Profile
@ritasker
ritasker / Delete all user information for a user
Created July 12, 2013 08:46
How to declare and use a SQL variable
DECLARE @UserId as int
SET @UserId = 8521
DELETE FROM UserAudits WHERE UserFk = @UserId
DELETE FROM Users WHERE Id = @UserId
@ritasker
ritasker / HomeModule.cs
Last active December 20, 2015 06:58
Hello world Nancy Fx example.
public class HomeModule : NancyModule
{
public HomeModule()
{
Get["/"] = parameters => "Hello Nancy";
}
}
@ritasker
ritasker / CustomBootstrapper.cs
Last active December 20, 2015 06:58
The Custom Bootstrapper from my first Nancy FX app.
public class CustomBootstrapper : DefaultNancyBootstrapper
{
protected override void ConfigureApplicationContainer(TinyIoCContainer container)
{
string mongoUser = ConfigurationManager.AppSettings["MongoUser"];
string mongoPassword = ConfigurationManager.AppSettings["MongoPassword"];
var connString = ConfigurationManager.AppSettings["MongoUrl"];
connString = string.Format(connString, mongoUser, mongoPassword);
var databaseName = connString.Split('/').Last();
@ritasker
ritasker / HomeModule.cs
Last active December 20, 2015 06:58
The Home Module of my first Nancy app.
public class HomeModule : NancyModule
{
private MongoCollection<Comment> _comments;
public HomeModule(MongoCollection<Comment> comments)
{
_comments = comments;
Get["/"] = Index;
Post["/AddComment"] = AddComment;
using DoUrden.BudgetCalculator.Domain;
using DoUrden.BudgetCalculator.Domain.Interfaces.Logic;
using DoUrden.BudgetCalculator.Domain.Interfaces.Services;
using DoUrden.BudgetCalculator.Domain.Interfaces.Services.Repositories;
using DoUrden.BudgetCalculator.Web.Modules.Authentication;
using Moq;
using Nancy;
using NUnit.Framework;
namespace DoUrden.BudgetCalculator.Tests.Unit.Modules
public AuthenticationModule(IMemberRepository memberRepository, ISecurityLogic securityLogic, IEmailService emailService)
{
_memberRepository = memberRepository;
_securityLogic = securityLogic;
_emailService = emailService;
Post["/register"] = args => PostRegister(this.Bind<RegistrationViewModel>());
}
public Negotiator PostRegister(RegistrationViewModel model)
@ritasker
ritasker / windows-vm.json
Created August 16, 2016 15:32
Packer script for creating Windows VMs in Azure
{
"variables": {
"client_id": "",
"client_secret": "",
"subscription_id": "",
"tenant_id": "",
"object_id": "",
"resource_group": "",
"storage_account": "",
@ritasker
ritasker / windows-vm.json
Created August 18, 2016 15:16
Packer File for Provisioning Windows VM Images
{
"variables": {
"client_id": "",
"client_secret": "",
"subscription_id": "",
"tenant_id": "",
"object_id": "",
"resource_group": "",
"storage_account": "",
2016/08/18 16:35:20 [INFO] Packer version: 0.10.1
2016/08/18 16:35:20 Packer Target OS/Arch: darwin amd64
2016/08/18 16:35:20 Built with Go Version: go1.6.2
2016/08/18 16:35:20 Detected home directory from env var: /Users/ritasker
2016/08/18 16:35:20 Using internal plugin for amazon-ebs
2016/08/18 16:35:20 Using internal plugin for qemu
2016/08/18 16:35:20 Using internal plugin for vmware-iso
2016/08/18 16:35:20 Using internal plugin for parallels-pvm
2016/08/18 16:35:20 Using internal plugin for amazon-chroot
2016/08/18 16:35:20 Using internal plugin for amazon-instance
@ritasker
ritasker / main.tf
Created August 23, 2016 11:19
Terraform Files
# Create a resource group
resource "azurerm_resource_group" "eg-resource-group" {
name = "EventGeniusApi"
location = "${var.location}"
}
# Create SQL Server
resource "azurerm_sql_server" "eg-sql-server" {
name = "eg-sql-sandbox"
resource_group_name = "${azurerm_resource_group.eg-resource-group.name}"