DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets

  • submit to reddit

Recent Snippets

                    
class ApplicationController < ActionController::Base
  before_filter :choose_theme
  
  private
  def choose_theme
    ActionController::Base.template_root = File.join(RAILS_ROOT, 'app/views', @params['theme'])
  end
end
                
                    To always show the vertical scrollbar, regardless of whether there is content to scroll (à la Internet Explorer), add this to userContent.css

html {
     overflow: -moz-scrollbars-vertical;
}

Tested in Firefox 1.0 and above.                
                    To have a <DIV> shrink and enlarge based on its content, use this CSS:

div.autosize { display: table; width: 1px; }
div.autosize > div { display: table-cell; }

In your HTML, enclose the <DIV> you want autosized in another <DIV> with class="autosize"

Before:

<div>
I want this to be auto sized!
</div>

After:

<div class="autosize">
<div>
I want this to be auto sized!
</div>
</div>

Tested in Firefox, Mozilla, Safari, Opera 7, and Internet Explorer 6.                
                    If you have a table with rowspans and colspans, it's especially likely that IE6 will begin to ignore your width settings (even if they all add up to the right number) and create a monster table that spreads off into the distance. If your tables work perfectly in FF/Safari/etc, and in IE6 your content is positioned properly but the invisible elements of the table (visible only with borders on) extends to the side so that you get a horizontal scroll bar no matter what you do, you might want to try this drastic CSS tweak:

html {
    overflow-y: hidden;
}

If that doesn't work, try it in body:
body {
    overflow-y: hidden;
}

<disclaimer>Note that this is somewhat hackish, as a last resort if you *know* your tables are *fine* and IE6 is screwing up, and that overflow-x/y are IE6-only and not real CSS. </disclaimer>                
                    
function hexToRGB ( hex:Number ){
   var returnObj:Object = new Object();   
   var returnObj .r = hex >> 16;
   var temp = hex ^ r << 16;
   var returnObj .g = temp >> 8;
   var returnObj .b = temp ^ g << 8;

   return returnObj;
}
                
                    
function RGBToHex (r, g, b ){
    var hex = r << 16 ^ g << 8 ^ b;
   return hex;
}
                
                    
<OBJECT CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" 
WIDTH="176"HEIGHT="170" 
CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab"> 
<PARAM name="SRC" VALUE="http://www.ericd.net/3gpp/1984_launch.3gp"> 
<PARAM name="AUTOPLAY" VALUE="false"> 
<param NAME="type" VALUE="video/quicktime">
<PARAM name="CONTROLLER" VALUE="true"> 
<EMBED SRC="http://www.ericd.net/3gpp/1984_launch.3gp" WIDTH="176" HEIGHT="170" 
AUTOPLAY="false" CONTROLLER="true" type="video/quicktime"PLUGINSPAGE="http://www.apple.com/quicktime/download/"> 
</EMBED> 
</OBJECT>
                
                    
import mx.events.EventDispatcher;
import mx.utils.Delegate;

class Emailer {
	
	// required for EventDispatcher:
	public var addEventListener:Function;
	public var removeEventListener:Function;
	private var dispatchEvent:Function;
	
	// use to communicate with php script
	private var _lv:LoadVars;
	// holds address of sender
	private var _sentFrom:String;
	
	// constructor
	public function Emailer() {    
		EventDispatcher.initialize(this);
		_lv = new LoadVars();
	}

	// 
	private function dataReceived(dataxfer_ok:Boolean):Void {
		// if some problem with loadVars transfer, pass back error=2
		if (!dataxfer_ok) dispatchEvent({target:this, type:'mailSent', errorFlag:2});
		// otherwise pass back error code returned from script
		else dispatchEvent({target:this, type:'mailSent', errorFlag:Number(_lv["faultCode"])});
	}
	
	 // Use loadvars object to send data (set to call dataReceived when script returns data)
	public function sendEmail(sub:String, fn:String, fe:String, msg:String, rep:String):Void {
		// if user already sent from this address, show error msg
		if (_sentFrom == fe) dataReceived(false);
		// otherwise set up and send
		else {
			_sentFrom = fe;
			// specify function to handle results, make scope = Emailer
			_lv.onLoad = Delegate.create(this, dataReceived);
			// set up properties of lv to items to be POSTed
			_lv.subject = sub;
			_lv.name = fn;
			_lv.email = fe;
			_lv.message = msg;
			_lv.reply = rep;
			// call script
			_lv.sendAndLoad("sendemail.php", _lv, "POST");
		}
	}
} 
                
                    If installed under Mambo, edit:
mambots/editors/tinymce_exp.php
Lines 157-158:
  relative_urls : true,
  remove_script_host : true,
                
                    When installed in Mambo, edit 
mambos/editors/tinymce_exp/jscripts/tiny_mce/plugins/advlink/link.php
 lines 253-258:
<select name="target" id="target">
          <option value="_self" selected>_self (<?php echo _insert_link_target_same ?>)</option>
          <option value="_blank">_blank (<?php echo _insert_link_target_blank ?>)</option>
          <!--<option value="_parent">_parent (<?php echo _insert_link_target_parent ?>)</option>
          <option value="_top">_top (<?php echo _insert_link_target_top ?>)</option>-->
</select>