Skip to content

Instantly share code, notes, and snippets.

@brettveenstra
brettveenstra / gist:747cded635cc67835411
Created July 10, 2015 17:36 — forked from tjchaplin/gist:621edccbfddc0d3526b5
Read package.json from TeamCity
# These are project build parameters in TeamCity
# Depending on the branch, we will use different major/minor versions
[System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions")
$ser = New-Object System.Web.Script.Serialization.JavaScriptSerializer
$json = Get-Content "package.json" | Out-String
$obj = $ser.DeserializeObject($json)
$majorVerion = ($obj['version'] -split "\.")[0]
$minorVerion = ($obj['version'] -split "\.")[1]
$buildCounter = "%teamcity.build.counter%"
$buildNumber = "$majorVerion.$minorVerion.$buildCounter"
# see http://stackoverflow.com/questions/28017374/what-is-the-suggested-way-to-install-brew-node-js-io-js-nvm-npm-on-os-x
brew update
brew install nvm
source $(brew --prefix nvm)/nvm.sh
echo "source $(brew --prefix nvm)/nvm.sh" >> ~/.zshrc
nvm install v0.12.7 #latest for now
npm install -g npm@latest
@brettveenstra
brettveenstra / 01-Update-Windows.ps1
Last active August 29, 2015 14:27 — forked from ChaseFlorell/01-Update-Windows.ps1
Boxstarter Installation Scripts
# http://boxstarter.org/package/url?
#####################
# BEGIN CONFIGURATION
#####################
#region Initial Windows Config
Install-WindowsUpdate -AcceptEula
Update-ExecutionPolicy Unrestricted
@brettveenstra
brettveenstra / boxstarter.txt
Last active August 29, 2015 14:27 — forked from DavidBoike/boxstarter.txt
David's Boxstarter Script
#Basic Setup
Install-WindowsUpdate -AcceptEula
Update-ExecutionPolicy Unrestricted
Set-ExplorerOptions -showHiddenFilesFoldersDrives -showProtectedOSFiles -showFileExtensions
Enable-RemoteDesktop
# Windows Features
choco install Microsoft-Hyper-V-All -source windowsFeatures
choco install IIS-WebServerRole -source windowsfeatures
choco install IIS-HttpCompressionDynamic -source windowsfeatures
@brettveenstra
brettveenstra / ko-chosen.js
Created September 30, 2015 12:56 — forked from isDipesh/ko-chosen.js
Collection of Knockout.js custom bindings.
//http://stackoverflow.com/questions/13210663/how-to-order-knockout-bindings
ko.bindingHandlers.chosen = {
init: function(element, valueAccessor, allBindingsAccessor, viewModel) {
var allBindings = allBindingsAccessor();
var options = {default: 'Select one...'};
$.extend(options, allBindings.chosen)
$(element).attr('data-placeholder', options.default);
@brettveenstra
brettveenstra / custom-validation-view-strategy.js
Created January 19, 2016 14:34 — forked from TylerJPresley/custom-validation-view-strategy.js
My custom approach to Aurelia's validation view strategy. It's closely based on the twbootstrap-view-strategy.js from within aurelia/validation.
import {ValidationViewStrategy} from 'aurelia-validation/validation-view-strategy';
export class CustomValidationViewStrategyBase extends ValidationViewStrategy {
constructor(containerClass, containerSuccessClass, containerErrorClass, appendClass, appendActiveClass) {
super();
this.containerClass = containerClass; // The class for the container.
this.containerErrorClass = containerErrorClass; // What's the error class for the container
this.containerSuccessClass = containerSuccessClass; // What's the error class for the container
this.appendClass = appendClass; // Where we're appending the message
@brettveenstra
brettveenstra / WebApiConfig.cs
Created April 11, 2016 19:30 — forked from nakamura-to/WebApiConfig.cs
ModelMetadata.ConvertEmptyStringToNull in ASP.NET Web API
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
@brettveenstra
brettveenstra / HtmlFormatter.cs
Created April 12, 2016 16:21 — forked from jakejscott/HtmlFormatter.cs
Asp.net web api, text/html, text/plain formatter
public class HtmlFormatter : MediaTypeFormatter
{
public HtmlFormatter()
{
SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/plain"));
}
protected override bool CanReadType(Type type)
{
@brettveenstra
brettveenstra / swagger-overrides.js
Created June 2, 2016 13:27 — forked from davetransom/swagger-overrides.js
A javascript override of swagger-ui markdown rendering to play nicely with XML comments generated from .NET
(function () {
var re_leading_whitespace = /^\s+(?=[^\s])/g,
re_is_whitespace = /^\s*$/,
re_br = /<br ?\/?>/gi,
re_blockquotes_for_html_fix = /^(\s*&gt;)+/gm;
function transform_markdown(html, text) {
var
// leading padding string, if found
@brettveenstra
brettveenstra / transform-xml.ps1
Created June 28, 2016 14:18 — forked from sayedihashimi/transform-xml.ps1
Script which can be used to transform an XML file using XDT. All you need to do is download the script and call it. The script will download the files it needs to run.
<#
.SYNOPSIS
You can use this script to easly transform any XML file using XDT.
To use this script you can just save it locally and execute it. The script
will download it's dependencies automatically.
#>
[cmdletbinding()]
param(
[Parameter(
Mandatory=$true,