Skip to content

Instantly share code, notes, and snippets.

@ChuckSavage
ChuckSavage / CScode.xaml.cs
Created March 19, 2022 17:47
play symbol for video files
<UserControl xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:SeaRisen.SFFv2"
xmlns:c="clr-namespace:SeaRisen.SFFv2.Converters"
xmlns:misc="clr-namespace:SeaRisen.SFFv2.Misc"
xmlns:zoom="clr-namespace:ZoomAndPan;assembly=ZoomAndPan"
xmlns:settings="clr-namespace:SeaRisen.SFFv2.Files.Xml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:imaging="clr-namespace:SeaRisenLib2.Imaging;assembly=SeaRisenLib2"
@ChuckSavage
ChuckSavage / NaturalStringComparer.cs
Last active January 27, 2022 19:33
Natural string comparer for files too
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
namespace SeaRisenLib2.Text;
@ChuckSavage
ChuckSavage / pirate_raiders.cs
Created December 6, 2018 10:36
Space Engineers Pirate Raiders Script Modification
// Script written by Rich_27, Designed by Splitsie
// Modified by Dune to check for no antenna, and to echo antenna name & radius
// CHANGE ME: Name of the antenna responsible for spawning drones in the pirate base
const string ANTENNA_NAME = "Antenna name";
// CHANGE ME: The time interval between antenna increments, in seconds
const float TIME_INTERVAL = 120.0f;
// CHANGE ME: The minimum and maximum antenna distances
@ChuckSavage
ChuckSavage / StoneDusterRunIfOverValue.cs
Created November 10, 2018 11:30
Space Engineers - Stone Duster mod, script to control stone amounts
// Written by steam handle "Dune__" aka Chuck Savage
// - Gist link: https://gist.github.com/ChuckSavage/fd5777417b802bf59a07a60688f84a94
// Feel free to use and modify. It'd be great if you list any
// changes here on this gist page so I can keep this up to date if they are important changes.
// Todo: handle multiple stone dusters. I'm not sure how to go about finding the type "Stone Duster" that
// the mod has listed for itself.
// Some code borrowed from the Space Engineers Visual Script Builder - http://dco.pe/vsb/
// Set name of Stone Duster to this name, or change this name to your stone duster's name
@ChuckSavage
ChuckSavage / battery_charge_and_drill_load_level.cs
Created November 3, 2018 08:35
Space Engineers Game - Battery Charge and Drill (miner) load level and balancer
// dco.pe/vsb
const float MinValueToActivateRedLights = 5000f;
const float VolumeOfDrills = 33750f; // small ship drill (large is 234375f)
public Program()
{
Runtime.UpdateFrequency = UpdateFrequency.Update100;
}
@ChuckSavage
ChuckSavage / AppendImageExtension.cs
Created August 29, 2017 18:29
C# Is file an image and get its type
// Includes a mini-program for checking and fixing files that have no extension
// Only checks for the most common types
// If you create a better version, please upload it here.
using System;
using System.Collections.Generic;
using System.IO;
namespace AppendJPG
{
@ChuckSavage
ChuckSavage / DisplaySize.cs
Last active October 29, 2016 06:09
NGUI DisplaySize
/*
* Modified this guys code - http://www.zedia.net/2013/ngui-unity3d-getting-screen-size/comment-page-1/
*/
public static class DisplaySize
{
public static float ScreenHeight(this Transform t)
{
UIRoot root = t.root.GetComponent<UIRoot>() ?? NGUITools.FindInParents<UIRoot>(t);
float ratio = (float)root.activeHeight / Screen.height;
return Mathf.Ceil(Screen.height * ratio);
@ChuckSavage
ChuckSavage / MapMagic_AutoSave
Last active October 14, 2016 09:19
MapMagic v1.5 Setting up Auto-Save of Nodes data. Modify MapMagic at your own risk. There is no guarantee that the node file generated by this is useful. Be sure to test it for your own assurance.
Edit MapMagicWindow.cs
Make the following method static, it doesn't reference internal class data, so it is ok.
private static Generator[] SmartCopyGenerators(Generator gen)
Then refactor the SaveGenerator method, extracting the file saving to a public static ExportToFile method
void SaveGenerator(Generator gen, Vector2 pos)
{
@ChuckSavage
ChuckSavage / ObservableValue
Last active January 21, 2022 02:39
Observe the changes in a value
public class ObservableValue<T> : INotifyPropertyChanged
{
public class MyArgs : PropertyChangedEventArgs
{
public MyArgs(string propertyName, T old, T @new)
: base(propertyName)
{
Old = old;
New = @new;
}
@ChuckSavage
ChuckSavage / ZipMultiple.cs
Last active January 21, 2022 02:40
It seems an oversight on the .Net team to not enable multiple arrays to be passed to Enumerable.Zip. So I've created up to seven overloaded Zip extensions that borrow from the code by Eric Lippert here: http://blogs.msdn.com/b/ericlippert/archive/2009/05/07/zip-me-up.aspx
using System;
using System.Collections.Generic;
namespace ZipMany
{
/// <summary>
/// Zip multiple arrays (more than 2 since there is a built in Zip for 2 with .Net 4.0)
/// </summary>
public static class ZipMultiple
{