Skip to content

Instantly share code, notes, and snippets.

View prom3theu5's full-sized avatar
🏡
Working from Home

David Sekula prom3theu5

🏡
Working from Home
  • UK
  • 19:26 (UTC +01:00)
View GitHub Profile
@prom3theu5
prom3theu5 / yt-playlist-import.lua
Last active August 29, 2015 14:13
Youtube Playlist Importer
--[[
Youtube Playlist Importer for VLC
--]]
-- Helper function to get a parameter's value in a URL
function get_url_param( url, name )
local _, _, res = string.find( url, "[&?]"..name.."=([^&]*)" )
return res
end
@prom3theu5
prom3theu5 / MailbirdInstallRegCheck.cs
Created March 13, 2015 14:31
Check 4.5 or Higher in the Registry
using Microsoft.Win32;
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Get45or451FromRegistry();
@prom3theu5
prom3theu5 / windowsize
Created April 22, 2015 15:30
window Size relational to desktop
//XAML
<Window x:Class="App.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tools="clr-namespace:App.Tools"
Height="{Binding Source={x:Static SystemParameters.PrimaryScreenHeight}, Converter={tools:RatioConverter}, ConverterParameter='0.9' }"
Width="{Binding Source={x:Static SystemParameters.PrimaryScreenWidth}, Converter={tools:RatioConverter}, ConverterParameter='0.9' }"
Title="{Binding Path=DisplayName}"
WindowStartupLocation="CenterScreen"
>
@prom3theu5
prom3theu5 / Who needs a map editor?.markdown
Created October 23, 2015 23:16
Who needs a map editor?
@prom3theu5
prom3theu5 / Ecommerce.cs
Created July 26, 2016 15:00
BCD Google Tracking ECOmmerce
public class WidgetsGoogleAnalyticsController : BasePluginController
{
private readonly IWorkContext _workContext;
private readonly IStoreContext _storeContext;
private readonly IStoreService _storeService;
private readonly ISettingService _settingService;
private readonly IOrderService _orderService;
private readonly ILogger _logger;
private readonly ICategoryService _categoryService;
private readonly IProductAttributeParser _productAttributeParser;
{
"version": "0.0.1",
"discord": {
"clientId": "568451050181492736",
"smallImageText": "Score",
"smallImageKey": "seal-circle"
},
"java": {
"oracle": "http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html"
},
@prom3theu5
prom3theu5 / Policy.cs
Created January 26, 2020 23:37
Polly Resiliency for Azure Cognitive Services etc
/// <summary>
/// Creates a Polly-based resiliency strategy that helps deal with transient faults when communicating
/// with the external (downstream) Computer Vision API service.
/// </summary>
/// <returns></returns>
private PolicyWrap<HttpResponseMessage> DefineAndRetrieveResiliencyStrategy()
{
// Retry when these status codes are encountered.
HttpStatusCode[] httpStatusCodesWorthRetrying = {
HttpStatusCode.InternalServerError, // 500
@prom3theu5
prom3theu5 / Policy.cs
Created January 26, 2020 23:58
Polly AuthRefresh
var authorisationEnsuringPolicy = Policy
.HandleResult<HttpResponseMessage>(r => r.StatusCode == HttpStatusCode.Unauthorized)
.RetryAsync(
retryCount: 1, // Consider how many retries. If auth lapses and you have valid credentials, one should be enough; too many tries can cause some auth systems to blacklist.
onRetryAsync: async (outcome, retryNumber, context) => FooRefreshAuthorizationAsync(context),
/* more configuration */);
var response = authorisationEnsuringPolicy.ExecuteAsync(context => DoSomethingThatRequiresAuthorization(context), cancellationToken);
@prom3theu5
prom3theu5 / Policy.cs
Created January 27, 2020 00:09
RetryAfter Read Headers
private TimeSpan getServerWaitDuration(DelegateResult<HttpResponseMessage> response)
{
var retryAfter = response?.Result?.Headers?.RetryAfter;
if (retryAfter == null)
return TimeSpan.Zero;
return retryAfter.Date.HasValue
? retryAfter.Date.Value - DateTime.UtcNow
: retryAfter.Delta.GetValueOrDefault(TimeSpan.Zero);
}
@prom3theu5
prom3theu5 / Docker connect to remote server.md
Created March 1, 2022 21:26 — forked from kekru/Docker connect to remote server.md
Connect to another host with your docker client, without modifying your local Docker installation

Run commands on remote Docker host

This is how to connect to another host with your docker client, without modifying your local Docker installation or when you don't have a local Docker installation.

Enable Docker Remote API

First be sure to enable the Docker Remote API on the remote host.

This can easily be done with a container.
For HTTP connection use jarkt/docker-remote-api.