Skip to content

Instantly share code, notes, and snippets.

View ukcoderj's full-sized avatar

Justin ukcoderj

View GitHub Profile
@ukcoderj
ukcoderj / vsts-clone-build-with-powershell.ps1
Last active September 22, 2017 07:56
VSTS Clone Build With Powershell
Clear-Host
$buildToCloneName = "Build 1"
$newBuildName = "Build 1 - Clone"
$user = "[email protected]"
$accessToken="4df31252fqt...PAT...."
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$accessToken)))
$env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI = "https://mycompany.visualstudio.com/"
$env:SYSTEM_TEAMPROJECTID = "MyProject"
@ukcoderj
ukcoderj / clean-bin-and-obj.ps1
Last active September 18, 2017 10:20
Remove all bin and object folders
Clear-Host
$folderToEmptyBins = "C:\Temp\ATest"
#short way
cd $folderToEmptyBins
get-childitem -Include "bin" -Recurse -force | Remove-Item -Force –Recurse
get-childitem -Include "obj" -Recurse -force | Remove-Item -Force –Recurse
#long way
#function DeleteSubFoldersWithName($folder, $name)
@ukcoderj
ukcoderj / nested-variables.ps1
Created September 13, 2017 14:39
How to create a nested variable in powershell
# How to create a nested variable in powershell
Clear-Host
$NestedObject1 = [pscustomobject]@{Item1="Bob";Item2="Fred";Item3="Joe"}
$ParentObject = [pscustomobject]@{LevelA=[pscustomobject]@{LevelB=@($NestedObject1)}}
#let's check it
$parentObject.LevelA.LevelB[0].Item2
@ukcoderj
ukcoderj / start-a-build-with-name-x-and-wait.ps1
Created September 8, 2017 15:32
Start a TFS/ VSTS Build And Wait For Completion
Add-PSSnapin Microsoft.TeamFoundation.PowerShell
#Add-Type -Path "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.Client.dll"
# *VSTS Load Above* Load the TFS powershell
# NOTE: Must allow build to access tokens in the options
Clear-Host
$buildToStart = "My-Build-Name e.g. Test - CLI"
$newLine = [System.Environment]::NewLine
@ukcoderj
ukcoderj / incrementversionnumber.ps1
Created September 1, 2017 10:31
Powershell Check Out / In Document from VSTS (TFS)
Add-PSSnapin Microsoft.TeamFoundation.PowerShell
# This file requires the TFS Power Tools (2015+). When installing, you must select Custom Installation and select PowerShell Cmdlets
# *VSTS Login*
# YOU MUST go to 'Options' and turn on 'Allow scripts to access OAuth token' for the buld
$url = "$($env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI)$env:SYSTEM_TEAMPROJECTID/_apis/build/definitions/$($env:SYSTEM_DEFINITIONID)?api-version=2.0"
Write-Host "URL: $url"
$definition = Invoke-RestMethod -Uri $url -Headers @{
Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"
}
@ukcoderj
ukcoderj / Main.cs
Created March 24, 2017 16:36
Web API with body content and C# / Html Calls
// Calling client
class Program
{
static void Main(string[] args)
{
string answer = "";
//string baseUrl = "http://localhost:56539/";
string baseUrl = "http://169.254.80.80/winauth/";
@ukcoderj
ukcoderj / calendar.html
Created February 10, 2017 09:52
Very basic starting point for iPhone style calendar using Html/JQuery
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
<link rel="stylesheet" href=""/>
<!-- http://qnimate.com/javascript-scroll-by-dragging/ -->
@ukcoderj
ukcoderj / ip.html
Last active April 30, 2024 16:15
Get client ip address from html page without going to an external website.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>IP Address</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="SitePoint">
<link rel="stylesheet" href="css/styles.css?v=1.0">
<script>
@ukcoderj
ukcoderj / sort.js
Created January 8, 2016 12:04
OrderBy on Array based on Properties, taken from Javscript: The Good Parts, by Douglas Crockford
// This might need tweaking for uppercase/lowercase comparisons
// Source - Javscript: The Good Parts, by Douglas Crockford
var by = function (name, minor) {
// Array sorting
// myArray.sort(by('FirstName', by('LastName')));
return function (o, p) {
var a, b;
if (typeof o === 'object' && typeof p === 'object' && o && p) {
a = o[name];
@ukcoderj
ukcoderj / gist:dbc24179da9e0015ce10
Last active August 29, 2015 14:25
Android SDK: Converting SeekBar to Value (and back) when the seekers start value is greater than zero
/**
* The seekbars min value cannot be changed in the sdk. It has to be zero
* Total = 240seconds represented
* Start Value = 30 seconds
* Each interval of the seekbar = 5 seconds.
* <SeekBar
android:id="@+id/settings_seekbar_time_interval"
android:layout_span="2"
android:minWidth="200dp"
android:max="42"