Skip to content

Instantly share code, notes, and snippets.

View millermedeiros's full-sized avatar

Miller Medeiros millermedeiros

View GitHub Profile
@millermedeiros
millermedeiros / gist:773911
Created January 11, 2011 02:38
Format Time: seconds to time string
/**
* @param {number} seconds Number between 0 to 359999.
* @return {string} Time string on the format 'HH:MM:SS'.
* @author Miller Medeiros
*/
function formatTime(seconds){
var output = Math.floor(seconds/3600) +':'+ ((Math.floor(seconds/60)%60) ^ 0) +':'+ ((seconds%60) ^ 0); //XOR 0 removes decimal digits
return output.replace(/([^0-9]|^)([0-9])(?=[^0-9]|$)/g, '$10$2'); //add zero before single digits
}
@millermedeiros
millermedeiros / default.css
Created January 9, 2011 17:55
Default CSS file
/**
* Awesome website
* @author YOUR_NAME_HERE
* @version 0.1
*/
/* ============================ RESET ============================ */
/* ===== Eric Meyer Reset ===== */
@millermedeiros
millermedeiros / gist:712798
Created November 23, 2010 23:50
Simple string template parsing - AS3
/**
* Simple string replacement inspired by Mustache
* @param template String to be parsed
* @param data Object containing Key -> Value pairs.
* @return Formated string
*/
function parseTemplate(template : String, data : Object): String {
function replaceFn() : String{
var prop : String = arguments[1];
return (prop in data)? data[prop] : '';
package rinaldi.util {
import flash.utils.getQualifiedClassName;
/**
*
* Just check if an object is a Vector instance or not.
*
* @param p_object Object to be checked.
/*
* Predator on acid - JS1K submission
* - Compress using closure compiler <http://closure-compiler.appspot.com/>
*
* Released under WTFPL license <http://sam.zoy.org/wtfpl/>.
*
* @author Miller Medeiros <http://millermedeiros.com/>
* @version 0.1 (2010/08/06)
*/
/*
* Mr.doob's entry for JS1K <http://mrdoob.com/blog/post/703>
* @author Mr.doob <http://mrdoob.com/>
* extra optimizations by Miller Medeiros <http://blog.millermedeiros.com/> (see comments on source code)
*/
( function () {
var res = 25, res3 = res * res * res,
i = 0, x = 0, y = 0, z = 0, s, size, sizeHalf,