Skip to content

Instantly share code, notes, and snippets.

View ibolmo's full-sized avatar

Olmo Maldonado ibolmo

View GitHub Profile
/*
Script: Color.js
Class for creating and manipulating colors in JavaScript. Includes basic color manipulations and HSB <-> RGB <-> HEX Conversions.
License:
MIT-style license.
*/
function Color(type, color, alpha){
this.type = type.toUpperCase();
Array.implement({
max: function(){
return Math.max.apply(null, this);
},
min: function(){
return Math.min.apply(null, this);
}
Array.prototype.find = function(value){
var result = [], i = 0;
for (var i = 0, l = this.length; i < l; i++){
var item = this[i];
if (item == value) result.push(i);
}
return result;
};
Array.prototype.find = function(value){
Array.implement({
item: function(at){
if (!this.length) return null;
if (at < 0) at += this.length;
return (at < this.length) ? this[at] : null;
},
item: function(at){
if (!this.length || (at < 0 && (at += this.length) && false) || at > this.length) return null;
/*
Script: Element.Dimensions.js
Contains methods to work with size, scroll, or positioning of Elements and the window object.
License:
MIT-style license.
Credits:
- Viewport dimensions based on [YUI](http://developer.yahoo.com/yui/) code, [BSD License](http://developer.yahoo.com/yui/license.html).
function $A(iterable){
if (iterable.item){
var array = [];
for (var i = 0, l = iterable.length; i < l; i++) array[i] = iterable[i];
return array;
}
return Array.prototype.slice.call(iterable);
};
function $A(iterable){
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>profile_data</title>
<link rel="stylesheet" href="/css/master.css" type="text/css" media="screen" title="no title" charset="utf-8" />
</head>
<body>
<p>
Array.prototype.kami = function(by){
var a = [], temp = this.slice(0);
while (temp.length) a.push(temp.splice(0,by));
return a;
};
[0,1,2,3,4,5,6,7].kami(4)
@ibolmo
ibolmo / .htaccess
Created June 5, 2009 21:56
markdown and restructuredtext to HTML utility
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule (.*)\.(?:md|markdown)$ /utilities/md2html.php?file=%{REQUEST_FILENAME} [QSA,L]
RewriteRule (.*)\.(?:rst)$ /utilities/rst2html.php?file=%{REQUEST_FILENAME} [QSA,L]
</IfModule>
@ibolmo
ibolmo / Clean Whitespace.tmCommand
Created November 4, 2009 00:08
Textmate or E-Texteditor command. My settings: Save: Current File, Input: Entire Document, Environment: Cygwin (generic), Output: Replace Document, Activation: Key Equivalent: F2, Scope Selector: ''
#!/usr/bin/env python
import sys
import re
re_whitespace = re.compile(r"[ \t]+$")
# Remove unnecessary whitespace.
lines = [re.sub(re_whitespace, '', line) for line in sys.stdin.readlines()]