Skip to content

Instantly share code, notes, and snippets.

View lankaapura's full-sized avatar
👨‍💻
_

Priyantha Lankapura lankaapura

👨‍💻
_
View GitHub Profile
[cmdletbinding()]
param(
[string]$Channel="LTS",
[string]$Version="Latest",
[string]$JSonFile,
[string]$InstallDir="<auto>",
[string]$Architecture="<auto>",
[ValidateSet("dotnet", "aspnetcore", "windowsdesktop", IgnoreCase = $false)]
[string]$Runtime,
[Obsolete("This parameter may be removed in a future version of this script. The recommended alternative is '-Runtime dotnet'.")]
@lankaapura
lankaapura / package-json-build-number.ps1
Created May 3, 2019 07:28 — forked from ediblecode/package-json-build-number.ps1
Powershell script to parse a package.json version and use as the build number in TeamCity
$version = (Get-Content package.json) -join "`n" | ConvertFrom-Json | Select -ExpandProperty "version"
$buildCounter = "%build.counter%"
$buildNumber = "$version.$buildCounter"
Write-Host "##teamcity[buildNumber '$buildNumber']"
@lankaapura
lankaapura / download_github_release.ps1
Created May 11, 2018 09:15
Download github release artifacts
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Add-Type -AssemblyName System.IO.Compression.FileSystem
$token = Read-Host -Prompt 'Github PAT'
if(!$token) {$token = ""}
$org = Read-Host -Prompt 'Org or User'
if(!$org) {$org = ""}
$repo = Read-Host -Prompt 'Repo'
@lankaapura
lankaapura / Replace-InvalidFileNameChars.ps1
Last active March 7, 2018 07:43
This will replace invalid characters in filename with a placeholder string. This will help to generate unique filenames.
# based on https://stackoverflow.com/a/15121461
Function Replace-InvalidFileNameChars {
param(
[Parameter(Mandatory=$true,
Position=0,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true)]
[String]$Name
)
@lankaapura
lankaapura / SemverSort.ps1
Created February 12, 2018 09:33 — forked from jageall/SemverSort.ps1
Sorts semver in powershell
#powershell script port of https://github.com/maxhauser/semver/
function toSemVer($version){
$version -match "^(?<major>\d+)(\.(?<minor>\d+))?(\.(?<patch>\d+))?(\-(?<pre>[0-9A-Za-z\-\.]+))?(\+(?<build>[0-9A-Za-z\-\.]+))?$" | Out-Null
$major = [int]$matches['major']
$minor = [int]$matches['minor']
$patch = [int]$matches['patch']
if($matches['pre'] -eq $null){$pre = @()}
else{$pre = $matches['pre'].Split(".")}
<!-- 1. Define some markup -->
<div id="btn" data-clipboard-text="1">
<span>Copy</span>
</div>
<!-- 2. Include library -->
<script src="clipboard.min.js"></script>
<!-- 3. Instantiate clipboard by passing a HTML element -->
<script>
function CopyToClipBoardHandler(value) {
const copyListener = event => {
document.removeEventListener('copy', copyListener, true);
event.preventDefault();
const clipboardData = event.clipboardData;
clipboardData.clearData();
clipboardData.setData('text/plain', value);
};
document.addEventListener('copy', copyListener, true);
document.execCommand('copy');
@lankaapura
lankaapura / c
Last active December 10, 2017 02:59
export const authConfig: AuthConfig = {
// Url of the Identity Provider
issuer: "https://demo.identityserver.io",
requireHttps: true,
// URL of the SPA to redirect the user to after login
redirectUri: "http://localhost:2020/",
// URL of the SPA to redirect the user after silent refresh
silentRefreshRedirectUri: "http://localhost:2020/silent-refresh.html",
@lankaapura
lankaapura / guard.ts
Created September 28, 2017 12:13
Typescript guard
export function guard() {
return function (target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>) {
const originalMethod = descriptor.value;
descriptor.value = function (...args: any[]) {
return false ? originalMethod.apply(this, args) : console.log('not authorized.');
};
return descriptor;
};
@lankaapura
lankaapura / TSQL-to-POCO
Created March 6, 2017 07:46 — forked from joey-qc/TSQL-to-POCO
A simple TSQL script to quickly generate c# POCO classes from SQL Server tables and views. You may tweak the output as needed. Not all datatypes are represented but this should save a bunch of boilerplate coding. USAGE: Run this query against the database of your choice. The script will loop through tables, views and their respective columns. Re…
declare @tableName varchar(200)
declare @columnName varchar(200)
declare @nullable varchar(50)
declare @datatype varchar(50)
declare @maxlen int
declare @sType varchar(50)
declare @sProperty varchar(200)
DECLARE table_cursor CURSOR FOR