Skip to content

Instantly share code, notes, and snippets.

View RobThree's full-sized avatar
🤙
Being awesome

Rob Janssen RobThree

🤙
Being awesome
View GitHub Profile
@RobThree
RobThree / index.php
Last active August 2, 2023 12:56
Pihole OISD.nl caching proxy PHP script
<?php
$fileroot = './cache/'; // Where to store files
$ttl = 3600; // Number of seconds to cache a file
$fileext = '.gz'; // File extension
$lists = [ // Known lists
'small' => 'https://small.oisd.nl/',
'big' => 'https://big.oisd.nl/',
'nsfw' => 'https://nsfw.oisd.nl/'
];
@RobThree
RobThree / program.cs
Last active June 14, 2023 23:47
Calculate number of subnets of a given size you can 'create' or 'take' or 'extract' from a given network.
using System;
public class Program
{
public static void Main()
{
// Example: How many /30's can we fit in a /28?
var sourcePrefixLength = 28;
var destinationPrefixLength = 30;
@RobThree
RobThree / Program.cs
Last active October 14, 2022 08:33
Random animated string (see https://www.reddit.com/r/programming/y13q8x )
// Use chars from input value with custom iterations
WriteAnimatedString("Hello world", 50);
Console.WriteLine();
// Use printable ASCII chars with left-to-right effect
var chars = Enumerable.Range(32, 127).Select(c => (char)c);
WriteAnimatedString("I learned something new today!", animationStyle: AnimationStyle.LeftToRight, chars: chars);
Console.WriteLine();
static void WriteAnimatedString(
@RobThree
RobThree / query.sql
Created June 29, 2022 11:18
List MySQL foreign keys including delete / update rules (RESTRICT, CASCADE, SET NULL, NO ACTION or SET DEFAULT)
SELECT `r`.`table_name`, `r`.`referenced_table_name`, `r`.`constraint_name`, GROUP_CONCAT(`k`.`column_name` SEPARATOR ', ') AS `key_columns`, `r`.`delete_rule`, `r`.`update_rule`
FROM `information_schema`.`referential_constraints` `r`
INNER JOIN `information_schema`.`key_column_usage` `k` on `r`.`constraint_catalog` = `k`.`constraint_catalog` and `r`.`constraint_schema` = `k`.`constraint_schema` and `r`.`constraint_name` = `k`.`constraint_name`
WHERE `r`.`constraint_schema` = '<database_name>'
GROUP BY `r`.`constraint_catalog`, `r`.`constraint_schema`, `r`.`constraint_name`
ORDER BY `r`.`table_name`, `r`.`constraint_name`
@RobThree
RobThree / DecimalValue.cs
Last active October 16, 2019 23:17
Provide c# decimal datatype for gRPC (based on https://visualrecode.com/blog/csharp-decimals-in-grpc/)
using System.Linq;
namespace YOUR_NAMESPACE_HERE
{
public partial class DecimalValue
{
public DecimalValue(int[] bits) => Bits.AddRange(bits);
public static implicit operator decimal(DecimalValue decimalValue) => decimalValue.ToDecimal();
@RobThree
RobThree / gist:6a0ed026a4b9bbd2f488fdf7e7841c3e
Created February 21, 2019 08:33
Blockstack verification
Verifying my Blockstack ID is secured with the address 1LF6MBuM2XTJxAoqCWBHo59ZqQ5EXUaBKs https://explorer.blockstack.org/address/1LF6MBuM2XTJxAoqCWBHo59ZqQ5EXUaBKs
@RobThree
RobThree / custom.css
Last active May 29, 2019 10:23
Maak je Tweakers.net frontpage weer bruikbaar
/* Automatisch spoilers tonen bij hover */
div.spoiler:hover {
color: white !important;
}
/* Quotes donkerder dan posts */
.message-quote-div {
background-color: #dddede !important;
border: 1px solid #c8c8c8 !important;
color: #000 !important;
@RobThree
RobThree / DocumentOperationRoleRequirementsFilter.cs
Created September 21, 2018 16:36
Swashbuckle.AspNetCore DocumentOperationRoleRequirementsFilter
using Microsoft.AspNetCore.Authorization;
using Swashbuckle.AspNetCore.Swagger;
using Swashbuckle.AspNetCore.SwaggerGen;
using System.Linq;
using System.Reflection;
using System.Web;
namespace MyNameSpace {
public class DocumentOperationRoleRequirementsFilter : IOperationFilter
{
@RobThree
RobThree / gameconsole.cs
Created October 17, 2017 08:42
OneLoneCoder GameConsole inspired C# version; work in progress and not a 1:1 conversion. API differs, tried to stay more close to dotnet best practices.
using Microsoft.Win32.SafeHandles;
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
namespace ConsoleEngine
{