Skip to content

Instantly share code, notes, and snippets.

View mjul's full-sized avatar

Martin Jul mjul

View GitHub Profile
@mjul
mjul / .i18n
Created January 4, 2018 10:36
Set SSH Mac to Linux locale
export LC_ALL=da_DK.utf8
@mjul
mjul / build.xml
Created January 4, 2018 13:51
Ant macros for parametrized builds
<!-- use Ant macrodef for to simplify building similar WAR files for test and production -->
<macrodef name="build-war">
<attribute name="wartype" />
<sequential>
<mkdir dir="${dist}/@{wartype}"/>
<war warfile="${dist}/@{wartype}/${ant.project.name}.war" webxml="etc/web-@{wartype}.xml">
<classes dir="${path-to-classes}"/>
<mappedresources>
@mjul
mjul / SeleniumScreenshot.js
Last active January 10, 2018 08:23
Take screenshot with Selenium JavaScript driver
var webdriver = require('selenium-webdriver'),
By = webdriver.By,
until = webdriver.until,
logging = webdriver.logging;
const fs = require('fs');
const path = require('path');
// Take a screenshot.
// state contains the Selenium driver instance and the config with the default path.
@mjul
mjul / JustLogin.js
Created January 10, 2018 08:22
Selenium Javascript web-driver API with promises
var webdriver = require('selenium-webdriver'),
By = webdriver.By,
until = webdriver.until,
logging = webdriver.logging;
// Selenium's promise module provides logging to report every instance of unsynchronized code running through the promise manager
logging.installConsoleHandler();
logging.getLogger('promise.ControlFlow').setLevel(logging.Level.ALL);
@mjul
mjul / docker-compose.yml
Created April 4, 2018 11:05
Elastic Search, Logstash and Kibana via docker-compose for parsing key=value style log files
version: '2'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.2.2
volumes:
- esdata:/usr/share/elasticsearch/data
ports:
- "9200:9200"
@mjul
mjul / azure-list-app-settings.ps1
Created July 13, 2018 11:50
Azure: list application settings from PowerShell
$apiVersion = "2018-02-01"
$resourceGroup = "sandbox-martinj"
$rname = "sandbox-GraphQLApi";
Invoke-AzureRmResourceAction `
-ApiVersion $apiVersion `
-ResourceGroupName $resourceGroup `
-ResourceType "Microsoft.Web/sites/config/appsettings" `
-ResourceName $rname `
-Action list `
@mjul
mjul / install-azure-functions-templates.ps1
Created August 14, 2018 14:21
Install the latest release of the Azure Functions item and project templates for dotnet new
# Install the latest release of the Azure item and project templates:
#
# See [Azure Functions Templates wiki](https://github.com/Azure/azure-functions-templates/wiki/Using-the-templates-directly-via-dotnet-new)
# See [Issue 721](https://github.com/Azure/azure-functions-templates/issues/721)
$feed = Invoke-WebRequest https://functionscdn.azureedge.net/public/cli-feed-v3.json | ConvertFrom-Json
$release = $feed.tags.v2.release
foreach ($t in "itemTemplates", "projectTemplates") {
$uri = $feed.releases."$release"."$t"
@mjul
mjul / build.fsx
Created September 27, 2018 07:54
Fake (V5) build with xUnit 2 and inline Paket
#r "paket:
nuget Fake.DotNet.Cli
nuget Fake.IO.FileSystem
nuget Fake.Core.Target
nuget Fake.DotNet.MSBuild
nuget Fake.DotNet.NuGet
nuget Fake.DotNet.Testing.XUnit2 //"
#load ".fake/build.fsx/intellisense.fsx"
open System.IO
@mjul
mjul / git-status-colours.ps1
Created October 1, 2018 07:23
Git status colour config for PowerShell readability
# `git status` in PowerShell shows untracked files is a dark red that is hard to read on the blue background.
# Change it to high-contrast red:
git config --global color.status.untracked "bold red"
@mjul
mjul / azure-devops-vsts-get-defaulthostname.ps1
Created October 22, 2018 12:41
Azure DevOps (VSTS) Get Azure WebApp DefaultHostName workaround
# Get-AzureRmWebApp does not work correctly when running under the Azure DevOps build server (October 2018).
# Here is a workaround to get the DefaultHostName
# Place your own name here:
$appName = "myspecialappname-dev"
$webApp = Get-AzureRmWebApp -ResourceGroupName $ResourceGroupName -Name $appName -ErrorAction Stop
if (!$webApp) { Write-Error ("WebApp not found: {0} (Resource Group: {1})" -f $appName,$ResourceGroupName) }
# DefaultHostName property does not work in the Azure DevOps (VSTS) build server, see: https://github.com/Azure/azure-powershell/issues/5760
# The HostNames property works, so pick one of the hostnames instead of DefaultHostName: