Skip to content

Instantly share code, notes, and snippets.

View cheeaun's full-sized avatar
📬
Subscribe to my newsletter https://cheeaun.substack.com/

Chee Aun cheeaun

📬
Subscribe to my newsletter https://cheeaun.substack.com/
View GitHub Profile
@cheeaun
cheeaun / Element.isVisibleHidden.js
Created March 3, 2009 14:34
Mootools Element extras: isVisible and isHidden
/*
* Inspired from http://github.com/jeresig/sizzle/commit/7631f9c3f85e5fa72ac51532399cb593c2cdc71f
* and this http://github.com/jeresig/sizzle/commit/5716360040a440041da19823964f96d025ca734b
* and then http://dev.jquery.com/ticket/4512
*/
Element.implement({
isHidden: function(){
var w = this.offsetWidth, h = this.offsetHeight,
@cheeaun
cheeaun / html5-ie.js
Created March 16, 2009 03:22
HTML5 elements NOW!
/* HTML5 elements for IE
* more reference from: http://remysharp.com/2009/01/07/html5-enabling-script/
*/
(function(){
var e = 'abbr article aside audio bb datagrid datalist details dialog eventsource figure footer header mark menu meter nav output progress section time video'.split(' ');
var i = e.length;
while (i--) document.createElement(e[i]);
})();
@cheeaun
cheeaun / delicious.custombuttons.js
Created March 21, 2009 03:47
Custom Buttons JS
var width = 550;
var height = 550;
var left = parseInt( ( screen.availWidth / 2 ) - ( width / 2 ) );
var top = parseInt( ( screen.availHeight / 2 ) - ( height / 2 ) ) - 20;
var url = encodeURIComponent(content.location.href);
var title = encodeURIComponent(content.document.title);
var f = 'http://delicious.com/save?url=' + url + '&title=' + title + '&v=5&';
if (!content.open(f + 'noui=1&jump=doclose', 'deliciousuiv5', 'location=yes,links=no,scrollbars=no,toolbar=no,top=' + top + ',left=' + left + ',width=' + width + ',height=' + height)) location.href = f+'jump=yes';
@cheeaun
cheeaun / alt-keys.ahk
Created April 19, 2009 13:07
AutoHotkey script to map Alt key to work like Ctrl AKA Mac-style Cmd key, on Windows.
LAlt & x::Send ^x
LAlt & c::Send ^c
LAlt & v::Send ^v
LAlt & s::Send ^s
LAlt & w::Send ^w
LAlt & q::Send !{F4}
LAlt & f::Send ^f
LAlt & t::Send ^t
LAlt & z::Send ^z
LAlt & r::Send ^r
@cheeaun
cheeaun / webkit-nice-links.css
Created April 29, 2009 05:44
WebKit fading links
@cheeaun
cheeaun / ie6-cssize.js
Created May 21, 2009 11:22
IE6-CSSize Bookmarklet code
javascript:void(function(){var link=document.getElementsByTagName("link");for(var i=0,len=link.length;i<len;i++){var l=link[i];if(l&&((l.href.indexOf(".css")>-1||l.rel=="stylesheet"))){l.parentNode.removeChild(l)}}var style=document.getElementsByTagName("style");for(var i=0,len=style.length;i<len;i++){var s=style[i];if(s){s.parentNode.removeChild(s)}}var iecss=document.createElement("link");iecss.setAttribute("rel","stylesheet");iecss.setAttribute("href","http://forabeautifulweb.com/demo/2009/05/21/ie6.0.2.css");document.getElementsByTagName("head")[0].appendChild(iecss);}());
@cheeaun
cheeaun / Element.isVisibleHidden.js
Created June 30, 2009 09:22 — forked from fabiomcosta/Element.isVisibleHidden.js
MooTools Element.Shortcuts, isHidden and isVisible
/*
* Inspired from http://github.com/jeresig/sizzle/commit/7631f9c3f85e5fa72ac51532399cb593c2cdc71f
* and this http://github.com/jeresig/sizzle/commit/5716360040a440041da19823964f96d025ca734b
* and then http://dev.jquery.com/ticket/4512
*/
Element.implement({
isHidden: function(){
var w = this.offsetWidth, h = this.offsetHeight,
/*
* Idea from http://james.padolsey.com/javascript/stringprototypeextract/
*/
String.implement({
extract: function(regex, n){
n = (n===undefined) ? 0 : n;
if (!regex.global) return this.match(regex)[n] || '';
var match, extracted = [];
@cheeaun
cheeaun / String.isValidLuhn.js
Created July 20, 2009 19:22
Luhn validation code in JavaScript (MooTools)
/*
* Luhn algorithm number checker - (c) 2005-2008 shaman - www.planzero.org
* Ported to Mootools by Chee Aun - http://cheeaun.com/
* http://planzero.org/code/bits/viewcode.php?src=luhn_check.js
* http://en.wikipedia.org/wiki/Luhn_algorithm
*/
String.implement({
isValidLuhn: function(){
@cheeaun
cheeaun / Browser.Engines.trident.js
Created July 26, 2009 03:15
Browser Engine IE6/7/8 detection
Browser.Engines.trident = function(){
return (!window.ActiveXObject) ? false : ((window.XMLHttpRequest) ? ((Browser.Features.query) ? 6 : 5) : 4);
}