Skip to content

Instantly share code, notes, and snippets.

@Midiman
Midiman / main.lua
Created June 6, 2012 23:30
[Love2D] Class Inheritence Error?
---------------------------------------------------------------
-- Amethyst
-- Created: 2012/06/05 10:02 PM
-- Version: 0.0.1
-- Website: http://www.place.com/
-- License: :) License
---------------------------------------------------------------
require("libs/32log")
require("util/types")
@Midiman
Midiman / new.lua
Created June 15, 2012 22:18
StepMania 5 - Jacket Display
local sBannerPath = THEME:GetPathG("Common", "fallback banner");
local sJacketPath = THEME:GetPathG("Common", "fallback jacket");
local bAllowJackets = true
local t = Def.ActorFrame {
Def.Sprite {
Name="Banner";
InitCommand=cmd(scaletoclipped,220,220;);
-- Commands to make sure each banenr gets the right look.
BannerCommand=cmd(scaletoclipped,256,80);
local screen;
if string.find(Var "LoadingScreen","MiniMenu") == nil then
if string.find(Var "LoadingScreen","Options") ~= nil and string.find(tostring(Screen.String("HeaderText")),"Options") == nil then
screen = tostring(Screen.String("HeaderText")).." Options";
else
screen = tostring(Screen.String("HeaderText"));
end
else
screen = "";
@Midiman
Midiman / audio.lua
Created September 7, 2012 09:30
Emo Engine Audio Example
local stage = emo.Stage();
// create audio manager with 1 channel.
local audio = emo.Audio(1);
// select audio channel 1 (index=0) to play the audio.
// you can handle audios through this channel.
local audioCh1 = audio.createChannel(0);
/*
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "Address.h"
#define NUM_FIELDS 4
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;
@Midiman
Midiman / README.md
Created October 12, 2013 20:29 — forked from nikcub/README.md
#!/usr/bin/env python
import argparse
import errno
import itertools
import json
import os
import requests
import time
WIDTHS = (1280, 500, 400, 250, 100, 75)
#include <map> // Component-entity system in 24 lines of C++11. 2013 rlyeh, MIT licensed.
#include <set> // Code fragment from kult engine - https://github.com/r-lyeh/kult
enum SUBSYSTEM_MODE { JOIN = 0, MERGE = 1, EXCLUDE = 2 };
template<typename T> std::set<unsigned> &system()
{ static std::set<unsigned> entities; return entities; }
template<typename T, int MODE> std::set<unsigned> subsystem( const std::set<unsigned> &B )
{ std::set<unsigned> newset; const std::set<unsigned> &A = system<T>(); // union first,
/**/ if (MODE == MERGE) { newset = B; for( auto &id : A ) newset.insert(id); } // then difference,
else if (MODE == EXCLUDE) { newset = B; for( auto &id : A ) newset.erase (id); } // then intersection
else if(A.size() < B.size()) { for( auto &id : A ) if(B.find(id) != B.end()) newset.insert( id ); }
data:text/html,<div class="wrap"> <h1>Todo<span>, no fuss lists</span></h1> <input placeholder="Add a todo" type="text" id="item" /> <button id="go">Save</button> <span class="help">* tap to delete</span> <ul id="tudu_list"> </ul> </div><script type="text/javascript">var tudu_list = document.getElementById('tudu_list'); var item = document.getElementById('item'); var new_li; var new_obj = {}; function prependElement(parentID,child) { parent=parentID; parent.insertBefore(child,parent.childNodes[0]); } function remove(element){ element.parentNode.removeChild(element); } function deleteItem(){ var answer = confirm('Sure you want to remove this?'); if(answer){ var deleteId = this.getAttribute('rel'); remove(this); } } function addItem(){ if(item.value !== ''){ new_li = document.createElement('li'); new_li.innerHTML = item.value; prependElement(tudu_list, new_li); new_li.onclick = deleteItem; item.value = ''; } } function callAdd(e){ if(event.keyCode == 13){ addItem(); } } item.onkeyup = function(e){ callAdd(e) };