Skip to content

Instantly share code, notes, and snippets.

@zionyx
zionyx / Auth-AzNpmFeed.ps1
Created March 10, 2022 16:58
This piece of PowerShell code helps to setup authentication info to Azure Artifact npm feed.
[CmdletBinding()]
param (
[String]$Registry,
[SecureString]$Token
)
$SampleRegistry = 'For example: //pkgs.dev.azure.com/project/npm/registry/'
function Validate-Registry {
param (
@zionyx
zionyx / Jenkinsfile
Created January 17, 2022 13:45
Jenkinsfile gitversion docker image
// https://hub.docker.com/layers/gittools/gitversion/5.8.1-alpine.3.14-6.0-amd64/images/sha256-ca0a8c928333b55e976b8c1f7e33b34a9b0884598adad92be2d2e1234b9b28c2?context=explore
scripts {
def gitversionJson = sh label: 'Running GitVersion.', returnStdout: true, script: 'docker run --rm -v "$(pwd):/repo" gittools/gitversion:5.8.1-alpine.3.14-6.0-amd64 /repo'
try {
def gitversionMap = new groovy.json.JsonSlurperClassic().parseText(gitversionJson)
gitversionMap.each { k, v -> env["${prefix}${k}"] = "${v}" }
} catch (Exception ex) {
echo "GitVersion output: \n${gitversionJson}"
error ex.getMessage()
@zionyx
zionyx / sample-command-test.yaml
Last active October 6, 2021 18:09
Container Structure Test docker test on Windows with Linux containers command: `docker run -v //var/run/docker.sock:/var/run/docker.sock -v "$(pwd):/work" gcr.io/gcp-runtimes/container-structure-test:latest test -i ubuntu:latest -c /work/command-test.yaml`
schemaVersion: "2.0.0"
commandTests:
- name: "git cli"
command: "git"
args: ["--version"]
expectedOutput: ["git version 2.25.1"]
- name: "Check path"
command: "pwd"
# args:
# - -c

yUML Test On GitHub

yUML is a simple tool for embedding UML diagrams in wikis and blogs without needing any UML or diagramming tools.

Here's an idea of how it could be used in your repository readme.markdown or wiki.

View the RAW source to see how images are made.

Example markdown codes below

@zionyx
zionyx / Get-GitHubRepoSize.ps1
Created May 6, 2021 18:42
Get the size of a public github repository before downloading
# https://gist.github.com/dingzeyuli/f07c126b74371adba4b7dbe181cb57d2
# Tested on PowerShell-Core 7.1.3
If ( 'https://github.com/torvalds/linux.git' -match '([^/]+/[^/]+?)(?:\.git)' ) { Invoke-RestMethod "https://api.github.com/repos/$($Matches[1])" | Select-Object -Property size }
# Output: (in bytes)
# size
# ----
# 3262068
@zionyx
zionyx / MyTheme.psm1
Created July 22, 2020 07:36
My oh-my-posh theme
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
@zionyx
zionyx / github.groovy
Created March 17, 2020 11:13
GitHub JobDSL @Casz
private boolean isSandbox() {
def locationConfig = jenkins.model.JenkinsLocationConfiguration.get()
if (System.getenv("ENVIRONMENT") == "sandbox") {
true
} else if (locationConfig != null && locationConfig.getUrl() != null) {
locationConfig.getUrl().contains("staging")
} else {
false
}
}
@zionyx
zionyx / SemVer.groovy
Created March 12, 2020 15:14 — forked from michaellihs/SemVer.groovy
Semantic Versioning class for Groovy
enum PatchLevel {
MAJOR, MINOR, PATCH
}
class SemVer implements Serializable {
private int major, minor, patch
SemVer(String version) {
def versionParts = version.tokenize('.')
@zionyx
zionyx / map2Json.groovy
Created March 1, 2020 21:35 — forked from rdmueller/map2Json.groovy
This Gist demonstrate how to serialize a Map to JSON and YAML with Groovy
//Problem:
//languages like tcl can simply switch between the String representation of a map or list and the
//object itself. In Groovy, this could theoretically work, but it doesn't:
def list1 = [1,2,3]
def list2 = ["1, 2, 3"]
assert list1 != list2
assert list1.toString() == list2.toString()
assert Eval.me(list1.toString()) instanceof List
assert Eval.me(list2.toString()) instanceof List
assert Eval.me(list1.toString()) == Eval.me(list2.toString())
@zionyx
zionyx / GitVersion.yml
Last active April 22, 2020 12:32
GitVersion.yml v2 - DEKA-717
# This property allows you to bump the next version explicitly. Also serves as base version.
# Uncomment to use. For more details: https://confluence.3shape.com/x/L44_C
#next-version:
# DEKA-817: Using standard GitVersion commit message to increment SemVer
# For complete instructions on how to use this, see https://confluence.3shape.com/x/00zfBw
commit-message-incrementing: Enabled
major-version-bump-message: '\+semver:\s?(breaking|major)'
minor-version-bump-message: '\+semver:\s?(feature|minor)'
patch-version-bump-message: '\+semver:\s?(fix|patch)'