Skip to content

Instantly share code, notes, and snippets.

View ducas's full-sized avatar

Ducas Francis ducas

  • Readify
  • Sydney, Australia
View GitHub Profile
@ducas
ducas / modal.js
Created March 21, 2014 04:37
RequireJS + Bootstrap Modal
define(
['jquery', 'bootstrap'],
function () {
var modalMarkup = '<div class="modal fade">' +
' <div class="modal-dialog">' +
' <div class="modal-content">' +
' <div class="modal-header">' +
' <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>' +
' <h4 class="modal-title">Single Movie ID</h4>' +
' </div>' +
@ducas
ducas / ajax.js
Created March 21, 2014 04:39
AJAX Loading Indicator
/* global baseUrl, alert, setTimeout */
define(
['jquery'],
function ($) {
var loadingCount = 0,
loadingMarkup = '<div id="loading-indicator" style="display:none;"><div></div><img src="/Content/Images/loading.gif" /></div>',
hiding = false,
showLoading = function () {
loadingCount++;
if (loadingCount !== 1) { return; }
@ducas
ducas / JSendResult.cs
Created March 21, 2014 04:43
MVC + JSend Result
using System;
using System.Web.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
namespace Web.Core
{
public class JSendResult : JsonResult
{
@ducas
ducas / CamelCaseStringEnumConverter.cs
Created April 8, 2014 23:13
ASP.Net Web API + JSend
using Newtonsoft.Json.Converters;
namespace Web.Core
{
public class CamelCaseStringEnumConverter : StringEnumConverter
{
public CamelCaseStringEnumConverter()
{
CamelCaseText = true;
}
@ducas
ducas / MongoApiController.cs
Created April 10, 2014 23:53
Generic WebAPI controller to provide a REST interface for MongoDB collections
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using MongoDB.Bson;
using MongoDB.Driver;
using MongoDB.Driver.Builders;
namespace Web.Core
{
public abstract class MongoApiController<T> : ApiController
@ducas
ducas / Initialize-Tentacle.ps1
Created June 17, 2014 22:46
Initialize an Octopus Deploy Tentacle by downloading, installing and setting up the Tentacle software
$OctopusThumbprint = "YOUR_THUMBRPRINT"
$OctopesServer = "http://your.octopusserver.com"
$ApiKey = "YOUR_API_KEY"
$Role = "a-role"
$Environment = "UAT"
$TentacleDownloadUrl = "http://octopusdeploy.com/downloads/latest/OctopusTentacle64"
$InstallDirectory = "C:\Program Files\Octopus Deploy\Tentacle"
@ducas
ducas / Validate-ReleaseAndPackagesForEnvironment.ps1
Last active August 29, 2015 14:03
Validate that a release and its packages can be deployed to an environment based on whether they have pre-release version numbers
$environment = $OctopusParameters['Octopus.Environment.Name']
$releaseNumber = $OctopusParameters['Octopus.Release.Number']
$packages = @(
@{
"Id" = $OctopusParameters['Octopus.Action[Update Database].Package.NuGetPackageId'];
"Version" = $OctopusParameters['Octopus.Action[Update Database].Package.NuGetPackageVersion']
},
@{
"Id" = $OctopusParameters['Octopus.Action[Deploy Website].Package.NuGetPackageId'];
"Version" = $OctopusParameters['Octopus.Action[Deploy Website].Package.NuGetPackageVersion']
@ducas
ducas / Octopus-Umbraco.psm1
Last active August 29, 2015 14:04
Umbraco helpers for Octopus Deploy
function Set-UmbracoPermissions($SitePath, $AppPoolAccount, $PathOverrides)
{
$readExecute = $AppPoolAccount,"ReadAndExecute","ContainerInherit, ObjectInherit","None","Allow"
$read = $AppPoolAccount,"Read","ContainerInherit, ObjectInherit","None","Allow"
$modify = $AppPoolAccount,"Modify","ContainerInherit, ObjectInherit","None","Allow"
$fileModify = $AppPoolAccount,"Modify","Allow"
$objects = @{}
$objects["App_Browsers"] = $readExecute
$objects["App_Code"] = $modify
@ducas
ducas / InMemoryIssuerNameRegistry.cs
Created September 5, 2014 01:27
In-Memory Issuer Name Registry Implementation for WAAD
using System.Collections.Generic;
using System.IdentityModel.Tokens;
using System.Linq;
using Web.Models;
namespace Web.Utils
{
public class InMemoryIssuerNameRegistry : ValidatingIssuerNameRegistry
{
public class TenantData
@ducas
ducas / jquery.preventNavigation.js
Last active August 29, 2015 14:09
Confirm Navigation Dialog
(function ($) {
$.fn.preventNavigation = function () {
var that = this;
this.on('change', 'input, select, textarea', function () {
that.data('field-change', true);
});
this.on('submit', function () {