Skip to content

Instantly share code, notes, and snippets.

View shawnmclean's full-sized avatar
🐭
:)

Shawn Mclean shawnmclean

🐭
:)
View GitHub Profile
@shawnmclean
shawnmclean / HelpPageConfig.cs
Created August 31, 2014 18:19
HelpPageConfig modified for integration tests.
public static class HelpPageConfig
{
public static void Register(HttpConfiguration config)
{
var path = HostingEnvironment.MapPath("~/App_Data/XmlDocument.xml");
if (!string.IsNullOrWhiteSpace(path))
{
config.SetDocumentationProvider(
new XmlDocumentationProvider(path));
}
@shawnmclean
shawnmclean / Startup.Auth.cs
Last active August 29, 2015 14:05
Manually setting Data Protection Provider
userManager.UserTokenProvider = new EmailTokenProvider<IdentityUser, Guid>();
@shawnmclean
shawnmclean / SetupUserManager.cs
Created August 31, 2014 18:43
Setting up UserTokenProvider
IDataProtectionProvider provider = app.GetDataProtectionProvider();
if (provider != null)
{
userManager.UserTokenProvider = new DataProtectorTokenProvider<IdentityUser, Guid>(provider.Create("User Tokens"));
}
@shawnmclean
shawnmclean / TestBase.cs
Last active August 29, 2015 14:05
Base Test class for integration testing WebAPI
[TestClass]
public class TestBase
{
private static TestServer server;
public static TestServer Server
{
get { return server; }
}
[TestClass]
public class AccountsTests : TestBase
{
[TestMethod]
public async Task Register_Returns_Successfull()
{
var registerModel = new RegisterModel
{
Email = Constants.USER_EMAIL,
FirstName = "Shawn",
@shawnmclean
shawnmclean / swap.ps1
Created September 18, 2014 05:54
Swap Azure staging and production
Import-Module Azure
Import-AzurePublishSettingsFile "C:\Certificate\Azure.publishsettings"
Write-Host "Swapping staging and production slots..."
Switch-AzureWebsiteSlot -Name "griklyapi" -Slot1 "production" -Slot2 "staging" -Force
Write-Host "Swap complete"
@shawnmclean
shawnmclean / jaobersvervotehack.js
Last active August 29, 2015 14:27
Free Vote Script for Jamaica Observer Voting System
var request = require('request');
var lineReader = require('line-reader');
var selection = 1; // <- the id of the person to vote for
lineReader.eachLine('proxy.txt', function(line, last) {
request.post({
uri: 'http://jol.jamaicaobserver.com/mogul_poll/add_vote.php?the_vote='+selection,
proxy: 'http://'+ line
}, function (err, resp, body) {});
});
@shawnmclean
shawnmclean / dynamicvalidation.html
Created August 10, 2011 04:11
Unobtrusive jquery validation with dynamic content in ASP.NET MVC
@using (Html.BeginForm())
{
<div id="RegBox" style="display: none;">
@Html.LabelFor(m => Model.Name)
@Html.TextBoxFor(m => Model.Name)
@Html.ValidationMessageFor(m => m.Name)
</div>
<div id="LoginBox">
@Html.LabelFor(m => Model.Email)
@shawnmclean
shawnmclean / convas2img.htm
Created August 23, 2011 00:43
Convert A canvas to image
<canvas id="MyCanvas" width="300" height="300">
</canvas>
<img id="MyImg"/>
<script>
function drawAndConvertStuff(canvas) {
var canvasContext = canvas.getContext('2d');
//draw a black box
@shawnmclean
shawnmclean / CountSorted.cs
Created November 13, 2011 23:20
Count Sorted Array
public static int CountSorted<T>(this List<T> list, T item) where T : IComparable
{
//find random index of the item
int index = list.BinarySearch(item);
//if item isn't found, just return -1
if (index < 0)
return -1;