Skip to content

Instantly share code, notes, and snippets.

View whizvox's full-sized avatar

Corneilious Eanes whizvox

View GitHub Profile
@whizvox
whizvox / UTF8.java
Last active June 26, 2023 20:04
UTF-8 Encoding with Java
import java.nio.ByteBuffer;
public class UTF8 {
public static void encodeUTF8(char c, ByteBuffer buf) {
if (c <= 0x7F) {
buf.put((byte) c);
} else if (c <= 0x7FF) {
buf.put((byte) (0b11000000 | (c >> 6)));
buf.put((byte) (0b10000000 | (c & 0b111111)));
@whizvox
whizvox / detabtwt.js
Last active March 25, 2023 13:26
De-tab Twitter
// ==UserScript==
// @name De-tab Twitter
// @namespace https://whizvox.me
// @version 1.1.1
// @downloadURL https://gist.githubusercontent.com/whizvox/2c5eb769c29576bdf4173ac2ee58445a/raw/38eba91a8c3da6da262de56bcd6ce712e153af04/detabtwt.js
// @description Removes "For You" and "Following" tabs, as well as selecting "Following" upon page load
// @author whizvox
// @match https://twitter.com/home
// @icon https://www.google.com/s2/favicons?sz=64&domain=twitter.com
// @grant none
@whizvox
whizvox / DynamicArray.cpp
Created April 4, 2019 17:55
A dynamic array data structure written in C++
#include "DynamicArray.hpp"
#include <cstring>
void copyArray(int* dst, const int* src, int n) {
for (int i = 0; i < n; i++) {
dst[i] = src[i];
}
}
DynamicArray::DynamicArray(int capacity) {
@whizvox
whizvox / quicksort.h
Created October 6, 2017 01:56
A memory-efficient implementation of the quicksort sorting algorithm in C++.
#pragma once
template<class T>
int partition(T*, const int, const int);
template<class T>
void quicksort(T*, int, int);
template<class T>
void quicksort(T*, const int);
@whizvox
whizvox / UTF8Encoding.java
Created August 14, 2016 08:59
How to encode and decode UTF8 strings using Java NIO
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
/**
* Do you want to know how to encode and decode in UTF8 format without relying on another library? Well, here ya go.
* Reference Guide: http://www.fileformat.info/info/unicode/utf8.htm
*/
public class UTF8Encoding {
public static void main(String[] args) {
@whizvox
whizvox / ModernRendering2.java
Created June 20, 2016 04:45
How to use modern OpenGL rendering using LWJGL and JOML
import org.joml.Matrix4f;
import org.lwjgl.BufferUtils;
import org.lwjgl.glfw.GLFWErrorCallback;
import org.lwjgl.glfw.GLFWKeyCallback;
import org.lwjgl.glfw.GLFWVidMode;
import org.lwjgl.glfw.GLFWWindowSizeCallback;
import org.lwjgl.opengl.GL;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
@whizvox
whizvox / ModernRendering.java
Created March 16, 2016 20:14
Working example of rendering a texture with LWJGL and modern OpenGL
import org.lwjgl.BufferUtils;
import org.lwjgl.glfw.GLFWErrorCallback;
import org.lwjgl.glfw.GLFWKeyCallback;
import org.lwjgl.glfw.GLFWVidMode;
import org.lwjgl.glfw.GLFWWindowSizeCallback;
import org.lwjgl.opengl.GL;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
@whizvox
whizvox / Main.java
Created February 19, 2016 20:30
How to render a texture with LWJGL using VBOs
import org.lwjgl.BufferUtils;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.glfw.GLFWErrorCallback;
import org.lwjgl.glfw.GLFWKeyCallback;
import org.lwjgl.opengl.GL;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL15;
import org.lwjgl.stb.STBImage;
import java.nio.ByteBuffer;
@whizvox
whizvox / Downloader.java
Last active October 29, 2015 20:14
A simple Java-written Swing-powered GUI to download files. (Not optimized yet)
import javax.swing.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Observable;
public class Downloader extends Observable implements Runnable {