Skip to content

Instantly share code, notes, and snippets.

View Yonaba's full-sized avatar
💭
I may be slow to respond.

Roland Yonaba

💭
I may be slow to respond.
View GitHub Profile
@Yonaba
Yonaba / sierpinski.lua
Created June 29, 2011 13:59
Sierpinski Triangle
-- Creates an image
-- uses LuaPlayer as Framework
local image = Image.createEmpty(480,272)
local white = Color.new(255,255,255)
--Fractal Size
local size = 480
--Draws Fractal
@Yonaba
Yonaba / TxtToPDF.lua
Created June 29, 2011 14:09
Simply Convert Text File To PDF Using LuaHPDF
--LUA Txt to PDF Converter
--Thanks to Takeshi Kanno (HaruFreePDF Lib) and LUAHPDF Module
--We load the library
require 'hpdf'
--Assuming filename 'input.txt'
local filename = 'input.txt'
--We seek the file to collect data inside a table
@Yonaba
Yonaba / GetID3Tag.lua
Created June 29, 2011 14:12
Retrieve ID3 tags from MP3
--Custom function that collects ID3 tag from mp3 File
function getID3(filename)
local ID3 = {}
local file = assert(io.open(filename,"rb"))
file:seek("end")
file:seek("cur",-128)
ID3.TAG = file:read(3)
ID3.TITLE = file:read(30)
ID3.INTERPRET = file:read(30)
@Yonaba
Yonaba / Md2Viewer.lua
Created June 29, 2011 14:19
Draw MD2 Model using irrLua
-- Quick Sheet on How to load and draw MD2 model using IrrLua
-- IrrLua can be found at http://irrlua.sourceforge.net/
require "irr"
local MyEventReceiver = {}
function MyEventReceiver:OnEvent(Event)
if Event.EventType == irr.EET_KEY_INPUT_EVENT then
return self:OnKeyEvent(Event.KeyInput.Key, Event.KeyInput.PressedDown, Event.KeyInput.Control, Event.KeyInput.Shift)
@Yonaba
Yonaba / LibDofile.lua
Created June 29, 2011 14:24
Custom Dofile Function (For PSP's LuaPlayer Debugging)
----------------------------
--LIB DOFILE
--Roland Yonaba (SeanPaul223)
--03/08/2010
----------------------------
-----------------------------------------------------------------------------------------
--The main purpose of this library is helping Lua coders to debug their apps bypassing the
--in-built error screen, which blocks the running process
@Yonaba
Yonaba / improcessing.lua
Created June 29, 2011 14:34
Image Processing Using Lua
-- A Library that provides naive-implemented algorithms for image processing
-- All functions assumes 'img' is a reference to a Drawable object loaded onto memory.
--Flips vertically a picture
function getImageFlipVertical(img)
local w = img:width()-1
local h = img:height()-1
local flip = Image.createEmpty(w+1,h+1)
for y = h,0,-1 do
for x = 0,w,1 do
@Yonaba
Yonaba / SRT.lua
Created June 29, 2011 14:39
Lua Subtitle Parser
-- A simple way to read .srt subtitles while streaming music!
-- This code uses LuaPlayer for PSP as framework.
local subs = {}
local _time = {}
local current_sub = 1
function get_time(tm)
local startTime,endTime
local t1={}
@Yonaba
Yonaba / bin2dec.lua
Created June 29, 2011 14:43
BinaryToDecimal
--Returns a binary string computed from a decimal arg
function dec2bin(dec)
local r,q
local str=""
repeat
q = math.modf(dec/2)
r= dec%2
dec=q
str = str..tostring(r)
@Yonaba
Yonaba / BWTransform.lua
Created June 29, 2011 14:51
Burrows-Wheeler Transform
-- Burrows-Wheeler Transform
-- Algorithm used for data compressing implemented through Lua
function encode(word)
local t={word}
local pos = 1
local cat = string.len(word)
for i=cat-1,1,-1 do
@Yonaba
Yonaba / Fract.lua
Created June 29, 2011 14:56
How To Compute Fraction
-- A function that return a fraction computed from a floating number.
function int(arg)
local e,d = math.modf(arg)
return e
end
function dec2fr(decimal,acc)
local acc = acc
if not acc then acc = 1E-4 end