This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shader_type canvas_item; | |
uniform float cells = 8.0; // how many cells in checkerboard pattern | |
uniform float angle: hint_range(0, 1.57079632679) = 0.0; // repeats every PI / 2 | |
void vertex() { // rotate UVs by angle | |
UV *= mat2(vec2(cos(angle), -sin(angle)), vec2(sin(angle), cos(angle))); | |
} | |
void fragment() { // assign color by even/odd checkerboard pattern |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends Node # for ease of testing attach to a node | |
func swap_elements(x: Array, a: int, b: int): | |
var temp = x[a] | |
x[a] = x[b] | |
x[b] = temp | |
# https://en.wikipedia.org/wiki/Heap%27s_algorithm | |
func heap_permutations(x: Array) -> Array: | |
x = x.duplicate() # copy we original array isn't affected by swaps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[System.Diagnostics.DebuggerHidden] | |
[System.Diagnostics.Conditional("DEBUG")] | |
public static void DebuggerBreakIf(bool condition) | |
{ | |
if (condition) | |
{ | |
System.Diagnostics.Debugger.Break(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# pipe_stdin_to_discord_webhook.sh | |
# This script triggers discord webhook with input from stdin line-by-line | |
set -eu | |
# discord webhook url, pay attention to add ?wait=true at the end | |
WEBHOOK_URL='https://discordapp.com/api/webhooks/[WEBHOOKID]/[WEBHOOKID]?wait=true' | |
# grep filter per line, lines not matching won't be sent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Pgloader script to convert a phpbb mysql database to postgres. | |
* Get a fresh postgres database and make a basic phpbb install to create schema. | |
* Phpbb wants to keep mysql-ism of boolean columns being int types. | |
* Probably worth tidying up stuff like FTS indices, **_track tables before. | |
* Assuming this script is called phpbb_mysql_to_postgres.load, database and | |
* schema names are "phpbb", run: | |
* | |
* docker run --network=with_access_to_both_containers \ | |
* --rm \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Cloudflare API credentials used by Certbot | |
# Should be sitting at /srv/certbot/cf.ini | |
dns_cloudflare_email = your cloudflare email goes here | |
dns_cloudflare_api_key = your cloudflare key goes here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
phpbb user pruning tool fails to actually work at > 100 users to prune | |
even though it happily displays a form with about 30000 checkboxes and | |
usernames to choose. | |
Slightly modified - this script wants user_ids_to_delete.txt near it, | |
with numerical user ids, one id per line. | |
Bulk delete all users with 0 posts in prevoius revision | |
This needs a *lot* of memory (or swapfile) if you have a lot of users |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
#if UNITY_EDITOR | |
using UnityEditor; | |
[CustomPropertyDrawer(typeof(HelpBoxAttribute))] | |
public class HelpBoxDrawer : DecoratorDrawer | |
{ | |
public override float GetHeight() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary>Enable TLS1.2 for .NET 4.0 app if .NET 4.5 is installed.</summary> | |
/// <seealso cref="http://stackoverflow.com/questions/28286086/default-securityprotocol-in-net-4-5"/> | |
/// <returns>True if .NET 4.0 is installed and we enabled the protocol on SevicePointManager.</returns> | |
public static bool TryEnableTls12() | |
{ | |
// detect .NET 4.5 or greater https://msdn.microsoft.com/en-us/library/hh925568 | |
using (var rk = Microsoft.Win32.RegistryKey | |
.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry32) | |
.OpenSubKey("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full\\")) | |
{ |