Skip to content

Instantly share code, notes, and snippets.

View ricardoboss's full-sized avatar
:shipit:
Ship it

Ricardo Boss ricardoboss

:shipit:
Ship it
View GitHub Profile
@ricardoboss
ricardoboss / main.dart
Created November 12, 2023 22:06
double.infinity in Dart
void main() {
double a = 0.5;
print(a.toInt());
double b = double.infinity;
print(b.toInt());
}
@ricardoboss
ricardoboss / bench_hash_hmac_algos.php
Created November 4, 2022 02:16
A benchmark script for hash_hmac_algos()
<?php
$revs = 5;
$loops = 100_000;
$data = "This is some test data.";
$key = "some.s3cr3t\$key";
$scores = [];
foreach (hash_hmac_algos() as $algo) {
$scores[$algo] = 0;
}
<?php
function foo(array ...$as): array
{
assert(count($as) >= 2);
return array_diff_uassoc(array_shift($as), ...$as, fn($a, $b) => $a - $b);
}
// ==UserScript==
// @name Time4 Improvements
// @namespace https://gist.github.com/ricardoboss/2ca62e8117a078cce226de2738c20f6e
// @version 0.1.2
// @updateURL https://gist.githubusercontent.com/ricardoboss/2ca62e8117a078cce226de2738c20f6e/raw/time4-improvements.js
// @description Improvements for time4
// @author Ricardo Boss
// @match https://time4-a17.msoft.de/*
// @icon https://time4-a17.msoft.de/Time4-D/Content/Images/Logo/Logo.svg
// @grant none
@ricardoboss
ricardoboss / github-custom.css
Created April 11, 2022 21:24
GitHub fixed sidepanel pure CSS
.Layout-sidebar {
position: sticky;
top: 8px;
max-height: 100vh;
overflow-y: auto;
}
.Layout-sidebar > .BorderGrid--spacious {
margin: 0;
}
@ricardoboss
ricardoboss / .php-cs-fixer.dist.php
Last active April 7, 2022 19:26
PHP-CS-Fixer Config Elephox
<?php
/*
* This document has been generated with
* https://mlocati.github.io/php-cs-fixer-configurator/#version:3.8.0|configurator
* you can change this configuration by importing this file.
*/
$config = new PhpCsFixer\Config();
return $config
->setFinder(PhpCsFixer\Finder::create()
->exclude('vendor')
@ricardoboss
ricardoboss / README.md
Last active November 21, 2022 10:14
Watch any video in picture-in-picture mode

The link below can be added as a bookmark to your favourite browser. Whenever you are browsing Twitch, YouTube, Netflix, Disney+, Amazon Prime and possibly more (not tested), you can click the bookmark and pop-out the video into it's own, resizable window.

I always did this manually (optionally removing layers above the video to directly right click the video element), but it has become quite cumbersome (especially with twitch). Another thought I had was to write an extension which shows a button, but this bookmark is way simpler.

It works like this:

  1. Find video elements
  2. Filter them by which element is currently playing and has no errors
@ricardoboss
ricardoboss / CollectionExtensions.cs
Last active April 11, 2021 09:28
Generic implementation for syncing an ICollection with an IEnumerable
namespace System.Linq
{
public static class CollectionExtensions
{
public static void Sync<T>(this ICollection<T> source, IEnumerable<T> other, IEqualityComparer<T>? comparer = null)
{
comparer ??= EqualityComparer<T>.Default;
var itemsToAdd = other.Except(source, comparer);
var itemsToRemove = source.Except(other, comparer);
@ricardoboss
ricardoboss / deploy.sh
Created January 16, 2021 04:15
Deploy script for NPM (Vue) websites and git-auto-deploy
#!/usr/bin/env bash
# change to location of script
SCRIPT_PATH="${0%/*}"
if [[ "$0" != "$SCRIPT_PATH" && "$SCRIPT_PATH" != "" ]]; then
cd "$SCRIPT_PATH" || exit
fi
timestamp=$(date +"%Y-%m-%d_%H-%M-%S")
echo "Executing deploy script at $timestamp"
@ricardoboss
ricardoboss / router.php
Created January 26, 2020 01:13
Simple php built-in webserver router script.
<?php
define('PUBLIC_DIR', __DIR__ . DIRECTORY_SEPARATOR . 'public');
$uri = $_SERVER['REQUEST_URI'];
// assume path exists in public directory
$path = PUBLIC_DIR . $uri;
// convert to realpath and substitute '.' and '..'