Skip to content

Instantly share code, notes, and snippets.

View akoluthic's full-sized avatar

Alex Yoder akoluthic

View GitHub Profile
@akoluthic
akoluthic / glerror.c
Last active June 28, 2016 14:43
OpenGL error catching
GLenum err = glGetError();
while (err != GL_NO_ERROR) {
fprintf(stdout, "glError: %s caught at %s:%u\n", (char *)gluErrorString(err), __FILE__, __LINE__);
err = glGetError();
}
@akoluthic
akoluthic / ualpha26_to_int.c
Last active September 29, 2015 17:25
base 26 uppercase alpha string to integer
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int ipow(int base, int exp)
{
int r = 1;
while (exp) {
if (exp & 1)
r *= base;
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>author</key>
<string>Fernando L. Garcia Bermudez</string>
<key>name</key>
<string>Desert Night</string>
<key>settings</key>
<array>
@akoluthic
akoluthic / two-bit-int.c
Created February 12, 2014 22:04
Bit twiddling method for breaking up a byte into 4 2-bit sections
#include <stdio.h>
#include <stdint.h>
int main() {
//set initial vars, range of 0 - 3
int p1 = 1;
int p2 = 2;
int p3 = 0;
int p4 = 3;
@akoluthic
akoluthic / mini-astar.c
Last active August 29, 2015 13:56
A minimal, inefficient, beginner's intro to the A* pathfinding algorithm
/**********************
mini-astar
a very minimal A* pathfinding implementation
Map Key
0 = normal tile
1 = impassable tile
5 = start
9 = goal
@akoluthic
akoluthic / roundDownPow2.js
Created September 5, 2013 21:39
Javascript algorithm for rounding down an integer to the nearest power of 2 using bitwise operators
//modified from http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
//input of 1 returns 1
function nextLowestPow2(d) {
d|=d>>1;
d|=d>>2;
d|=d>>4;
d|=d>>8;
d|=d>>16;
return (d + 1) / 2;
@akoluthic
akoluthic / Ubuntu12.04-g++4.8
Created September 1, 2013 13:35
Install g++ 4.8 on Ubuntu 12.04
*Add the toolchain/test PPA*
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-4.8
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50
*If you ever want to update symlinks for a future version:*
sudo rm /usr/bin/g++
sudo ln -s /usr/bin/g++-4.XXX /usr/bin/g++
@akoluthic
akoluthic / js-log2.js
Last active December 21, 2015 04:48
Javascript - Determine power of 2 (log2)
function log2(val) {
return Math.log(val) / Math.LN2;
}
//find the number of flags a musical note gets
alert(log2(8) - 2); //8th notes get 1 flag
alert(log2(128) - 2); //128th notes get 5 flags
@akoluthic
akoluthic / lilypond_string_ind.ly
Last active December 14, 2015 07:29
If you change the default fonts, this will print string number indications (roman numeral format)
f'8^ \markup { \fontsize #-1 \override #'(font-name . "Century Schoolbook bold") "II" }
@akoluthic
akoluthic / LilyPond crescendo length
Last active December 12, 2015 08:39
LilyPond error workaround: "warning: crescendo too small"
\once\override Hairpin #'minimum-length = #7