you are here: codestackercodes [RSS]leozera [RSS]

1kb ie 6 png fix hack

create a 1x1 'clear.gif' image

var clear="images/clear.gif" //path to clear.gif


pngfix=function(){var els=document.getElementsByTagName('*');var i_p=/\.png/i;var i=els.length;while (i-- >0){var el=els[i];var es=el.style;if(el.src&&el.src.match(i_p)&&es.filter==''){el.height = el.height;el.width = el.width;es.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+el.src+"',sizingMethod='crop')";el.src = clear;}else{var elb=el.currentStyle.backgroundImage;if(elb.match(i_p)){var path=elb.split('"');var rep=(el.currentStyle.backgroundRepeat=='no-repeat')?'crop':'scale';es.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+path[1]+"',sizingMethod='"+rep+"')";es.height=el.clientHeight+'px';es.backgroundImage="none";}}if (el.currentStyle.position!='absolute' && !es.filter && !el.tagName.match(/(body|html|script)/gi)) es.position="relative";if (es.filter&&el.currentStyle.position=="relative") es.position="static";}}
window.attachEvent('onload',pngfix);

another min-height hack

http://www.dustindiaz.com/min-height-fast-hack/

selector {
  min-height:500px;
  height:auto !important;
  height:500px;
}

safari single window mode

defaults write com.apple.Safari TargetedClicksCreateTabs -bool true

Password protecting your pages with htaccess

create a .htaccess file with this content.

the .htpasswd contains a user and encrypted password (e.g.: leo:4tHAiRmQ4OpjM). create a encrypted password in: http://www.kxs.net/support/htaccess_pw.html

AuthUserFile /home/leonardo/public_html/project/.htpasswd
AuthGroupFile /dev/null
AuthName "Restricted Access"
AuthType Basic
<limit GET>
require valid-user
</limit>

[funny] google pagerank code

function getPagerank(url) {
	// start off with a random low PR

	pagerank = randomNumber(0, 3);

	if ( pageHostedOn(url, 'google.com') ) {
		pagerank++;
	}
	else if ( pageHostedOn(url, 'microsoft.com') ) {
		pagerank–;
	}
	
	if ( pageValidates(url) ) {
		pagerank *= .5;
	}
	
	tag_value['b'] = 1;
	tag_value['h2'] = 2;
	tag_value['h1'] = 3;
	tag_value['strong'] = -1; // W3C sux!

	pagerank = calculateTagsPr(tag_value, pagerank);
	
	// Sergey said good news sites have

	// lots of nested tables

	tablesOnPage = getTagCount('table');
	if (tablesOnPage >= 50) {
		pagerank += 2;
	}
	if (pagerank >= 5) {
		pagerank = 4; // helps selling AdWords

	}
	if ( linksFrom('mattcutts.com', url) >= 4 ) {
		// I link to “clean” sites only

		// – Matt, Feb 2006

		pagerank += 2;
	}
	
	pagerank += countBacklinks(url) / 10000;
	blacklist1 = getList('government.cn/censored.txt');
	blacklist2 = getList('c:\larry-page-hatelist.txt');
	
	if ( inArray(blacklist1, url) || inArray(blacklist2, url) ) {
		pagerank = 0;
	}
	
	d = dashesInUrl(url);
	pagerank = (d >= 3) ? pagerank -1 : pagerank + 1;

	if ( inString(url, “how to build a bomb”) ) {
		// added on request. 2004-12-01.

		recipient = “peter@homelandsecurity.gov”;
		subject = “You might wanna check this…”;
		sendMailTo(recipient, subject, url);
		// page might still be relevant

		pagerank++;
	}

	if ( month() == "June" || month() == "October" ) {
		// makes people talk about

		// PR updates, good publicity

		pagerank -= randomNumber(1,3);
	} 

	if ( linkCol(url) == WHITE &&
		pageCol(url) == WHITE ) {
		// spammer!! Googleaxe it!!

		pagerank = 0;
	}

	if (url == “http://www.nytimes.com”) {

		// just testing, pls remove tomorrow

		// – Frank, June 2003

		pagerank = 10;
	}
	return pagerank;
}

mac os reading twitter updates

require 'rss/1.0'
require 'rss/2.0'
require 'open-uri'

content = ''
open('http://twitter.com/statuses/user_timeline/peepcode.rss').each { |i| content << i }
RSS::Parser.parse(content).items.each { |i| system "say \"#{i.title}\"" }

show hidden files in finder

to reverse, replaces YES by NO

defaults write com.apple.Finder AppleShowAllFiles YES
killall Finder

highlight active item in dock

for mac users. type in terminal

defaults write com.apple.dock mouse-over-hilte-stack -boolean YES

killall Dock

new flash helper with prototype effects

create an application helper to manage your rails messages
concept by nando vieira [simplesideias.com.br]

  # paste application_helper.rb

  def flash_message 
    messages = ""
    [:notice, :info, :warning, :error].each {|type|
      if flash[type]
        messages += "<p class=\"#{type}\" id=\"alert\">#{flash[type]}</p>"
      end
    }    
    messages
  end

  ####################################


  # your layout 

  <%= flash_message %>
	
  <% content_tag :script, :type => "text/javascript" do %>
    $('alert').style.display = 'none';
    new Effect.Appear('alert', {duration: 3});
    setTimeout("new Effect.Fade('alert');", 10000);
  <% end %>

resets autoincrement (mysql)

ALTER TABLE tablename AUTO_INCREMENT = 1
Displaying Code 261 - 270 of 270 in total