Removing Chatter feed from the home page

Update: This method no longer works due to changes in Salesforce Home Page Components.

 

Holy cow I’m actually alive, although I can’t say the same for my blog. I finally decided to put something up here on the blog again to help a fellow force.com user. This code can be applied to your home page via an HTML home page component to remove the Chatter feed at the top of the page.

Note Don’t forget to hit “show html” before pasting the code into the component.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$j = jQuery.noConflict();
$j('.chatterfeedshell').parent().remove();
</script>

Once you’ve created the component add it onto the home page layout and it’ll hide the content. The only downside I see so far is it created an additional section in the home page. If you already have an existing HTML component you can just paste this code into it to hide this additional section.

Hopefully I’ll be able to turn this post into a momentum and start posting some more. I’ll refine this post some more later tonight with some images and steps and possibly a non jQuery solution for anyone still living in the dark ages.

Converting string to decimal character array in Apex

Recently I had to find a way to convert strings into their ascii decimal value. I solved this by converting to hex first, and then using some simple math to get the decimal value of each character. This won’t work on double byte characters, but that wasn’t my use case so for now this will work for me.

Edit: After some thinking, making this double byte or even multiple byte wouldn’t be too hard if you were to figure out the ratio of input length to hex output length, then increase the formula to increase the power of 16. I’ll try to get back to this later this week and update for those using multi byte characters.

Edit2: After more investigation and learning the ins and outs of UTF8 I now fully understand the return values of the EncodingUtil.convertToHex method. It returns bytes in UTF8 format. Each byte explains how many bytes that character uses. Some bytes use 1 (old school ascii compatible 0-127), some use 2, 3 or even 4. The range in the first byte tells a story about that character. I have a method to convert these to decimals that can be parsed by String.fromCharArray if anyone is interested. So since each byte is encoded in this, this technically handles UTF8 just fine, and works perfect for my apex ported AES encryption :-)

private static Map<String,Integer> hexMap = new Map<String,Integer>();
static {
	hexMap.put('0',0);
	hexMap.put('1',1);
	hexMap.put('2',2);
	hexMap.put('3',3);
	hexMap.put('4',4);
	hexMap.put('5',5);
	hexMap.put('6',6);
	hexMap.put('7',7);
	hexMap.put('8',8);
	hexMap.put('9',9);
	hexMap.put('A',10);
	hexMap.put('B',11);
	hexMap.put('C',12);
	hexMap.put('D',13);
	hexMap.put('E',14);
	hexMap.put('F',15);
	hexMap.put('a',10);
	hexMap.put('b',11);
	hexMap.put('c',12);
	hexMap.put('d',13);
	hexMap.put('e',14);
	hexMap.put('f',15);
}

public static List<Integer> stringToInt(String input) {
	String hex = EncodingUtil.convertToHex(Blob.valueOf(input));
	List<Integer> retValues = new List<Integer>();

	for(Integer i=0;i<hex.length();i+=2) {
		retValues.add( (hexMap.get(hex.substring(i,i+1))*16) + (hexMap.get(hex.substring(i+1,i+2))) );
	}
	return retValues;
}