A collection of AE extendscript snippets that might be usefull.
Not everything is 100% mine. If you feel like getting credits, please let me know.

Inertia Bounce

amp = .03;
freq = 4.0;
decay = 8.0;
n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time){
n--;
}
}
if (n == 0){
t = 0;
}else{
t = time - key(n).time;
}
if (n > 0 && t < 1){
v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{
value;
}

Reference to layer

Reference to layer below
thisComp.layer(index+1).transform.position
Reference to specific layer
thisComp.layer("layername").transform.position
Reference to layer with delay
thisComp.layer(index+1).transform.position.valueAtTime(time-.05)
thisComp.layer("layername").transform.position.valueAtTime(time-.05)

Count number of lines

temp = thisComp.layer("layername").text.sourceText;
numLines = (temp.split("\r").length - 1);

Convert text to number

L1 = thisComp.layer("layername").text.sourceText;
[transform.scale[0],parseFloat(L1)];

Counter

numDecimals = 2;
commas = true;
dollarSign = true;
beginCount = -1999;
endCount = 1999;
dur = 4;

t = time - inPoint;
s = linear (t, 0, dur, beginCount, endCount).toFixed(numDecimals);

prefix = "";
if (s[0] == "-"){
prefix = "-";
s = s.substr(1);
}
if(dollarSign) prefix += "$";

if (commas){
decimals = "";
if (numDecimals > 0){
decimals = s.substr(-(numDecimals + 1));
s = s.substr(0,s.length - (numDecimals + 1));
}
outStr = s.substr(-s.length, (s.length-1)%3 +1);
for (i = Math.floor((s.length-1)/3); i > 0; i--){
outStr += "," + s.substr(-i*3,3);
}
prefix + outStr + decimals;
}else{
prefix + s;
}

Split comp name into sourceText

thisComp.name.split(" - ")[0] // line 1 thisComp.name.split(" - ")[1] // line 2

Remove special characters from sourceText

temp = comp("composition name").layer("layer name").text.sourceText.replace(/\r/gi, " ").replace(/\u0104/g,"A").replace(/\u0106/g, "C").replace(/\u0118/g, "E").replace(/\u0141/g, "L").replace(/\u0143/g, "N").replace(/\u00D3/g, "O").replace(/\u015A/g, "S").replace(/\u0179/g, "Z").replace(/\u017B/g, "Z").replace("\u0105", "a").replace(/\u0107/g, "c").replace(/\u0119/g, "e").replace(/\u0142/g, "l").replace(/\u0144/g, "n").replace(/\u00F3/g, "o").replace(/\u015B/g, "s").replace(/\u017A/g, "z").replace(/\u017C/g, "z").replace(/ó/g,"o").replace("’", "").replace("‘", "").replace("\.", "").toLowerCase();
temp = temp.replace(/ /gi, "");