Skip to content

Instantly share code, notes, and snippets.

View PatrickKalkman's full-sized avatar
🏠
Working from home

Patrick Kalkman PatrickKalkman

🏠
Working from home
View GitHub Profile
@PatrickKalkman
PatrickKalkman / HLS Ladder.csv
Created November 9, 2022 19:22
HLS bitrate ladder
16:9 aspect ratio Bitrate Frame rate
416 x 234 145 ≤ 30 fps
640 x 360 365 ≤ 30 fps
768 x 432 730 ≤ 30 fps
768 x 432 1100 ≤ 30 fps
960 x 540 2000 Same as source
1280 x 720 3000 Same as source
1280 x 720 4500 Same as source
1920 x 1080 6000 Same as source
1920 x 1080 7800 Same as source
@PatrickKalkman
PatrickKalkman / init-player.js
Created May 14, 2021 18:52
function to initialize shaka-player
private initPlayer() {
this.player = new shaka.Player(this.videoElement);
const ui = new shaka.ui.Overlay(
this.player,
this.videoContainerElement,
this.videoElement
);
this.player
public List<ContentValues> parseMovies(JSONArray videoArray) throws JSONException {
List<ContentValues> videosToInsert = new ArrayList<>();
String title = video.optString(TAG_TITLE);
String description = video.optString(TAG_DESCRIPTION);
String short_description = video.optString(TAG_SHORT_DESCRIPTION);
if (description.isEmpty()) {
description = short_description;
}
public List<ContentValues> parseMedia(JSONArray videoArray) throws JSONException {
List<ContentValues> videosToInsert = new ArrayList<>();
for (int j = 0; j < videoArray.length(); j++) {
JSONObject video = videoArray.getJSONObject(j);
String videoUrl = video.optString(TAG_URL);
String titleId = video.optString(TAG_TITLE_ID);
if (videoUrl.isEmpty()) {
if (!titleId.isEmpty()) {
function Remove-AccessRestrictionsFromAppService([string] $ResourceGroupName, [string] $Name) {
$config = Get-AzWebAppAccessRestrictionConfig -ResourceGroupName $ResourceGroupName -Name $Name
Write-Information "Removing existing access restrictions on $Name"
Foreach ($accessRestriction in $config.MainSiteAccessRestrictions) {
$ruleName = $accessRestriction.RuleName
Write-Debug "Removing rule $ruleName"
Remove-AzWebAppAccessRestrictionRule -ResourceGroupName $ResourceGroupName -WebAppName $Name -Name $accessRestriction.RuleName
}
# Also remove all the access restriction from the staging slots
<#
.SYNOPSIS
Get the ip address from the ip-addresses.json and give these access to all the
app services in the given resource group.
.DESCRIPTION
Get the ip address from the ip-addresses.json and give these access to all the
app services in the given resource group.
.PARAMETER JsonFilename
function Add-AccessRestrictionToAppService([string] $ResourceGroupName, [string] $Name, [string] $IpFilterRuleName, [string] $IpAddress, [string] $Priority)
{
Write-Information "Adding rule $IpFilterRuleName to allow api management service with ip $IpAddress and $Priority access to $Name"
Add-AzWebAppAccessRestrictionRule -ResourceGroupName $ResourceGroupName -WebAppName $Name -Name $IpFilterRuleName -Priority $Priority -Action Allow -IpAddress $IpAddress
Update-AzWebAppAccessRestrictionConfig -Name $appService.Name -ResourceGroupName $ResourceGroupName -ScmSiteUseMainSiteRestrictionConfig
# Also add the access restriction to the staging slots
$allSlots = Get-AzWebAppSlot -ResourceGroupName $ResourceGroupName -Name $Name
Foreach ($slot in $allSlots)
{
:nextAppService Foreach ($appService in $allAppServices)
{
$appServiceName = $appService.Name
Foreach ($appServiceToExclude in $AppServicesToExclude)
{
if($appServiceToExclude.ToLower().Contains($appServiceName.ToLower()))
{
Write-Output "Skipped app service $appServiceName as it is in the exclude list"
continue nextAppService
function Add-AccessRestrictionsToAppServices([string] $ResourceGroupName,
[string] $JsonFilename,
[bool] $RemoveExistingRules,
[string[]] $AppServicesToExclude)
{
Write-Information "Retrieving all app services in $ResourceGroupName"
$allAppServices = Get-AzWebApp -ResourceGroupName $ResourceGroupName
$confirmAppServicesToExclude = Confirm-AppServicesToExclude -AllAppServices $allAppServices -AppServicesToExclude $AppServicesToExclude
if (!$confirmAppServicesToExclude)
@PatrickKalkman
PatrickKalkman / rules.json
Created January 21, 2022 09:25
A file with rules to set as access restrictions on app services
[
{ "rulename": "gateway", "ipaddress": "213.46.145.111", "priority": "200" },
{ "rulename": "vpn", "ipaddress": "210.46.145.111", "priority": "300" },
{ "rulename": "test", "ipaddress": "215.46.145.111", "priority": "400" }
]