Skip to content

Instantly share code, notes, and snippets.

ForeverZer0 / EndianSwapExtensions.cs
Created Aug 24, 2021
Swap endian of numeric types using grouped bit-shifts instead of the much slower Array.Reverse.
View EndianSwapExtensions.cs
using System;
using System.Runtime.CompilerServices;
using JetBrains.Annotations;
namespace ChangeThisNamespace
/// <summary>
/// Contains extension methods dealing with endianness of numeric types.
/// </summary>
ForeverZer0 / Adler32.cs
Created Aug 24, 2021
C# ZLib stream implementation
View Adler32.cs
using System;
using System.Runtime.CompilerServices;
namespace ZLib
/// <summary>
/// An Adler-32 checksum implementation for ZLib streams.
/// </summary>
/// <seealso href=""/>
public sealed class Adler32
ForeverZer0 / Guttman.txt
Last active Apr 22, 2021
Andrew Gutmann's Letter to Brearley
View Guttman.txt
April 13, 2021
Dear Fellow Brearley Parents,
Our family recently made the decision not to reenroll our daughter at Brearley for the 2021-22 school year. She has been at Brearley for seven years, beginning in kindergarten. In short, we no longer believe that Brearley's administration and Board of Trustees have any of our children's best interests at heart. Moreover, we no longer have confidence that our daughter will receive the quality of education necessary to further her development into a critically thinking, responsible, enlightened, and civic minded adult. I write to you, as a fellow parent, to share our reasons for leaving the Brearley community but also to urge you to act before the damage to the school, to its community, and to your own child's education is irreparable.
It cannot be stated strongly enough that Brearley's obsession with race must stop. It should be abundantly clear to any thinking parent that Brearley has completely lost its way. The administration and the Board of Trustees have dis
ForeverZer0 / url_match.c
Created Feb 8, 2021
Validate URL in C (POSIX)
View url_match.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <regex.h>
printf("Enter the website URL:\n");
fgets(str, 100, stdin);
if (!strcmp(str, "\n")) {
ForeverZer0 / snake_case.rb
Created Nov 29, 2020
Convert from camelCase/PascalCase to snake_case in Ruby
View snake_case.rb
def snake_case
return downcase if match(/\A[A-Z]+\z/)
gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
gsub(/([a-z])([A-Z])/, '\1_\2').
"FooBar".snake_case #=> "foo_bar"
"HeadlineCNNNews".snake_case #=> "headline_cnn_fake_news"
"CNN".snake_case #=> "cnn"
ForeverZer0 / ip2country.rb
Last active Aug 31, 2020
Ruby method to quickly get the country and country codes from a given IPv4 or IPv6 address using only standard library
View ip2country.rb
#!/usr/bin/env ruby
require 'json'
require 'net/http'
# Gets a hash containing the country of origin with a given IPv4 or IPv6 address.
# @param ip [String,#to_s] An IPv4 or IPv6 address, or an object that returns one with #to_s
ForeverZer0 / imgur_upload.rb
Last active Aug 29, 2020
Upload a file to Imgur with Ruby, using no external dependencies, only standard library.
View imgur_upload.rb
#!/usr/bin/env ruby
require 'base64'
require 'json'
require 'net/http'
# The Imgur client ID. Create your own at
CLIENT_ID = '3662c57963d1bdf'
ForeverZer0 / Giuffre v. Maxwell - Links to the documents released on 07-30-2020 (which were under seal)
Created Jul 31, 2020
Giuffre v. Maxwell - Links to the documents released on 07-30-2020 (which were under seal)
View Giuffre v. Maxwell - Links to the documents released on 07-30-2020 (which were under seal)
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 / 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