Skip to content

Instantly share code, notes, and snippets.

View Rene-Sackers's full-sized avatar

René Sackers Rene-Sackers

View GitHub Profile
@Rene-Sackers
Rene-Sackers / ConsolePasswordInput.cs
Last active June 8, 2023 16:43
.NET 5+ WindowsCredentialVault access
using System.Security;
public static class ConsolePasswordInput
{
public static SecureString? ReadPassword()
{
var securePassword = new SecureString();
while (true)
{
@Rene-Sackers
Rene-Sackers / f1tv-theatre-mode.js
Last active March 18, 2022 15:44
F1TV theatre mode
// ==UserScript==
// @name F1 theatre mode
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Make F1TV videos theatre mode
// @author René Sackers
// @match https://f1tv.formula1.com/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
@Rene-Sackers
Rene-Sackers / Pilicies.cs
Created December 20, 2020 15:20
Strong typed policies
public class Policy
{
public string Name { get; }
public Policy(string name)
{
Name = name;
}
public static implicit operator string(Policy policy) => policy.Name;
@Rene-Sackers
Rene-Sackers / Client.cs
Created October 10, 2020 16:56
FiveM C# events
[EventHandler(Events.Client.onClientResourceStart)]
private void onClientResourceStart(string resourceName)
{
Debug.WriteLine($"{Events.Client.onClientResourceStart}");
}
[EventHandler(Events.Client.onClientResourceStop)]
public void onClientResourceStop(string resourceName)
{
Debug.WriteLine($"{Events.Client.onClientResourceStop}");
@Rene-Sackers
Rene-Sackers / RegistrationBuilderExtensions.cs
Created July 27, 2018 12:41
Autofac NotAssignableTo extension
public static class RegistrationBuilderExtensions
{
public static IRegistrationBuilder<object, ScanningActivatorData, DynamicRegistrationStyle> NotAssignableTo<T>(this IRegistrationBuilder<object, ScanningActivatorData, DynamicRegistrationStyle> registration)
{
return registration.NotAssignableTo(typeof(T));
}
public static IRegistrationBuilder<TLimit, TScanningActivatorData, TRegistrationStyle> NotAssignableTo<TLimit, TScanningActivatorData, TRegistrationStyle>(this IRegistrationBuilder<TLimit, TScanningActivatorData, TRegistrationStyle>
registration, Type type) where TScanningActivatorData : ScanningActivatorData
{
@Rene-Sackers
Rene-Sackers / fbembed.html
Last active July 7, 2018 15:57
Get rid of the stupid shit around a FB livestream.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
html, body {
@Rene-Sackers
Rene-Sackers / AsyncHelper.cs
Last active June 30, 2018 13:55
RAGE MP Useful snippets
public static class AsyncHelper
{
public static Task<T> RunAsync<T>(Func<T> callback)
{
var taskCompletion = new TaskCompletionSource<T>();
NAPI.Task.Run(() =>
{
try
{
[Serializable]
public class TypedHubClientInterceptor : IInterceptor
{
public delegate void MethodCalledHandler(MethodInfo methodInfo, params object[] args);
public void Intercept(IInvocation invocation) =>
MethodCalled?.Invoke(invocation.Method, invocation.Arguments);
public event MethodCalledHandler MethodCalled;
}
@Rene-Sackers
Rene-Sackers / Program.cs
Created December 7, 2017 20:13
Embedded .dlls
public class Program
{
[STAThread]
public static void Main()
{
AppDomain.CurrentDomain.AssemblyResolve += OnResolveAssembly;
App.Main();
}
private static Assembly OnResolveAssembly(object sender, ResolveEventArgs args)
@Rene-Sackers
Rene-Sackers / EventDispatcher.ts
Last active September 28, 2017 14:08
GT-MP Easy clientside events.
class EventDispatcher {
public static eventHandlers: { [key: string]: (args: any[]) => void } = {};
constructor() {
API.onServerEventTrigger.connect(<any>this.onEventTrigger);
}
private onEventTrigger = (eventName: string, args: System.Array<any>) => {
var argsArray: any[] = [];