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 | |
# This script opens a Wireguard VPN and is closing it after a Hyperbackup task has finished. | |
# It was tested with only one active backup task on a single remote target and Hyperbackup 4.1.1-3758. | |
# | |
# How it works: | |
# * Setup a new scheduled task in the control panel executing this script with correct parameters | |
# * Make sure it runs BEFORE your Hyperbackup tasks are started | |
# * Note: Verify if it's working. Unfortunately Hyperbackup officially doesn't support any hooks, | |
# therefore this is relying on parsing the log file with regex. It can break any time with a |
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
<?php | |
// Fritz!Box update URL: https://example.com/upd.php?key=<pass>&zone=<domain>&ipv4=<ipaddr>&a=[records to update] | |
// Replace [records to update] in the url. | |
// If you want to update multiple records of your zone, just add them comma separated: '&a=sub,sub2,*,@' | |
// Optionally you can update AAAA records by appending '&ipv6=<ip6addr>&aaaa=[records to update]' to the url. | |
// If no AAAA record is defined but ipv6 is used, it will update both ip4 and ip6 defined for A records. | |
// $_SERVER['REMOTE_ADDR'] no longer works as FritzOS 7.50 started using IPv6 | |
$key = $_GET['key'] ?? NULL; | |
$zone = $_GET['zone'] ?? NULL; |
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 System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using UnityEditor; | |
using UnityEditor.SceneManagement; | |
using UnityEngine; | |
public class RemoveMissingScriptComponents | |
{ |
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 UnityEditor; | |
using UnityEditor.SceneManagement; | |
using UnityEngine; | |
public class GameObjectTools | |
{ | |
private const string TempPrefabAssetPath = "Assets/tmp.prefab"; | |
[MenuItem ("GameObject/Really Break Prefab Instance", true)] | |
public static bool ValidateBreakPrefabInstance () |
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; | |
using UnityEngine.UI; | |
public static class ScrollRectExtensions | |
{ | |
public static void SnapTo (this ScrollRect rect, Transform target) | |
{ | |
rect.content.anchoredPosition = rect.transform.InverseTransformPoint (rect.content.position) - rect.transform.InverseTransformPoint (target.position); | |
} | |
} |
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
// The Google Play receipt JSON comes with a payload, which contains a string of nested JSON structure. | |
// In order to deserialize that structure, apply this method to the raw JSON string BEFORE you | |
// deserialize it to an object. | |
public static string FixJSONFormat (string json) | |
{ | |
return json.Replace (@"\\\", "").Replace (@"\""", @"""").Replace (@"""{", @"{").Replace (@"}""", @"}"); | |
} |
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> | |
/// Special JsonConvert resolver that allows you to ignore properties. See http://stackoverflow.com/a/13588192/1037948 | |
/// </summary> | |
public class IgnorableSerializerContractResolver : DefaultContractResolver { | |
protected readonly Dictionary<Type, HashSet<string>> Ignores; | |
public IgnorableSerializerContractResolver() { | |
this.Ignores = new Dictionary<Type, HashSet<string>>(); | |
} |
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
public abstract class Singleton<T> where T : new() | |
{ | |
private static T mInstance; | |
public static T Instance | |
{ | |
get | |
{ | |
if (mInstance == null) | |
{ |
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
//Assume we have 5 items in our list | |
List<Item> myList = new List<Item>(5); | |
//Assume our current active item is at index 2 | |
public Item GetNextItem(Item item) | |
{ | |
int currentIndex = myList.IndexOf(item); | |
int nextItemIndex = (currentIndex + 1) % myList.Count; | |
return myList[nextItemIndex]; | |
} |
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; | |
using System.Collections; | |
public class RecursiveBoundingBox | |
{ | |
//Gets all bounding boxes and returns a new one which encapsulate them all | |
//This is e.g. useful if you want to calculate the actual size of a gameobject | |
//Using "MeshRenderer" means it uses the data from "MeshFilter" applied to "Transform" | |
public static Bounds RecursiveMeshRendererBoundingBox (GameObject go) |
NewerOlder