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 / 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 / close-app-mem.ahk
Created June 15, 2009 15:13
AutoHotkey script to immediately kill an application when exceeded a set memory usage limit
Loop {
app = msnmsgr.exe
; Live Messenger on my machine is having memory leaks, hence this script :)
mem := GetProcessMemoryInfo(app)
Menu, tray, tip, %app% %mem% KB
if mem > 80000
{
Process, close, %app%
TrayTip, %app% closed, %mem% KB used.
}
@cheeaun
cheeaun / evalJSON.js
Created June 22, 2009 10:37
JSON parsing method, uses eval() for old browsers, JSON.parse for new ones.
var evalJSON = function(string){
return (window.JSON && JSON.parse) ? JSON.parse(string) : eval('(' + string + ')');
};
@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);
}
@cheeaun
cheeaun / Element.getOffsets.1.2.2.js
Created July 30, 2009 11:24
Restoring the old getOffsets from 1.2.2
(function(){
Element.implement({
getOffsets: function(){
if (Browser.Engine.trident){
var bound = this.getBoundingClientRect(), html = this.getDocument().documentElement;
var isFixed = styleString(this, 'position') == 'fixed';
return {
x: bound.left + ((isFixed) ? 0 : html.scrollLeft) - html.clientLeft,
@cheeaun
cheeaun / horizontal-scroll.ahk
Created August 4, 2009 03:18
AutoHotkey: Shift + Wheel for horizontal scrolling
; Shift + Wheel for horizontal scrolling
+WheelDown::WheelRight
+WheelUp::WheelLeft