Skip to content

Instantly share code, notes, and snippets.

View mbenford's full-sized avatar

Michael Benford mbenford

View GitHub Profile
@mbenford
mbenford / Bootstrap.bat
Created May 27, 2013 19:09
Bootstrap script to register a Tentacle with an Octopus server and deploy a release to its environment/role. Requires a Tentacle installer and Octo.exe in the same directory of the script.
start /wait msiexec /i Octopus.Tentacle.<version>.msi /quiet INSTALLLOCATION=C:\Octopus
cd C:\Octopus\Agent
tentacle configure --appdir="C:\Applications" --port=10933 --trust=<server-thumbprint>
tentacle new-certificate
tentacle install
tentacle register-with --server=<server-url> --environment=<environment> --role=<role> --apikey=<some-user-apikey>
octo deploy-release --project=<project-name> --deployto=<environment-to-deploy> --version=<version-to-deploy> --server=<server-url> --apikey=<some-user-apikey>
var sumsOfDivisors = from i in Enumerable.Range(1, 10000)
select new { Number = (long)i, SumOfDivisors = Toolbox.GetProperDivisors(i).Sum() };
var amicableNumbers = from a in sumsOfDivisors
join b in sumsOfDivisors on new { x = a.Number, y = a.SumOfDivisors } equals
new { x = b.SumOfDivisors, y = b.Number }
where a.Number != b.Number
select a.Number;
@mbenford
mbenford / SimpleTagsInputDemo.html
Created September 1, 2013 06:35
Simple Tags Input Demo
<body ng-init="tags=['some','cool','tags']">
<tags-input ng-model="tags"></tags-input>
</body>
@mbenford
mbenford / ngTranscludeAppend.js
Last active December 29, 2015 05:39
AngularJS directive that re-creates the old ngTransclude behavior
app.directive('ngTranscludeAppend', function() {
return function(scope, element, attrs, ctrl, transcludeFn) {
if (!transcludeFn) return;
transcludeFn(function(clone) {
element.append(clone);
});
};
});
@mbenford
mbenford / autosize.js
Created December 18, 2013 03:47
Autosize directive for AngularJS. Resizes an input field automatically so its content is always visible. http://plnkr.co/edit/iodg4SqKBXL0V6ZJmRue
app.directive('autosize', function($document) {
return {
require: 'ngModel',
link: function(scope, element, attrs, ctrl) {
var placeholder, span, resize;
placeholder = element.attr('placeholder') || '';
span = angular.element('<span></span>');
span[0].style.cssText = getComputedStyle(element[0]).cssText;
@mbenford
mbenford / demo.html
Last active September 30, 2020 16:17
Angular directive that binds attributes without relying on interpolation
<input type="text" ng-bind-attrs="{placeholder: somePropertyOfTheScope, tabindex: anotherPropertyOfTheScope}" >
@mbenford
mbenford / .gitconfig
Last active August 29, 2015 14:02
Useful Git alias
[alias]
aa = add -A
co = checkout
st = status
ci = commit
br = branch
me = merge
rs = reset
rb = rebase
df = diff
@mbenford
mbenford / git-update.sh
Last active August 17, 2022 09:53
Bash script to update a local copy of a Git repository with latest changes from a remote branch
#!/bin/bash
set -e
local_branch=$(git rev-parse --symbolic-full-name --abbrev-ref HEAD)
remote_branch=$(git rev-parse --abbrev-ref --symbolic-full-name @{u})
remote=$(git config branch.$local_branch.remote)
echo "Fetching from $remote..."
git fetch $remote
@mbenford
mbenford / forceDatabinding.js
Last active August 29, 2015 14:03
Simple Angular directive to force data to be bound even when it's deemed invalid by some validator
app.directive('forceDatabinding', function() {
return {
require: 'ngModel',
link: function(scope, element, attrs, ngModel) {
ngModel.$parsers.push(function(value) {
return value || ngModel.$viewValue;
});
}
};
});
@mbenford
mbenford / DeployToOctopus.ps1
Created August 10, 2014 19:28
Powershell script for TeamCity that creates and deploys a release on Octopus Deploy based on the current branch
function Is-Default-Branch {
return "%teamcity.build.branch.is_default%" -eq "true"
}
function Build-Arguments {
if (Is-Default-Branch) {
$releaseNumber = "%octopus.master.releaseNumber%"
$deployTo = "%octopus.master.deployTo%"
$packageVersion = "%octopus.master.packageVersion%"
}