Skip to content

Instantly share code, notes, and snippets.

View emctague's full-sized avatar
🖥️
Probably Coding

Ethan McTague emctague

🖥️
Probably Coding
View GitHub Profile
@emctague
emctague / base64.js
Created July 23, 2017 23:54
base64 encode/decode for node and browser
// Simple Base64 encode/decode that works in node and the browser.
var base64 = {
encode: function (text) {
if (typeof btoa === 'function')
return btoa(text)
else
return new Buffer(text).toString('base64')
},
decode: function (text) {
if (typeof atob === 'function')
@emctague
emctague / brightness.c
Last active July 25, 2020 04:57
brightness.c (like xbacklight, except it actually works for me)
/* brightness.c - Because xbacklight doesn't work for me.
* Features: Cubic ease-in-out interpolation of brightness over time.
*
* Currently works with a single target device from /sys/class/backlight.
* Previously only worked on intel_backlight, has since been adapted to search
* for the proper controller.
*
* Ethan McTague <ethan@tague.me> - January 28, 2018
* Public domain - free to use/modify without any restrictions.
*
@emctague
emctague / init.sh
Created February 10, 2018 05:44
Lazy Init System (to get a quick User-Mode Linux shell)
#!/bin/sh
# The Lazy Init System for Lazy People
# ------------------------------------
# by: Ethan McTague <ethan@tague.me>
# Copyright 2018 Ethan McTague
# ------------------------------------
#
# This is an init system that sets up
# critical things, opens a login
@emctague
emctague / example.c
Created May 8, 2019 16:06
memo [C Memory Management]
#include "memo.h"
#include <stdlib.h>
int main (int argc, char** argv)
{
// We initialize our memo set
memo_set* set = memo_set_new ();
// We make a thing and add it to the memo set
void* someData = malloc(20);
@emctague
emctague / FindGLFW.cmake
Last active June 12, 2019 18:37
Better FindGLFW.cmake
# Distributed under the OSI-approved BSD 3-Clause License.
# See https://cmake.org/licensing for details.
#[=======================================================================[.rst:
FindGLFW
-------
Finds GLFW3.
Imported Targets
@emctague
emctague / attribPointers.hpp
Last active September 26, 2019 23:50
OpenGL Attrib Pointers Template System
/** Base case of OpenGL attrib pointer template tool. */
template<typename P, typename T>
inline void attribPointers(int n = 0, size_t s = 0) {
glEnableVertexAttribArray(n);
glVertexAttribPointer(n, sizeof(T)/sizeof(float), GL_FLOAT, GL_FALSE, sizeof(P), (void*)s);
}
/** Applies all OpenGL attrib pointers given as type arguments (first argument is vertex class). */
template<typename P, typename T, typename S, typename ...Args>
inline void attribPointers(int n = 0, size_t s = 0) {
@emctague
emctague / README.md
Last active October 25, 2019 20:01
command-line data url generator

dataurl

Converts a file into a data URL.

e.g.

dataurl test.png
Animals that lay eggs don't have belly buttons.
Beavers can hold their breath for 45 minutes under water.
Slugs have four noses.
Camels have three eyelids.
A honey bee can fly at 15mph.
A queen bee can lay 800-1,500 eggs per day.
A bee has five eyelids.
The average speed of a housefly is 4.5 mph.
Mosquitoes are attracted to people who just ate bananas.
Flamingos turn pink from eating shrimp.
@emctague
emctague / README
Created November 8, 2019 13:18
uini - Single header-file INI parser
uini: header-only INI parser
by Ethan McTague - November 8, 2019
Example:
#include "uini.h"
void handler(const char *section, const char *key, const char *value, void *user) {
printf("%s::%s = %s\n", section, key, value);
}
#!/usr/bin/env bash
# boxit: Format text inside box-drawing sections.
# Reads from stdin, waits for EOF (^D), then prints output to stdout.
# Lines containing three dashes will be converted into separators!
# Usage: boxit [--round]
# Copyright 2019 Ethan McTague
# License to use, modify, and distribute this software is granted to
# any and all entities wherever permitted by law.