Other @fractastical Google Chart URL Gen

     // The step is the distance between each label on the y axis
     public Integer calculateStepSize(Integer highestVal)
     {
	     	//calculates the appropriate step to display on the y axis
		  List<Integer> possibleSteps = New Integer[]{1,2,5,10,20,50};  
		  for(Integer i= (possibleSteps.size() - 1);i >= 0; i--) {
		  	System.debug('HIGH DIV 6:' + (highestVAl / 6) + ' POSS STEP:' + possibleSteps[i]);  
		  	if ((highestVal / 6) > possibleSteps[i])  
		  		return possibleSteps[i];
		  }
		  return 1;            
     }
     
     public Integer roundUpToClosestStep(Integer highestVal, Integer step)
     {
     	  return highestVal + (step - (math.mod(highestVal,step)));   
     }	
     
     //The idea is that any parameter could be overwritten with a Map specifying a different value pair (hash)
    //Data integrity should also be insured (e.g. that the length of both the data and labels are the same)
    public String generateChartURL(String title, List<Integer> incomingData, List<String> incomingLabels, Map <String,String> valuePairs)
    {  
     	if (incomingData.size() == 0)
    		return '';
    	
    	String dataString = '';
    	Integer highest = 0;
    	for (Integer d : incomingData) {
    		if (d > highest)
    			highest = d;
    		dataString += d + ',';
    	}
    	 dataString = dataString.substring(0, dataString.length() - 1);
     
     	 Integer step = calculateStepSize(highest);
		 highest = roundUpToClosestStep(highest, step);
		//System.debug('STEP:' + step);  
		     
		 String chartType = 'cht=bvg'; //vertical bar chart
		 String colors = 'chco=4D89F9,C6D9FD';       
		 String spacing = 'chbh=20,4,20';    
		 String chartSize = 'chs=600x200';                          
		 
		 //y axis, start value, highest value, step	size
		 String YAxisRange = 'chxr=1,0,' + Highest + ',' + step;    
		 String scaling = 'chds=0,' + Highest;
		 String data = 'chd=t:' + dataString;        
		
		 String chartLabels = 'chxt=x,y&chxl=0:|';
		 
		 //System.debug('LABEL SIZE:' + incomingLabels.size());
		 for (String l: incomingLabels)
		 	chartLabels += l + '|';   
		 chartLabels = chartLabels.substring(0, chartLabels.length() - 1);
		 
		 //System.debug('CHART LABEL:'+chartlabels);
		 
		 String chartTitle = 'chtt=' + title.replaceAll(' ','+');  

	  
		 String chartPath = 'http://chart.apis.google.com/chart?';    
		 return  chartPath + chartType + '&' + ChartTitle + '&' + YAxisRange + '&' + colors + '&' + Scaling + '&' + chartLabels + '&' + spacing + '&'  + Data + '&' + chartSize;
    }

Other @dlog触发模板

trigger AccountTrigger on Account (after delete, after insert, after undelete, 
after update, before delete, before insert, before update) {
	AccountTriggerHandler handler = new AccountTriggerHandler(Trigger.isExecuting, Trigger.size);
	
	if(Trigger.isInsert && Trigger.isBefore){
		handler.OnBeforeInsert(Trigger.new);
	}
	else if(Trigger.isInsert && Trigger.isAfter){
		handler.OnAfterInsert(Trigger.new);
		AccountTriggerHandler.OnAfterInsertAsync(Trigger.newMap.keySet());
	}
	
	else if(Trigger.isUpdate && Trigger.isBefore){
		handler.OnBeforeUpdate(Trigger.old, Trigger.new, Trigger.newMap);
	}
	else if(Trigger.isUpdate && Trigger.isAfter){
		handler.OnAfterUpdate(Trigger.old, Trigger.new, Trigger.newMap);
		AccountTriggerHandler.OnAfterUpdateAsync(Trigger.newMap.keySet());
	}
	
	else if(Trigger.isDelete && Trigger.isBefore){
		handler.OnBeforeDelete(Trigger.old, Trigger.oldMap);
	}
	else if(Trigger.isDelete && Trigger.isAfter){
		handler.OnAfterDelete(Trigger.old, Trigger.oldMap);
		AccountTriggerHandler.OnAfterDeleteAsync(Trigger.oldMap.keySet());
	}
	
	else if(Trigger.isUnDelete){
		handler.OnUndelete(Trigger.new);	
	}
}

