Skip to content

Instantly share code, notes, and snippets.

function split(s, v)
local pos = s:find(v)
local ret = {}
local idx = 1
for i=1,string.len(s) do
local c = s:sub(i,i)
local token = s:sub(i, i+v:len()-1)
if token:find(v) then
idx = idx + 1
else
all:
cp foo.o bar.o
@echo "or if you're the silent type..."
@cp bar.o baz.o
@echo "copied bar.o to baz.o"
-- size 3
-- going up 1 3 5
-- going down 5 3 4 4 1 2 2 3 3
-- size 5
-- going up 1 3 5 7 9
-- going down 9 7 8 8 5 6 6 7 7 3 4 4 5 5 1 2 2 3 3 4 4
-- string.format is quite a bit of typing
_ = string.format;
@shakesoda
shakesoda / foo.cpp
Created May 29, 2013 08:44
GL/AL/similar extension pretty printing.
void pretty_print_extensions(std::vector<std::string> &extensions)
{
// derived from the extension pretty printing from StepMania.
using namespace std;
sort( extensions.begin(), extensions.end() );
size_t next = 0;
while( next < extensions.size() )
{
size_t last = next;
@shakesoda
shakesoda / openhmd.h
Last active December 17, 2015 20:59
OpenHMD API mockup
/*
* OpenHMD - Free and Open Source API and drivers for immersive technology.
* Copyright (C) 2013 Fredrik Hultin.
* Copyright (C) 2013 Jakob Bornecrantz.
* Distributed under the Boost 1.0 licence, see LICENSE for full text.
*/
#ifndef OPENHMD_H
#define OPENHMD_H
@shakesoda
shakesoda / findvar.js
Created June 12, 2013 22:55
snippet for parsing a get variable out of a url
function findVar(attr) {
var url = location.href.split("#")[0];
var search = new RegExp(attr + "=.*?(?=[#&]|$)");
var result = search.exec(url);
if (result !== null) {
result = result[0].split("=")[1];
if (/^-?\d+(\.\d+)?$/.test(result))
return Number(result);
else
return result;
@shakesoda
shakesoda / png.cpp
Created August 22, 2013 23:24
some old libpng code
#include <GL/glfw3.h>
#include <png.h>
#include "managers/FileManager.h"
#include "PNGFile.h"
#include "utils/Logger.h"
Texture PNGFile::Load(std::string _path)
{
Texture tex;
@shakesoda
shakesoda / ConvertUTF.c
Created August 23, 2013 09:52
ConvertUTF
/*
* Copyright 2001-2004 Unicode, Inc.
*
* Disclaimer
*
* This source code is provided as is by Unicode, Inc. No claims are
* made as to fitness for any particular purpose. No warranties of any
* kind are expressed or implied. The recipient agrees to determine
* applicability of information provided. If this file has been
* purchased on magnetic or optical media from Unicode, Inc., the
@shakesoda
shakesoda / metrics.ini
Created October 21, 2013 22:21
3d wheel more or less operating
[ScreenSelectMusic]
MusicWheelX=SCREEN_CENTER_X
MusicWheelY=SCREEN_CENTER_Y
MusicWheelOnCommand=draworder,DrawOrder.Overlay;SetDrawByZPosition,true;fov,90
[MusicWheel]
ItemWidth=math.max(math.ceil(SCREEN_WIDTH/3), 220)
ItemHeight=55
ItemOffset=0
ItemTransformFunction=function(self,offsetFromCenter,itemIndex,_numItems) \
@shakesoda
shakesoda / Makefile
Last active December 26, 2015 16:18
simple gcw zero makefile + package script
CC=mipsel-gcw0-linux-uclibc-gcc
CXX=mipsel-gcw0-linux-uclibc-g++
LIBS=-lGLESv2 -lEGL -Iglm
FLAGS=-Wall -Wextra -fno-strict-aliasing -Og -ggdb -std=c++11 -Wno-missing-field-initializers
OUT=bin/game.bin
FILES=src/*.cpp src/stb_image.c
PACKAGE=gcw-test.opk
all:
@if ! test -d bin; then mkdir bin; fi;