Skip to content

Instantly share code, notes, and snippets.

@ForeverZer0
ForeverZer0 / ColorExtensions.cs
Created September 1, 2018 00:48
Provides conversion to/from System.Drawing.Color and System.ConsoleColor.
using System;
using System.Drawing;
namespace MyNamespace
{
public static class Extensions
{
public static Color ToColor(this ConsoleColor color)
{
switch (color)
@ForeverZer0
ForeverZer0 / ConsoleHelper.cs
Created September 3, 2018 02:25
Simple helper methods for spawning/closing an attached console to a Windows application.
using System;
using System.Runtime.InteropServices;
namespace MyNamespace
{
public static class ConsoleHelper
{
private const int SW_SHOW = 5;
public static void Show()
@ForeverZer0
ForeverZer0 / AbstractControlDescriptionProvider.cs
Created September 6, 2018 03:17
Provider to allow an abstract Form or Control to be displayed in the Visual Studio designer.
using System;
using System.ComponentModel;
using System.Windows.Forms;
namespace MyNamespace
{
/// <summary>
/// Provider to allow an abstract <see cref="Form"/> or <see cref="Control"/> to be displayed in the Visual Studio designer.
/// </summary>
/// <typeparam name="TAbstract">The type of the abstract.</typeparam>
@ForeverZer0
ForeverZer0 / case_conversion.rb
Created September 18, 2018 22:16
snake_case, camelCase, and PascalCase extension methods for Ruby's String class.
class String
def snake_case
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
.gsub(/([a-z\d])([A-Z])/,'\1_\2')
.tr("-", "_")
.downcase
end
def camel_case
@ForeverZer0
ForeverZer0 / extconfig.rb
Created October 3, 2018 18:42
Automatically include/compile all Ruby C extension source files (including subdirectories) using mkmf
require "mkmf"
ext_name = 'my_extension'
excluded = ['x86', 'x64']
dir_config(ext_name)
$srcs = Dir.glob("#{$srcdir}/**/*.c").map { |path| File.basename(path) }
Dir.glob("#{$srcdir}/*/") do |path|
dir = File.basename(path)
@ForeverZer0
ForeverZer0 / hosts
Last active December 16, 2019 12:15
Block Spotify Ads
############## SPOTIFY ###################
127.0.0.1 media-match.com
127.0.0.1 adclick.g.doublecklick.net
127.0.0.1 www.googleadservices.com
127.0.0.1 pagead2.googlesyndication.com
127.0.0.1 googleads.g.doubleclick.net
127.0.0.1 pubads.g.doubleclick.net
127.0.0.1 securepubads.g.doubleclick.net
127.0.0.1 www.omaze.com
127.0.0.1 omaze.com
@ForeverZer0
ForeverZer0 / libogg.cs
Created January 25, 2020 20:48
Minimal bindings of the libogg reference library.
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Security;
// Referernce Source: https://xiph.org/vorbis/doc/libvorbis/reference.html
namespace OGG
{
[SuppressUnmanagedCodeSecurity]
@ForeverZer0
ForeverZer0 / libsndfile.cs
Created January 25, 2020 20:54
Minimal bindings for the libsndfile library.
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
namespace SndFile
{
[SuppressUnmanagedCodeSecurity]
@ForeverZer0
ForeverZer0 / OpenAL.cs
Last active January 26, 2020 17:43
Minimal bindings for OpenAL
using System;
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Security;
namespace MyNamespace
{
[SuppressUnmanagedCodeSecurity]
[SuppressMessage("ReSharper", "IdentifierTypo")]
@ForeverZer0
ForeverZer0 / hex2char.sh
Created January 30, 2020 06:19
Convert a binary file into a string that can be stored in a C file as an embedded resource.
#!/usr/bin/bash
hexdump -v -e '16/1 "_x%02X" "\n"' $1 | sed 's/_/\\/g; s/\\x //g; s/.*/ "&"/'