Other @dlog触发器处理程序模板

 
public with sharing class AccountTriggerHandler {
	private boolean m_isExecuting = false;
	private integer BatchSize = 0;
	
	public AccountTriggerHandler(boolean isExecuting, integer size){
		m_isExecuting = isExecuting;
		BatchSize = size;
	}
		
	public void OnBeforeInsert(Account[] newAccounts){
		//Example usage
		for(Account newAccount : newAccounts){
			if(newAccount.AnnualRevenue == null){
				newAccount.AnnualRevenue.addError('Missing annual revenue');
			}
		}
	}
	
	public void OnAfterInsert(Account[] newAccounts){
		
	}
	
	@future public static void OnAfterInsertAsync(Set<ID> newAccountIDs){
		//Example usage
		List<Account> newAccounts = [select Id, Name from Account where Id IN :newAccountIDs];
	}
	
	public void OnBeforeUpdate(Account[] oldAccounts, Account[] updatedAccounts, Map<ID, Account> accountMap){
		//Example Map usage
		Map<ID, Contact> contacts = new Map<ID, Contact>( [select Id, FirstName, LastName, Email from Contact where AccountId IN :accountMap.keySet()] );
	}
	
	public void OnAfterUpdate(Account[] oldAccounts, Account[] updatedAccounts, Map<ID, Account> accountMap){
		
	}
	
	@future public static void OnAfterUpdateAsync(Set<ID> updatedAccountIDs){
		List<Account> updatedAccounts = [select Id, Name from Account where Id IN :updatedAccountIDs];
	}
	
	public void OnBeforeDelete(Account[] accountsToDelete, Map<ID, Account> accountMap){
		
	}
	
	public void OnAfterDelete(Account[] deletedAccounts, Map<ID, Account> accountMap){
		
	}
	
	@future public static void OnAfterDeleteAsync(Set<ID> deletedAccountIDs){
		
	}
	
	public void OnUndelete(Account[] restoredAccounts){
		
	}
	
	public boolean IsTriggerContext{
		get{ return m_isExecuting;}
	}
	
	public boolean IsVisualforcePageContext{
		get{ return !IsTriggerContext;}
	}
	
	public boolean IsWebServiceContext{
		get{ return !IsTriggerContext;}
	}
	
	public boolean IsExecuteAnonymousContext{
		get{ return !IsTriggerContext;}
	}
}

CSS CSS - CSS3 Safari样式工具栏按钮圆角框阴影按下边框半径为Moz,Firefox,KHTML

/**
 * Author: Chris Morrell <http://cmorrell.com/>
 * Version: 1.1
 * 201008051349 - brandonjp - modified for moz, khtml, css3
 *
 * from http://cmorrell.com/safari-extensions
 *
 * You may use this file any way you see fit.
 *
 */

a, button {
	color: #282828;
	font-weight: bold;
	text-shadow: 0px 1px 0px rgba(255, 255, 255, 0.4);
	text-decoration: none;
	padding: 1px 7px 2px;
	display: inline-block;
	border-radius: 8px;
	cursor: default;
	border: none;
	background: none;
}

a:hover, button:hover {
	color: #fff;
	text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.4);
	background: rgba(0, 0, 0, 0.21);
}

a:active, button:active, a.toggled, button.toggled {
	color: #fff;
	text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.4);
	box-shadow: inset
		0 1px 2px rgba(0, 0, 0, 0.5),
		0 1px 1px rgba(255, 255, 255, 0.8);
	-moz-box-shadow: inset
		0 1px 2px rgba(0, 0, 0, 0.5),
		0 1px 1px rgba(255, 255, 255, 0.8);
	-khtml-box-shadow: inset
		0 1px 2px rgba(0, 0, 0, 0.5),
		0 1px 1px rgba(255, 255, 255, 0.8);
	-webkit-box-shadow: inset
		0 1px 2px rgba(0, 0, 0, 0.5),
		0 1px 1px rgba(255, 255, 255, 0.8);
}

a.toggled, button.toggled {
	background: rgba(0, 0, 0, 0.35);
}

a:active, button:active {
	background: rgba(0, 0, 0, 0.49);
}

Bash tar(untar)和gzip(ungzip)文件

# tar and gzip some files
tar -zcvf output.tar.gz input_folder

# untar and gunzip a file
tar xvfz /some_files.tar.gz

jQuery 基本的jQuery AJAX提交

$.ajax({
	url: $(this).attr('action') + '.json',
	data: $(this).serialize(),
	type: $(this).attr('method'),
	dataType: "json",
	success: function(data) {
		
	}
});

Bash 从Postgres中的表导出/导入数据子集

# Development Server

psql database_name
CREATE TABLE temp_table_name AS SELECT * FROM actual_table WHERE some_field = 'some_value' ORDER BY some_field;
\q

pg_dump -t temp_table_name database_name | gzip > temp_table_name.sql.gz
scp temp_table_name.sql.gz user@server:
psql database_name
DROP TABLE temp_table_name;

# Production Server

