Skip to content

Instantly share code, notes, and snippets.

Eric Freed ForeverZer0

Block or report user

Report or block ForeverZer0

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ForeverZer0
ForeverZer0 / GL.Delegates.cs
Created May 10, 2020
Generated C# bindings for OpenGL 3.3 (Core Profile)
View GL.Delegates.cs
using System;
using System.Runtime.InteropServices;
using System.Security;
// ReSharper disable InconsistentNaming
// ReSharper disable IdentifierTypo
namespace OpenGL
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
@ForeverZer0
ForeverZer0 / MeshLoader.cs
Created May 4, 2020
Simplified loader for creating a mesh from Wavefront OBJ (*.obj) format.
View MeshLoader.cs
/*
* MIT License
*
* Copyright (c) 2020 Eric Freed
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@ForeverZer0
ForeverZer0 / SphereMesh.cs
Last active May 3, 2020
Various mesh generation techniques for spheres.
View SphereMesh.cs
/*
* MIT License
*
* Copyright (c) 2020 Eric Freed
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@ForeverZer0
ForeverZer0 / RectPacker.cs
Created Apr 4, 2020
High-efficiency bin-packer implementation for 2D rectangles.
View RectPacker.cs
using System.Drawing;
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
namespace MyNamespace
{
/// <summary>
/// Represents a rectangular box shape.
/// </summary>
View jetbrains-reset.rb
#!/usr/bin/env ruby
require 'tty-prompt'
require 'fileutils'
@prompt = TTY::Prompt.new
def find_product(name)
paths = []
Dir.entries(Dir.home).each do |entry|
@ForeverZer0
ForeverZer0 / hue-shift.frag
Created Mar 1, 2020
Simple and efficient hue-shift function for a GLSL fragment shader.
View hue-shift.frag
/**
* @brief Applies a hue-shift in a GLSL fragment shader.
*
* @param color The color of the fragment to shift.
* @param hue The amount of hue-shift to apply, in radians. Use GLSL radians function to convert from degrees if needed.
*
* @return The hue-shifted fragment color.
*/
vec3 hueShift(vec3 color, float hue) {
const vec3 k = vec3(0.57735, 0.57735, 0.57735);
@ForeverZer0
ForeverZer0 / main.c
Created Feb 25, 2020
Prime number generator
View main.c
#include <stdio.h>
#include <getopt.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
static struct option prime_opts[] =
{
{"count", required_argument, NULL, 'c'},
@ForeverZer0
ForeverZer0 / exportsym.rb
Created Feb 17, 2020
Export formatted list of symbols defined in a C/C++ library
View exportsym.rb
#!/usr/bin/env ruby
#==============================================================================
#
# Searches for a library either local or on the system and prints out a sorted
# list of all exported symbols found within it. (UNIX-like systems only)
#
# Useful for creating a wrapper/bindings for a C/C++ library.
#
# Example: exportsym tar
@ForeverZer0
ForeverZer0 / ConvertFileToResource.md
Created Feb 17, 2020
Converts any file to C char array to embed as resource.
View ConvertFileToResource.md

Convert any file to formatted string of hex characters

#!/usr/bin/bash
hexdump -v -e '16/1 "_x%02X" "\n"' $1 | sed 's/_/\\/g; s/\\x  //g; s/.*/    "&"/'

The output can then be copied and assigned to a const char * in a header/source file and referenced as a normal string.

@ForeverZer0
ForeverZer0 / RemoveGitSubModule.md
Last active Feb 18, 2020
Completely remove/delete git submodule from project
View RemoveGitSubModule.md

Completely Remove Git Sub-Module

Two different methods to automate the process of removing a submodule from a git repo with a single command. Adapted from here.

NOTE: A commit is made during removal, so it is best to commit any other changes prior to executing the command.

Using as a script in your PATH (filename will be name of command)

  • Create a new file anywhere in your shell's search paths (i.e. ~/.local/bin)
  • Copy the following
You can’t perform that action at this time.