zcat temp_table_name.sql.gz | psql database_name
psql database_name
INSERT INTO actual_table SELECT * FROM temp_table_name;
DROP TABLE temp_table_name;

Other Visualforce Lightbox组件

<!-- AppExchange Link http://sites.force.com/appexchange/listingDetail?listingId=a0N30000001g3u0EAA -->
<!-- Jonathan Hersh - jhersh@salesforce.com - 7/13/2009 -->

<apex:component selfclosing="true">
	<apex:attribute name="function" description="This is the name of the JS function to call." 
        type="String" required="true"/>
    <apex:attribute name="title" description="This is the title displayed in the lightbox." 
        type="String" required="true"/>
    <apex:attribute name="content" description="This is the HTML content of the lightbox." 
        type="String" required="true"/>
    <apex:attribute name="width" description="This is the width, in pixels, of the lightbox." 
        type="Integer" required="true"/>
    <apex:attribute name="duration" description="This is the duration, in ms, to show the box before it autohides (i.e. 2000ms = 2 sec), or 0 for an untimed box." 
        type="Integer" required="true"/>
	
	<script type="text/javascript">		
        function {!function}() {
             var box = new parent.SimpleDialog("hersh"+Math.random(), true);
             parent.box = box;
        
             box.setTitle("{!title}");
        
             box.createDialog();
             box.setWidth({!width});
             
             box.setContentInnerHTML("<a href=\"#\" onclick=\"box.hide();\">Close</a><br /><br /><p>{!content}</p>");

             box.setupDefaultButtons();
             
             box.show();
             
             if( {!duration} > 0 )
             	setTimeout("box.hide();",{!duration});
        }
	</script>
</apex:component>

JavaScript 查看iPad的源书签

javascript:(function(){var a=window.open("about:blank").document;a.write("<!DOCTYPE html><html><head><title>Source of "+location.href+'</title><meta name="viewport" content="width=device-width" /></head><body></body></html>');a.close();var b=a.body.appendChild(a.createElement("pre"));b.style.overflow="auto";b.style.whiteSpace="pre-wrap";b.appendChild(a.createTextNode(document.documentElement.innerHTML))})();

CSS master.css

* {
	/* old-style reset here :) */
	border: 0px;
	padding: 0px;
}
body {
	font-family: Helvetica;
	background: white;
/*	text-align: center;*/
/*	background: url(../images/body.png) repeat-x;*/
}
body h1 {
	padding-top: 20px;
	font-size: 26px;
	color: #335;
}
#content td {
border-bottom:medium none;
padding:0;
}
#calmain table {
	border-collapse: separate;
	border: 1px solid #9DABCE;
	border-width: 0px 0px 1px 1px;
	margin: 10px auto;
	font-size: 20px;
}
#calmain td, #calmain th {
	width: 81px;
	height: 81px;
	text-align: center;
	vertical-align: middle;
	background: url(../images/cells.png);
	color: #444;
	position: relative;
	padding:0;
}
#calmain th {
	height: 30px;
	font-weight: bold;
	font-size: 14px;
}
#calmain td:hover, #calmain th:hover {
	background-position: 0px -81px;
	color: #222;
}
#calmain td.date_has_event {
	background-position: 162px 0px;
	color: white;
}
#calmain td.date_has_event:hover {
	background-position: 162px -81px;
}
#calmain td.padding {
	background: url(../images/calpad.jpg);
}
#calmain td#today {
	background-position: 81px 0px;
	color: white;
}
#calmain td#today:hover {
	background-position: 81px -81px;
}
#calmain .events {
	position: relative;
}
#calmain .events ul {
	text-align: left;
	position: absolute;
	display: none;
	z-index: 1000;
	padding: 15px;
	background: #E7ECF2 url(../images/popup.png) no-repeat;
	color: white;
	border: 1px solid white;
	font-size: 15px;
	width: 200px;
	-moz-border-radius: 3px;
	-khtml-border-radius: 3px;
	-webkit-border-radius: 3px;
	-border-radius: 3px;
	list-style: none;
	color: #444444;
	-webkit-box-shadow: 0px 8px 8px #333;
}
#calmain .events li {
	padding-bottom: 5px;
}
#calmain .events li span {
	display: block;
	font-size: 12px;
	text-align: justify;
	color: #555;
}
#calmain .events li span.title {
	font-weight: bold;
	color: #222;
}

#calmain th a{
text-decoration:none;
font-size:120%;
font-weight:bold;
color: #000;
outline-width:0;
}

#content textarea, #content input{
	border: 1px solid #ccc;
}
/* Calendar */

#calmain{
	width: 50%;
	float: left;
}
#calleft{
	float: left;
	width: 20%;
	padding: 20px;
}
#calright {
	float: left;
	width:20%;
	padding: 20px;
}